From cfe5763f2b574f3e64042913d501ac38da8e5ce3 Mon Sep 17 00:00:00 2001 From: bvandekerkhof Date: Wed, 13 Mar 2024 15:35:48 +0100 Subject: [PATCH] Release tagging updates Signed-off-by: bvandekerkhof --- .github/get_version.py | 14 ++++++++++ .github/workflows/main.yml | 10 +++---- .github/workflows/manual_release.yml | 39 +++++++++++++++++++++++++++ .github/workflows/release_tagging.yml | 9 ++----- 4 files changed, 60 insertions(+), 12 deletions(-) create mode 100644 .github/get_version.py create mode 100644 .github/workflows/manual_release.yml diff --git a/.github/get_version.py b/.github/get_version.py new file mode 100644 index 0000000..c6c94af --- /dev/null +++ b/.github/get_version.py @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: 2024 Shell Global Solutions International B.V. All Rights Reserved. +# +# SPDX-License-Identifier: Apache-2.0 + +import re + +with open("pyproject.toml", "r") as file: + version_content = file.read() +# Match regex for pattern +current_semantic_version = re.findall(r'version = "(\d+\.\d+\.[a-zA-Z0-9]+)"', version_content) +major_version, minor_version, patch_version = current_semantic_version[0].split(".") +patch_version = int(re.findall(r"\d+", patch_version)[0]) +output_semantic_version = f"{major_version}.{minor_version}.{patch_version}" +print(output_semantic_version) # Print is required for release in GitHub action diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1e6adaf..c4bcf54 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -39,11 +39,11 @@ jobs: uses: sede-open/pyELQ/.github/workflows/sonarcloud_analysis.yml@main needs: Tests secrets: inherit -# -# ReleaseTag: -# uses: sede-open/pyELQ/.github/workflows/release_tagging.yml@main -# needs: [CodeFormat, Pydocstyle, Pylint, Tests] -# secrets: inherit + + ReleaseTag: + uses: sede-open/pyELQ/.github/workflows/release_tagging.yml@main + needs: [CodeFormat, Pydocstyle] + secrets: inherit Build: uses: sede-open/pyELQ/.github/workflows/build_package.yml@main diff --git a/.github/workflows/manual_release.yml b/.github/workflows/manual_release.yml new file mode 100644 index 0000000..16ca501 --- /dev/null +++ b/.github/workflows/manual_release.yml @@ -0,0 +1,39 @@ +# SPDX-FileCopyrightText: 2024 Shell Global Solutions International B.V. All Rights Reserved. +# +# SPDX-License-Identifier: Apache-2.0 + +name: ManualReleaseTag + +on: + workflow_dispatch: + +jobs: + # Releases new Python version + Release: + runs-on: ubuntu-latest + strategy: + matrix: + # Specify all python versions you might want to perform the actions on + python-version: [ "3.11" ] + steps: + # Checkout + - name: Checkout + uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Get version + env: + GITHUB_ACCESS_TOKEN: ${{ secrets.PYELQ_TOKEN }} + id: version + run: | + version=$(python .github/get_version.py) + echo "BUMPED_VERSION=$(echo v$version)" >> $GITHUB_ENV + echo "New version: $version" + - name: Create Release + run: gh release create ${{ env.BUMPED_VERSION }} --generate-notes + env: + GITHUB_TOKEN: ${{ secrets.PYELQ_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/release_tagging.yml b/.github/workflows/release_tagging.yml index 7764ccc..15aa826 100644 --- a/.github/workflows/release_tagging.yml +++ b/.github/workflows/release_tagging.yml @@ -25,17 +25,12 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - - name: Bump version and commit bumped version back to branch + - name: Get version env: GITHUB_ACCESS_TOKEN: ${{ secrets.PYELQ_TOKEN }} id: version run: | - version=$(python .github/bump_version.py) - git config --global user.name 'bump_version' - git config --global user.email 'action@github.com' - git remote set-url origin "https://$GITHUB_ACCESS_TOKEN@github.com/$GITHUB_REPOSITORY" - git commit --signoff -am "Bumped minor version" - git push + version=$(python .github/get_version.py) echo "BUMPED_VERSION=$(echo v$version)" >> $GITHUB_ENV echo "New version: $version" - name: Create Release