From 5ad7511f50ac265399a06e7ece31d25a27b4c1f0 Mon Sep 17 00:00:00 2001 From: David Gonzalez Martin Date: Sun, 3 Nov 2024 14:13:11 -0600 Subject: [PATCH] Automate tag creation --- .github/workflows/ci.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c8da33b..ea9bd73 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,6 +67,27 @@ jobs: CMAKE_BUILD_TYPE: ${{matrix.CMAKE_BUILD_TYPE}} CMAKE_PREFIX_PATH: ${{steps.FETCH.outputs.CMAKE_PREFIX_PATH}} BUSTER_GITHUB_RUN: "true" + - name: Create tag + if: github.ref == 'refs/heads/main' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + git config --global user.name "github-actions" + git config --global user.email "github-actions@github.com" + # Get the current date in YYYY-MM-DD format + DATE=$(date +"%Y-%m-%d") + + # Get the current commit hash (first 7 characters) + COMMIT_HASH=$(git rev-parse --short HEAD) + + # Create the tag with the format "release-YYYY-MM-DD-commit" + TAG="automatic-release-${DATE}-${COMMIT_HASH}" + + # Create the annotated tag + git tag -a "$TAG" -m "Release on $DATE for commit $COMMIT_HASH" + + # Push the tag to the remote repository + git push origin "$TAG" - name: Release uses: softprops/action-gh-release@v2 if: github.ref == 'refs/heads/main'