From 57453a0601ae1250fdee71b0561af4c0a7384051 Mon Sep 17 00:00:00 2001 From: Roberto Pastor Muela <37798125+RobPasMue@users.noreply.github.com> Date: Tue, 10 Dec 2024 07:35:43 +0000 Subject: [PATCH 1/2] wip_ first draft --- .github/workflows/autorelease.yml | 52 +++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/autorelease.yml diff --git a/.github/workflows/autorelease.yml b/.github/workflows/autorelease.yml new file mode 100644 index 0000000..9fd9d9e --- /dev/null +++ b/.github/workflows/autorelease.yml @@ -0,0 +1,52 @@ +name: Auto Release + +on: + workflow_dispatch: + inputs: + patch_release: + description: "Select the type of release" + type: choice + options: + - patch + - minor + - major + +jobs: + patch-release: + runs-on: ubuntu-latest + + steps: + # Checkout the repository + - name: Checkout Repository + uses: actions/checkout@v4 + + # Retrieve the latest release tag from GitHub + - name: Get Latest Release Branch + id: get-release + run: | + # Fetch all tags + git fetch --tags + + # Get the latest release tag + LATEST_RELEASE=$(git tag --list "v*" --sort=-version:refname | head -n 1) + + # Parse major and minor version numbers + if [[ "$LATEST_RELEASE" =~ ^v([0-9]+)\.([0-9]+)\.[0-9]+$ ]]; then + MAJOR="${BASH_REMATCH[1]}" + MINOR="${BASH_REMATCH[2]}" + RELEASE_BRANCH="release/${MAJOR}.${MINOR}" + else + echo "Error: Unable to parse the latest release tag." + exit 1 + fi + + # Export the release branch name + echo "RELEASE_BRANCH=${RELEASE_BRANCH}" >> $GITHUB_ENV + + # Run the patch release script + - name: Run Patch Release Script + if: ${{ inputs.choice }} == "patch" + run: | + ./release.sh "$RELEASE_BRANCH" + env: + RELEASE_BRANCH: ${{ env.RELEASE_BRANCH }} \ No newline at end of file From 09c413a769a0dfc95677795b9149b35867d7999a Mon Sep 17 00:00:00 2001 From: Roberto Pastor Muela <37798125+RobPasMue@users.noreply.github.com> Date: Tue, 10 Dec 2024 09:00:56 +0100 Subject: [PATCH 2/2] ci: finish autorelease script --- .github/workflows/autorelease.yml | 37 +++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/.github/workflows/autorelease.yml b/.github/workflows/autorelease.yml index 9fd9d9e..8807323 100644 --- a/.github/workflows/autorelease.yml +++ b/.github/workflows/autorelease.yml @@ -3,7 +3,7 @@ name: Auto Release on: workflow_dispatch: inputs: - patch_release: + release_type: description: "Select the type of release" type: choice options: @@ -20,6 +20,12 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 + # Configure Git + - name: Configure Git + run: | + git config --global user.name ${{ secrets.PYANSYS_CI_BOT_USERNAME }} + git config --global user.email ${{ secrets.PYANSYS_CI_BOT_EMAIL }} + # Retrieve the latest release tag from GitHub - name: Get Latest Release Branch id: get-release @@ -35,6 +41,8 @@ jobs: MAJOR="${BASH_REMATCH[1]}" MINOR="${BASH_REMATCH[2]}" RELEASE_BRANCH="release/${MAJOR}.${MINOR}" + echo "Latest release tag: $LATEST_RELEASE" + echo "Associated release branch: $RELEASE_BRANCH" else echo "Error: Unable to parse the latest release tag." exit 1 @@ -45,8 +53,29 @@ jobs: # Run the patch release script - name: Run Patch Release Script - if: ${{ inputs.choice }} == "patch" + if: ${{ github.event.inputs.release_type == 'patch' }} + env: + GITHUB_TOKEN: ${{ secrets.PYANSYS_CI_BOT_TOKEN }} + RELEASE_BRANCH: ${{ env.RELEASE_BRANCH }} + run: | + ./scripts/patch_release.sh ${{ env.RELEASE_BRANCH }} + + # Run the minor release script + - name: Run Minor Release Script + if: ${{ github.event.inputs.release_type == 'minor' }} + env: + GITHUB_TOKEN: ${{ secrets.PYANSYS_CI_BOT_TOKEN }} run: | - ./release.sh "$RELEASE_BRANCH" + # TODO: Implement the minor release script + echo "Minor release script not implemented." + exit 1 + + # Run the major release script + - name: Run Major Release Script + if: ${{ github.event.inputs.release_type == 'major' }} env: - RELEASE_BRANCH: ${{ env.RELEASE_BRANCH }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.PYANSYS_CI_BOT_TOKEN }} + run: | + # TODO: Implement the major release script + echo "Major release script not implemented." + exit 1