From b56a9d7d861810b6f1d5d76bd1389fe60e49eba3 Mon Sep 17 00:00:00 2001 From: achour94 Date: Tue, 26 Nov 2024 15:55:31 +0100 Subject: [PATCH 1/6] Implement release workflow Signed-off-by: achour94 --- .github/workflows/release.yml | 100 ++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..20abaa00a --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,100 @@ +name: Release + +on: + workflow_dispatch: + inputs: + versionType: + description: 'Version type increment' + required: true + type: choice + options: + - major + - minor + - patch + +permissions: + contents: write + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/create-github-app-token@v1 + id: app-token + name: Generate app token + with: + app-id: ${{ vars.GRIDSUITE_ACTIONS_APPID }} + private-key: ${{ secrets.GRIDSUITE_ACTIONS_SECRET }} + + - name: Checkout sources + uses: actions/checkout@v4 + with: + token: ${{ steps.app-token.outputs.token }} + fetch-depth: 0 # Fetch all history for all tags and branches + + - name: Set up JDK 17 + uses: actions/setup-java@v1 + with: + java-version: 17 + + - name: Calculate versions + id: versions + run: | + # Get latest tag (e.g., v1.20.0) + LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0") + echo "Latest tag: $LATEST_TAG" + + # Remove 'v' prefix and split version + LATEST_VERSION=${LATEST_TAG#v} + IFS='.' read -r MAJOR MINOR PATCH <<< "$LATEST_VERSION" + + # Calculate versions based on version type + case "${{ github.event.inputs.versionType }}" in + "major") + RELEASE_VERSION="$((MAJOR + 1)).0.0" + NEXT_VERSION="$((MAJOR + 1)).1.0-SNAPSHOT" + ;; + "minor") + RELEASE_VERSION="$MAJOR.$((MINOR + 1)).0" + NEXT_VERSION="$MAJOR.$((MINOR + 2)).0-SNAPSHOT" + ;; + "patch") + RELEASE_VERSION="$MAJOR.$MINOR.$((PATCH + 1))" + NEXT_VERSION="$MAJOR.$((MINOR + 1)).0-SNAPSHOT" + ;; + esac + + echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_OUTPUT + echo "NEXT_VERSION=${NEXT_VERSION}" >> $GITHUB_OUTPUT + echo "Release version will be: ${RELEASE_VERSION}" + echo "Next development version will be: ${NEXT_VERSION}" + + - name: Configure Git + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" + + - name: Set release version + run: | + mvn versions:set -DnewVersion=${{ steps.versions.outputs.RELEASE_VERSION }} -DgenerateBackupPoms=false + git commit -am "Release version ${{ steps.versions.outputs.RELEASE_VERSION }}" + + - name: Create and push tag + run: | + git tag v${{ steps.versions.outputs.RELEASE_VERSION }} -m "Release v${{ steps.versions.outputs.RELEASE_VERSION }}" + git push origin v${{ steps.versions.outputs.RELEASE_VERSION }} + git push origin main + + - name: Create GitHub Release + env: + GH_TOKEN: ${{ steps.app-token.outputs.token }} + run: | + gh release create v${{ steps.versions.outputs.RELEASE_VERSION }} \ + --title "v${{ steps.versions.outputs.RELEASE_VERSION }}" \ + --generate-notes + + - name: Set next development version + run: | + mvn versions:set -DnewVersion=${{ steps.versions.outputs.NEXT_VERSION }} -DgenerateBackupPoms=false + git commit -am "Prepare for next development version ${{ steps.versions.outputs.NEXT_VERSION }}" + git push origin main \ No newline at end of file From 712ecfd2d491cc79a7040d82a4be61bead1fe936 Mon Sep 17 00:00:00 2001 From: achour94 Date: Tue, 26 Nov 2024 16:13:59 +0100 Subject: [PATCH 2/6] Implement release workflow Signed-off-by: achour94 --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 20abaa00a..2f0d06a9d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -81,7 +81,7 @@ jobs: - name: Create and push tag run: | - git tag v${{ steps.versions.outputs.RELEASE_VERSION }} -m "Release v${{ steps.versions.outputs.RELEASE_VERSION }}" + git tag v${{ steps.versions.outputs.RELEASE_VERSION }} git push origin v${{ steps.versions.outputs.RELEASE_VERSION }} git push origin main From aa57c88e7c53a39afbcd235183c19bec8ba799c1 Mon Sep 17 00:00:00 2001 From: achour94 Date: Thu, 5 Dec 2024 14:25:01 +0100 Subject: [PATCH 3/6] Implement release and patch workflows Signed-off-by: achour94 --- .github/workflows/patch.yml | 18 +++++++ .github/workflows/release.yml | 95 +++-------------------------------- 2 files changed, 26 insertions(+), 87 deletions(-) create mode 100644 .github/workflows/patch.yml diff --git a/.github/workflows/patch.yml b/.github/workflows/patch.yml new file mode 100644 index 000000000..47be379eb --- /dev/null +++ b/.github/workflows/patch.yml @@ -0,0 +1,18 @@ +name: Patch + +on: + workflow_dispatch: + inputs: + branchRef: + description: 'Patch branch (format: release-vX.Y.Z)' + required: true + type: string + +jobs: + run-patch: + uses: powsybl/github-ci/.github/workflows/patch-backend-lib-generic.yml@859a4effdaa9c5e79684378f39778fd8d06df3c5 + with: + githubappId: ${{ vars.GRIDSUITE_ACTIONS_APPID }} + branchRef: ${{ github.event.inputs.branchRef }} + secrets: + githubappPrivateKey: ${{ secrets.GRIDSUITE_ACTIONS_SECRET }} \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2f0d06a9d..e0f001299 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,97 +4,18 @@ on: workflow_dispatch: inputs: versionType: - description: 'Version type increment' + description: 'Version type increment (major | minor)' required: true type: choice options: - major - minor - - patch - -permissions: - contents: write jobs: - release: - runs-on: ubuntu-latest - steps: - - uses: actions/create-github-app-token@v1 - id: app-token - name: Generate app token - with: - app-id: ${{ vars.GRIDSUITE_ACTIONS_APPID }} - private-key: ${{ secrets.GRIDSUITE_ACTIONS_SECRET }} - - - name: Checkout sources - uses: actions/checkout@v4 - with: - token: ${{ steps.app-token.outputs.token }} - fetch-depth: 0 # Fetch all history for all tags and branches - - - name: Set up JDK 17 - uses: actions/setup-java@v1 - with: - java-version: 17 - - - name: Calculate versions - id: versions - run: | - # Get latest tag (e.g., v1.20.0) - LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0") - echo "Latest tag: $LATEST_TAG" - - # Remove 'v' prefix and split version - LATEST_VERSION=${LATEST_TAG#v} - IFS='.' read -r MAJOR MINOR PATCH <<< "$LATEST_VERSION" - - # Calculate versions based on version type - case "${{ github.event.inputs.versionType }}" in - "major") - RELEASE_VERSION="$((MAJOR + 1)).0.0" - NEXT_VERSION="$((MAJOR + 1)).1.0-SNAPSHOT" - ;; - "minor") - RELEASE_VERSION="$MAJOR.$((MINOR + 1)).0" - NEXT_VERSION="$MAJOR.$((MINOR + 2)).0-SNAPSHOT" - ;; - "patch") - RELEASE_VERSION="$MAJOR.$MINOR.$((PATCH + 1))" - NEXT_VERSION="$MAJOR.$((MINOR + 1)).0-SNAPSHOT" - ;; - esac - - echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_OUTPUT - echo "NEXT_VERSION=${NEXT_VERSION}" >> $GITHUB_OUTPUT - echo "Release version will be: ${RELEASE_VERSION}" - echo "Next development version will be: ${NEXT_VERSION}" - - - name: Configure Git - run: | - git config --global user.name "github-actions[bot]" - git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" - - - name: Set release version - run: | - mvn versions:set -DnewVersion=${{ steps.versions.outputs.RELEASE_VERSION }} -DgenerateBackupPoms=false - git commit -am "Release version ${{ steps.versions.outputs.RELEASE_VERSION }}" - - - name: Create and push tag - run: | - git tag v${{ steps.versions.outputs.RELEASE_VERSION }} - git push origin v${{ steps.versions.outputs.RELEASE_VERSION }} - git push origin main - - - name: Create GitHub Release - env: - GH_TOKEN: ${{ steps.app-token.outputs.token }} - run: | - gh release create v${{ steps.versions.outputs.RELEASE_VERSION }} \ - --title "v${{ steps.versions.outputs.RELEASE_VERSION }}" \ - --generate-notes - - - name: Set next development version - run: | - mvn versions:set -DnewVersion=${{ steps.versions.outputs.NEXT_VERSION }} -DgenerateBackupPoms=false - git commit -am "Prepare for next development version ${{ steps.versions.outputs.NEXT_VERSION }}" - git push origin main \ No newline at end of file + run-release: + uses: powsybl/github-ci/.github/workflows/release-backend-lib-generic.yml@859a4effdaa9c5e79684378f39778fd8d06df3c5 + with: + githubappId: ${{ vars.GRIDSUITE_ACTIONS_APPID }} + versionType: ${{ github.event.inputs.versionType }} + secrets: + githubappPrivateKey: ${{ secrets.GRIDSUITE_ACTIONS_SECRET }} \ No newline at end of file From c1a45ce064cfc29972c8007aa9c978c74c176113 Mon Sep 17 00:00:00 2001 From: achour94 Date: Thu, 5 Dec 2024 15:43:09 +0100 Subject: [PATCH 4/6] Implement release and patch workflows Signed-off-by: achour94 --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e0f001299..c6251020a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,7 +15,7 @@ jobs: run-release: uses: powsybl/github-ci/.github/workflows/release-backend-lib-generic.yml@859a4effdaa9c5e79684378f39778fd8d06df3c5 with: - githubappId: ${{ vars.GRIDSUITE_ACTIONS_APPID }} + githubappId: ${{ vars.POWSYBL_ACTIONS_APPID }} versionType: ${{ github.event.inputs.versionType }} secrets: - githubappPrivateKey: ${{ secrets.GRIDSUITE_ACTIONS_SECRET }} \ No newline at end of file + githubappPrivateKey: ${{ secrets.POWSYBL_ACTIONS_SECRET }} \ No newline at end of file From c2b321312d753dba893e971bd816695a0ad2cff8 Mon Sep 17 00:00:00 2001 From: achour94 Date: Thu, 5 Dec 2024 15:57:23 +0100 Subject: [PATCH 5/6] Implement release and patch workflows Signed-off-by: achour94 --- .github/workflows/patch.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/patch.yml b/.github/workflows/patch.yml index 47be379eb..e7d03fd65 100644 --- a/.github/workflows/patch.yml +++ b/.github/workflows/patch.yml @@ -12,7 +12,7 @@ jobs: run-patch: uses: powsybl/github-ci/.github/workflows/patch-backend-lib-generic.yml@859a4effdaa9c5e79684378f39778fd8d06df3c5 with: - githubappId: ${{ vars.GRIDSUITE_ACTIONS_APPID }} + githubappId: ${{ vars.POWSYBL_ACTIONS_APPID }} branchRef: ${{ github.event.inputs.branchRef }} secrets: - githubappPrivateKey: ${{ secrets.GRIDSUITE_ACTIONS_SECRET }} \ No newline at end of file + githubappPrivateKey: ${{ secrets.POWSYBL_ACTIONS_SECRET }} \ No newline at end of file From 830c4a50aa060129efd0360f5254361e6e7af345 Mon Sep 17 00:00:00 2001 From: achour94 Date: Fri, 6 Dec 2024 10:19:29 +0100 Subject: [PATCH 6/6] Implement release and patch workflows Signed-off-by: achour94 --- .github/workflows/maven.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 12710fdf3..2cc40a6d3 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -4,9 +4,6 @@ on: push: branches: - 'main' - - 'release-v**' - tags: - - 'v[0-9]*' pull_request: jobs: