From a1e92b4bcdaf81d5b5e8f3edab60e33549e9009b Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Thu, 7 Nov 2024 08:00:13 +0100 Subject: [PATCH] feat(ci): Add action to add SemVer tags Signed-off-by: Steffen Vogel --- .github/workflows/release-tag.yaml | 47 ++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/release-tag.yaml diff --git a/.github/workflows/release-tag.yaml b/.github/workflows/release-tag.yaml new file mode 100644 index 0000000..995075a --- /dev/null +++ b/.github/workflows/release-tag.yaml @@ -0,0 +1,47 @@ +# SPDX-FileCopyrightText: 2023-2024 Steffen Vogel +# SPDX-License-Identifier: Apache-2.0 + +# yaml-language-server: $schema=https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/github-workflow.json +--- +name: Tag Semver + +on: + push: + branches: + - main + +jobs: + semver-tag: + name: Add a Semantic Versioned Tag + runs-on: ubuntu-latest + + permissions: + contents: write + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.PAT }} + + - uses: actions/setup-go@v5 + with: + go-version: '1.22.2' + + - name: Setup svu + run: | + go install github.com/caarlos0/svu@latest + + - name: Create new tag + run: | + CURRENT=$(svu current) + NEXT=$(svu next) + + if [ ${CURRENT} != ${NEXT} ]; then + git tag ${NEXT} + git push origin tag ${NEXT} + + echo "Tagged new release with ${NEXT}" + else + echo "No new commits to tag" + fi \ No newline at end of file