From 787df9b2cb5f2a95fe3b339d5ecc612279fc6e5d Mon Sep 17 00:00:00 2001 From: Felix Seifert Date: Mon, 18 Mar 2024 06:59:06 +0100 Subject: [PATCH] ci: add workflow to automatically release to PyPI and GitHub * This workflow gets automatically triggered on any tag push if the tag starts with `v*`. * This workflow builds and deploys the lib to PyPI with Twine. * After a successful deployment to PyPI, the workflow calls another workflow to issue a GitHub release. --- .github/workflows/release.yaml | 55 ++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..452c3c1 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,55 @@ +name: Release to PyPI and GitHub + +on: + push: + tags: + - 'v*' # Push events with tags 'v*', i.e. 'v1.0.4' or 'v0.3.2' + +jobs: + deploy-with-twine: + + runs-on: ubuntu-latest + + steps: + + - uses: actions/checkout@v4 + with: + sparse-checkout: | + .github + src + pyproject.toml + requirements.txt + + - name: Set up Python 3.10 + uses: actions/setup-python@v5 + with: + python-version: 3.10 + cache: "pip" + + - name: Install dependencies (with Twine) + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install twine + + - name: Build dist + run: | + python -m build + + - name: Test dist + run: | + python -m twine check dist/* + + - name: Deploy dist + run: | + python -m twine upload dist/* + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + + release-on-github: + needs: deploy-with-twine + name: Trigger GitHub release workflow + uses: ./.github/workflows/release-on-github.yaml + with: + tag: ${{ github.ref_name }}