From 9a29ee1f6a045728a6ba885e22f275f350e38b3f Mon Sep 17 00:00:00 2001 From: Sietze van Buuren Date: Wed, 21 Aug 2024 09:52:06 +0200 Subject: [PATCH] feat: Setup automatic semantic version releases with PyPi publishing Signed-off-by: Sietze van Buuren --- .github/workflows/{ci.yml => docs.yaml} | 5 +- .github/workflows/release.yaml | 71 +++++++++++++++++++++++++ README.md | 8 +-- 3 files changed, 80 insertions(+), 4 deletions(-) rename .github/workflows/{ci.yml => docs.yaml} (98%) create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/ci.yml b/.github/workflows/docs.yaml similarity index 98% rename from .github/workflows/ci.yml rename to .github/workflows/docs.yaml index 4a13c41..9ea4f9b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/docs.yaml @@ -1,10 +1,13 @@ -name: ci +name: docs + on: push: branches: - master + permissions: contents: write + jobs: deploy: runs-on: ubuntu-latest diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..15f7103 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,71 @@ +# Release workflow for push commits to the 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 + +name: Release + +on: + push: + branches: + - master + +jobs: + release: + name: Semantic Release + runs-on: ubuntu-latest + concurrency: push + if: github.repository == 'swvanbuuren/simple-cdd-yaml' + environment: + name: pypi + url: https://pypi.org/project/simple-cdd-yaml/ + 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 }} diff --git a/README.md b/README.md index 2617c93..07c3274 100644 --- a/README.md +++ b/README.md @@ -38,9 +38,11 @@ information. ## Installation -Simple-CDD-YAML can be installed using `pip`: -``` -pip install git+https://github.com/swvanbuuren/simple-cdd-yaml.git +Simple-CDD-YAML can be directly installed from [PyPi](https://pypi.org) using +`pip`: + +```bash +pip install simple-cdd-yaml ``` ## Usage