From ac4326d13dde1d6594dbfcb05f9bdb7d8879be6e Mon Sep 17 00:00:00 2001 From: Jonas Bushart Date: Wed, 20 Apr 2022 19:46:12 +0000 Subject: [PATCH] Add autotag action to keep semantic version tags --- .github/workflows/autotag-releases.yml | 31 ++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/autotag-releases.yml diff --git a/.github/workflows/autotag-releases.yml b/.github/workflows/autotag-releases.yml new file mode 100644 index 0000000..a0b5f30 --- /dev/null +++ b/.github/workflows/autotag-releases.yml @@ -0,0 +1,31 @@ +# Create tags with only major or major.minor version +# This runs for every created release. Releases are expected to use vmajor.minor.patch as tags. + +name: Autotag Release +on: + release: + types: [released] + workflow_dispatch: +permissions: read-all + +jobs: + autotag_release: + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/v') + permissions: + contents: write + steps: + - uses: actions/checkout@v3 + - name: Get version from tag + id: tag_name + run: | + echo ::set-output name=current_version::${GITHUB_REF#refs/tags/} + shell: bash + - name: Create and push tags + run: | + MINOR="$(echo -n ${{ steps.tag_name.outputs.current_version }} | cut -d. -f1-2)" + MAJOR="$(echo -n ${{ steps.tag_name.outputs.current_version }} | cut -d. -f1)" + git tag -f "${MINOR}" + git tag -f "${MAJOR}" + git push -f origin "${MINOR}" + git push -f origin "${MAJOR}"