From c6eeaaca2d6c2d1bb9e1954c271223337dd90347 Mon Sep 17 00:00:00 2001 From: Giovanni Ciatto Date: Sun, 5 May 2024 16:39:26 +0200 Subject: [PATCH] chore(ci): automate release --- .github/workflows/check.yml | 38 +++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index e4c980b..7f6bb32 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -42,3 +42,41 @@ jobs: - name: Test shell: bash run: poetry run python -m unittest discover -v -s tests + + release: + needs: test + if: github.ref == 'refs/heads/master' + runs-on: ubuntu-latest + name: Release on PyPI and GitHub + permissions: + contents: write + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Install poetry + run: pip install poetry + + - name: Restore Python dependencies + run: poetry install + + - name: Bump version + shell: bash + run: poetry run python bump_version.py --apply | tee CHANGELOG.md + + - name: Build Python Package + run: poetry build + + - name: Publish on TestPyPI + run: poetry publish --repository pypi-test --username __token__ --password ${{ secrets.TEST_PYPI_TOKEN }} + + - name: Create GitHub Release + shell: bash + run: | + RELEASE_TAG=$(poetry version --short) + gh release create $RELEASE_TAG dist/* -t v$RELEASE_TAG -F CHANGELOG.md + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}