From 6b4a6e6f684352483e632b31291f62865a878d5f Mon Sep 17 00:00:00 2001 From: aarons20 Date: Sat, 18 Nov 2023 21:51:08 +0100 Subject: [PATCH] Automate git tagging with GitHub Action -[ADDED] GitHub Action adds git tag after releasing package to PyPi -[CHANGED] Version number now in separate file --- .github/workflows/pypi_ci.yaml | 24 +++++++++++++++++++----- VERSION | 1 + setup.py | 5 ++++- 3 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 VERSION diff --git a/.github/workflows/pypi_ci.yaml b/.github/workflows/pypi_ci.yaml index 2be8630..a7223ef 100644 --- a/.github/workflows/pypi_ci.yaml +++ b/.github/workflows/pypi_ci.yaml @@ -11,8 +11,7 @@ permissions: jobs: build-python-package: name: Build distribution packages - runs-on: ubuntu-latest - + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v4 @@ -29,7 +28,7 @@ jobs: with: name: python-package-distributions path: dist/ - + publish-to-pypi: name: Publish Python distribution package to PyPI if: ${{ github.repository == 'quantorconsulting/mkdocs_build_plantuml' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') }} @@ -40,8 +39,7 @@ jobs: name: pipy url: https://pypi.org/p/mkdocs-build-plantuml-plugin permissions: - id-token: write - + id-token: write steps: - name: Download all the dists uses: actions/download-artifact@v3 @@ -50,3 +48,19 @@ jobs: path: dist/ - name: Publish distribution packages to PyPI uses: pypa/gh-action-pypi-publish@release/v1 + + add-git-tag: + name: Add version tag to repository + needs: + - publish-to-pypi + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Get version from VERSION file + id: get_version + run: | + echo "version=$(cat VERSION)" >> $GITHUB_OUTPUT + - name: Create and push tag + run: | + git tag ${{ steps.get_version.outputs.version }} + git push origin ${{ steps.get_version.outputs.version }} diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..f8e233b --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +1.9.0 diff --git a/setup.py b/setup.py index 157ddec..fbf16d0 100644 --- a/setup.py +++ b/setup.py @@ -7,9 +7,12 @@ long_description = f.read() +with open('VERSION', 'r') as f: + __version__ = f.read().strip() + setup( name="mkdocs-build-plantuml-plugin", - version="1.9.0", + version=__version__, description="An MkDocs plugin to call plantuml locally or remote", long_description=long_description, long_description_content_type="text/markdown",