From 5a44c9231df5848f7092a3c263075ccad197e82b Mon Sep 17 00:00:00 2001 From: Sietze van Buuren Date: Mon, 19 Aug 2024 17:13:04 +0200 Subject: [PATCH] feat: Add semantic release management and publishing to PyPi Signed-off-by: Sietze van Buuren --- .github/workflows/push.yaml | 69 +++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 .github/workflows/push.yaml diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml new file mode 100644 index 0000000..0c770b0 --- /dev/null +++ b/.github/workflows/push.yaml @@ -0,0 +1,69 @@ +# Workflow for push commit to master branch + +# This workflow uses python semantic releases, which relies on certain commit tags to +# determine if a new release/version should be created. +# Checkout https://github.com/python-semantic-release/python-semantic-release form more +# info on how to use it. +# Also checkout https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#type to +# which types of commit messages are accepted + +on: + push: + branches: + - master + +jobs: + release: + name: Semantic Release + runs-on: ubuntu-latest + concurrency: push + if: github.repository == 'swvanbuuren/mlpyqtgraph' + environment: + name: pypi + url: https://pypi.org/project/mlpyqtgraph/ + permissions: + id-token: write + contents: write + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ github.ref_name }} + + - name: Python Semantic Release + id: release + uses: python-semantic-release/python-semantic-release@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Python + if: steps.release.outputs.released == 'true' + uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: Install dependencies + if: steps.release.outputs.released == 'true' + run: | + python -m pip install --upgrade pip + pip install build + + - name: Build package + if: steps.release.outputs.released == 'true' + run: python -m build + + - name: Publish package distributions to PyPI + id: pypi-publish + if: steps.release.outputs.released == 'true' + uses: pypa/gh-action-pypi-publish@release/v1 + with: + verbose: true + + - name: Publish package distributions to GitHub Releases + id: github-release + if: steps.release.outputs.released == 'true' + uses: python-semantic-release/upload-to-gh-release@main + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ steps.release.outputs.tag }}