From 024eebe0971680d67ef42afaaae19070890f842b Mon Sep 17 00:00:00 2001 From: LTLA Date: Sat, 5 Aug 2023 19:35:24 -0700 Subject: [PATCH] Auto-create tags based on cmake project version. --- .github/workflows/create-tag.yaml | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/create-tag.yaml diff --git a/.github/workflows/create-tag.yaml b/.github/workflows/create-tag.yaml new file mode 100644 index 0000000..c9cf667 --- /dev/null +++ b/.github/workflows/create-tag.yaml @@ -0,0 +1,33 @@ +on: + workflow_run: + workflows: [Run tests] + types: [completed] + branches: [master] + +name: Tag project version + +jobs: + tag: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} + steps: + - uses: actions/checkout@v3 + + - name: Get current version + id: current + run: | + current=$(cat CMakeLists.txt | grep ' *VERSION' | sed 's/.*VERSION //g') + echo "Current version is ${current}" + echo "version=v${current}" >> $GITHUB_OUTPUT + + - name: Get latest version + id: latest + uses: actions-ecosystem/action-get-latest-tag@v1 + with: + semver_only: true + + - name: Tag version if new + if: ${{ steps.current.outputs.version != steps.latest.outputs.tag }} + uses: actions-ecosystem/action-push-tag@v1 + with: + tag: ${{ steps.current.outputs.version }}