diff --git a/.github/workflows/create_version_tag.yml b/.github/workflows/create_version_tag.yml new file mode 100644 index 0000000000..acee1ebbd8 --- /dev/null +++ b/.github/workflows/create_version_tag.yml @@ -0,0 +1,77 @@ +name: Create a new version tag + +# This file is part of t8code. +# t8code is a C library to manage a collection (a forest) of multiple +# connected adaptive space-trees of general element types in parallel. +# +# Copyright (C) 2025 the developers +# +# t8code is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# t8code is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with t8code; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +on: + workflow_dispatch: + schedule: + # trigger at 0:00 on the first day of each month + - cron: '0 0 1 * *' + +jobs: + monthly_release: + runs-on: ubuntu-latest + steps: + #checkout main branch + - name: Checkout code + uses: actions/checkout@v6 + with: + fetch-depth: 0 + ref: main + persist-credentials: false + # Get the current version from the latest tag + - name: Get latest tag + id: get_latest_tag + run: | + LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`) + echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV + echo "LATEST_TAG=$LATEST_TAG" + # Get Major, Minor, Patch version numbers + - name: Parse version numbers + id: parse_version + run: | + VERSION_REGEX="v([0-9]+)\\.([0-9]+)\\.([0-9]+)" + if [[ "${{ env.LATEST_TAG }}" =~ $VERSION_REGEX ]]; then + MAJOR="${BASH_REMATCH[1]}" + MINOR="${BASH_REMATCH[2]}" + PATCH="${BASH_REMATCH[3]}" + echo "MAJOR=$MAJOR" >> $GITHUB_ENV + echo "MINOR=$MINOR" >> $GITHUB_ENV + echo "PATCH=$PATCH" >> $GITHUB_ENV + echo "MAJOR=$MAJOR, MINOR=$MINOR, PATCH=$PATCH" + else + echo "No valid tag found, aborting." + exit 1 + fi + # Create version name accessible in the following steps + - name: Set version name + run: | + echo "VERSION_NAME=v${{ env.MAJOR }}.${{ env.MINOR }}.${{ env.PATCH }}-$(date +'%Y.%m.%d')" >> $GITHUB_ENV + echo "VERSION_NAME=$VERSION_NAME" + # Create a new version tag + - name: Create version tag + run: | + git config user.email "t8ddy.bot@gmail.com" + git config user.name "t8ddy" + # configure remote to use the secret token for pushing + git remote set-url origin https://x-access-token:${{ secrets.T8DDY_TOKEN }}@github.com/${{ github.repository }} + git tag "${{ env.VERSION_NAME }}" + git push origin --tags \ No newline at end of file