From 8807d0e104c1c5e72790f909c748a511f1f8be2d Mon Sep 17 00:00:00 2001 From: Loic Coyle Date: Thu, 4 Jul 2024 16:20:54 +0200 Subject: [PATCH] ci: add release-please & publish on release --- .github/.release-please-manifest.json | 3 ++ .github/release-please-config.json | 13 ++++++++ .github/workflows/ci.yml | 44 +++++++++++++++++++++++++-- 3 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 .github/.release-please-manifest.json create mode 100644 .github/release-please-config.json diff --git a/.github/.release-please-manifest.json b/.github/.release-please-manifest.json new file mode 100644 index 0000000..37fcefa --- /dev/null +++ b/.github/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "1.0.0" +} diff --git a/.github/release-please-config.json b/.github/release-please-config.json new file mode 100644 index 0000000..624fd83 --- /dev/null +++ b/.github/release-please-config.json @@ -0,0 +1,13 @@ +{ + "packages": { + ".": { + "changelog-path": "CHANGELOG.md", + "release-type": "python", + "bump-minor-pre-major": false, + "bump-patch-for-minor-pre-major": false, + "draft": false, + "prerelease": false + } + }, + "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json" +} \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5a21411..7c0cd84 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ on: pull_request: jobs: - ci: + tests: strategy: fail-fast: false matrix: @@ -44,9 +44,47 @@ jobs: - name: Run pytest run: poetry run pytest -q tests + release: + name: release + if: ${{ github.ref == 'refs/heads/main' && github.repository_owner == 'loiccoyle' }} + needs: + - tests + outputs: + release_created: ${{ steps.release.release_created }} + runs-on: ubuntu-latest + steps: + - uses: googleapis/release-please-action@v4 + id: release + with: + config-file: .github/release-please-config.json + manifest-file: .github/.release-please-manifest.json + + publish: + name: Publish to pypi + needs: + - release + if: needs.release.outputs.release_created + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.12" + - uses: abatilo/actions-poetry@v3 + with: + poetry-version: 1.8.3 + + - name: Configure Pypi token + shell: bash + run: poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }} + + - name: Publish Package + shell: bash + run: poetry publish --build + readme: runs-on: ubuntu-latest - needs: ci + needs: tests steps: - uses: actions/checkout@v4 with: @@ -62,7 +100,7 @@ jobs: - name: Commit changes uses: stefanzweifel/git-auto-commit-action@v5 with: - commit_message: "ci: Update readme" + commit_message: "docs: update readme" branch: ${{ github.head_ref }} commit_user_name: github-actions[bot] commit_user_email: github-actions[bot]@users.noreply.github.com