From be2d8e566f86db5cbb051bf08039e61bd9675103 Mon Sep 17 00:00:00 2001 From: Joris Mancini Date: Mon, 14 Oct 2024 16:47:55 +0200 Subject: [PATCH 1/6] chore: add automated releases in GitHub Actions Signed-off-by: Joris Mancini --- .github/workflows/{maven.yml => build.yml} | 15 +--- .github/workflows/gh-release.yml | 21 +++++ .github/workflows/patch.yml | 84 +++++++++++++++++++ .github/workflows/release.yml | 96 ++++++++++++++++++++++ 4 files changed, 203 insertions(+), 13 deletions(-) rename .github/workflows/{maven.yml => build.yml} (71%) create mode 100644 .github/workflows/gh-release.yml create mode 100644 .github/workflows/patch.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/maven.yml b/.github/workflows/build.yml similarity index 71% rename from .github/workflows/maven.yml rename to .github/workflows/build.yml index 9b60eb4..9e5ca26 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/build.yml @@ -4,8 +4,6 @@ on: push: branches: - 'main' - tags: - - 'v[0-9]*' pull_request: jobs: @@ -23,7 +21,7 @@ jobs: uses: actions/checkout@v1 - name: Build with Maven - run: mvn --batch-mode -P jacoco verify + run: mvn --batch-mode -Pjacoco verify - name: Run SonarCloud analysis run: > @@ -43,16 +41,7 @@ jobs: -Djib.to.image=docker.io/gridsuite/spreadsheet-config-server -Djib.to.auth.username=gridsuiteci -Djib.to.auth.password=${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build Docker image - Tag - if: startsWith(github.ref, 'refs/tags/') - run: > - mvn --batch-mode deploy -DskipTests -Dmaven.install.skip -Dmaven.deploy.skip -Dpowsybl.docker.deploy - -Djib.httpTimeout=60000 - -Djib.to.image=docker.io/gridsuite/spreadsheet-config-server:${GITHUB_REF_NAME#v} - -Djib.to.auth.username=gridsuiteci - -Djib.to.auth.password=${{ secrets.DOCKERHUB_TOKEN }} - + - name: Broadcast update event if: github.ref == 'refs/heads/main' uses: gridsuite/broadcast-event@main diff --git a/.github/workflows/gh-release.yml b/.github/workflows/gh-release.yml new file mode 100644 index 0000000..17f673a --- /dev/null +++ b/.github/workflows/gh-release.yml @@ -0,0 +1,21 @@ +name: GH-Release + +on: + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' + +jobs: + gh-release: + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Create GitHub release + run: | + gh release create ${{ github.ref_name }} --generate-notes + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/patch.yml b/.github/workflows/patch.yml new file mode 100644 index 0000000..1f6e076 --- /dev/null +++ b/.github/workflows/patch.yml @@ -0,0 +1,84 @@ +name: Patch + +on: + workflow_dispatch: + inputs: + releaseVersion: + description: Patch version (vX.X) + required: true + +jobs: + patch: + runs-on: ubuntu-latest + steps: + - name: Set up JDK 17 + uses: actions/setup-java@v1 + with: + java-version: 17 + + - 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: + fetch-depth: 0 + token: ${{ steps.app-token.outputs.token }} + + - name: Checkout on existing release branch + run: | + git checkout release/${{ github.event.inputs.releaseVersion }} + + - name: Extract tag versions + run: | + lastTag=$(git describe --tags --abbrev=0) + regex="v([0-9]+).([0-9]+).([0-9]+)" + if [[ $lastTag =~ $regex ]] + then + major=${BASH_REMATCH[1]} + minor=${BASH_REMATCH[2]} + patch=${BASH_REMATCH[3]} + ((++patch)) + echo "GITHUB_MAJOR_VERSION=$major" >> $GITHUB_ENV + echo "GITHUB_MINOR_VERSION=$minor" >> $GITHUB_ENV + echo "GITHUB_PATCH_VERSION=$patch" >> $GITHUB_ENV + echo "GITHUB_SHORT_VERSION=$major.$minor.$patch" >> $GITHUB_ENV + fi + + - name: Change Maven version to release version + run: mvn --batch-mode versions:set -DgenerateBackupPoms=false -DnewVersion=${{ env.GITHUB_SHORT_VERSION }} + + - name: Commit and tag release version + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" + git add . + git commit -m "Patched release v${{ env.GITHUB_SHORT_VERSION }}" + git tag v${{ env.GITHUB_SHORT_VERSION }} + git push origin release/v${{ env.GITHUB_MAJOR_VERSION }}.${{ env.GITHUB_MINOR_VERSION }} + git push origin v${{ env.GITHUB_SHORT_VERSION }} + + - name: Build with Maven + run: mvn --batch-mode -Pjacoco verify + + - name: Run SonarCloud analysis + run: > + mvn --batch-mode -DskipTests sonar:sonar + -Dsonar.host.url=https://sonarcloud.io + -Dsonar.organization=gridsuite + -Dsonar.projectKey=gridsuite_spreadsheet-config-server + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + + - name: Build Docker image + run: > + mvn --batch-mode deploy -DskipTests -Dmaven.install.skip -Dmaven.deploy.skip -Dpowsybl.docker.deploy + -Djib.httpTimeout=60000 + -Djib.to.image=docker.io/gridsuite/spreadsheet-config-server:${{ env.GITHUB_SHORT_VERSION }} + -Djib.to.auth.username=gridsuiteci + -Djib.to.auth.password=${{ secrets.DOCKERHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..d718c1b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,96 @@ +name: Release + +on: + workflow_dispatch: + inputs: + releaseVersion: + description: Release version (vX.X) + required: true + commitSha: + description: SHA of the commit from where to release + required: true + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Set up JDK 17 + uses: actions/setup-java@v1 + with: + java-version: 17 + + - 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: + fetch-depth: 0 + token: ${{ steps.app-token.outputs.token }} + + - name: Extract tag versions + run: | + regex="v([0-9]+).([0-9]+)" + if [[ ${{ github.event.inputs.releaseVersion }} =~ $regex ]] + then + echo "GITHUB_MAJOR_VERSION=${BASH_REMATCH[1]}" >> $GITHUB_ENV + echo "GITHUB_MINOR_VERSION=${BASH_REMATCH[2]}" >> $GITHUB_ENV + echo "GITHUB_SHORT_VERSION=${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.0" >> $GITHUB_ENV + fi + + - name: Checkout with new branch + run: | + git checkout -b release/v${{ env.GITHUB_MAJOR_VERSION }}.${{ env.GITHUB_MINOR_VERSION }} ${{ github.event.inputs.commitSha }} + + - name: Change Maven version to release version + run: mvn --batch-mode versions:set -DgenerateBackupPoms=false -DnewVersion=${{ env.GITHUB_SHORT_VERSION }} + + - name: Commit and tag release version + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" + git add . + git commit -m "Release v${{ env.GITHUB_SHORT_VERSION }}" + git tag v${{ env.GITHUB_SHORT_VERSION }} + git push origin release/v${{ env.GITHUB_MAJOR_VERSION }}.${{ env.GITHUB_MINOR_VERSION }} + git push origin v${{ env.GITHUB_SHORT_VERSION }} + + - name: Build with Maven + run: mvn --batch-mode -Pjacoco verify + + - name: Run SonarCloud analysis + run: > + mvn --batch-mode -DskipTests sonar:sonar + -Dsonar.host.url=https://sonarcloud.io + -Dsonar.organization=gridsuite + -Dsonar.projectKey=gridsuite_spreadsheet-config-server + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + + - name: Build Docker image + run: > + mvn --batch-mode deploy -DskipTests -Dmaven.install.skip -Dmaven.deploy.skip -Dpowsybl.docker.deploy + -Djib.httpTimeout=60000 + -Djib.to.image=docker.io/gridsuite/spreadsheet-config-server:${{ env.GITHUB_SHORT_VERSION }} + -Djib.to.auth.username=gridsuiteci + -Djib.to.auth.password=${{ secrets.DOCKERHUB_TOKEN }} + + - name: Increment minor version + run: | + minor=${{ env.GITHUB_MINOR_VERSION }} + ((minor++)) + echo "GITHUB_MINOR_VERSION=${minor}" >> $GITHUB_ENV + + - name: Update SNAPSHOT version on main + run: | + git checkout main + git pull + mvn --batch-mode versions:set -DgenerateBackupPoms=false -DnewVersion=${{ env.GITHUB_MAJOR_VERSION }}.${{ env.GITHUB_MINOR_VERSION }}.0-SNAPSHOT + git add . + git commit -m "Update SNAPSHOT version to v${{ env.GITHUB_MAJOR_VERSION }}.${{ env.GITHUB_MINOR_VERSION }}.0" + git push From 104ba2a9a7815a8c794aa5f848d1a1c9b1fdfc9c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 15 Oct 2024 08:42:38 +0000 Subject: [PATCH 2/6] Update SNAPSHOT version to v2.8.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 44f94d5..2864cb9 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ org.gridsuite gridsuite-spreadsheet-config-server - 1.0.0-SNAPSHOT + 2.8.0-SNAPSHOT jar Spreadsheet config server From 3ec3421c9aff81f9565f9919d640a2a947d5c54c Mon Sep 17 00:00:00 2001 From: Joris Mancini Date: Tue, 15 Oct 2024 17:00:08 +0200 Subject: [PATCH 3/6] chore: merge gh-release action in release workflows and commit/tag after build Signed-off-by: Joris Mancini --- .github/workflows/gh-release.yml | 21 --------------------- .github/workflows/patch.yml | 26 ++++++++++++++++---------- .github/workflows/release.yml | 26 ++++++++++++++++---------- 3 files changed, 32 insertions(+), 41 deletions(-) delete mode 100644 .github/workflows/gh-release.yml diff --git a/.github/workflows/gh-release.yml b/.github/workflows/gh-release.yml deleted file mode 100644 index 17f673a..0000000 --- a/.github/workflows/gh-release.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: GH-Release - -on: - push: - tags: - - 'v[0-9]+.[0-9]+.[0-9]+' - -jobs: - gh-release: - runs-on: ubuntu-latest - steps: - - name: Checkout sources - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Create GitHub release - run: | - gh release create ${{ github.ref_name }} --generate-notes - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/patch.yml b/.github/workflows/patch.yml index 1f6e076..5e65bc0 100644 --- a/.github/workflows/patch.yml +++ b/.github/workflows/patch.yml @@ -52,16 +52,6 @@ jobs: - name: Change Maven version to release version run: mvn --batch-mode versions:set -DgenerateBackupPoms=false -DnewVersion=${{ env.GITHUB_SHORT_VERSION }} - - name: Commit and tag release version - run: | - git config --global user.name "github-actions[bot]" - git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" - git add . - git commit -m "Patched release v${{ env.GITHUB_SHORT_VERSION }}" - git tag v${{ env.GITHUB_SHORT_VERSION }} - git push origin release/v${{ env.GITHUB_MAJOR_VERSION }}.${{ env.GITHUB_MINOR_VERSION }} - git push origin v${{ env.GITHUB_SHORT_VERSION }} - - name: Build with Maven run: mvn --batch-mode -Pjacoco verify @@ -82,3 +72,19 @@ jobs: -Djib.to.image=docker.io/gridsuite/spreadsheet-config-server:${{ env.GITHUB_SHORT_VERSION }} -Djib.to.auth.username=gridsuiteci -Djib.to.auth.password=${{ secrets.DOCKERHUB_TOKEN }} + + - name: Commit and tag release version + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" + git add . + git commit -m "Patched release v${{ env.GITHUB_SHORT_VERSION }}" + git tag v${{ env.GITHUB_SHORT_VERSION }} + git push origin release/v${{ env.GITHUB_MAJOR_VERSION }}.${{ env.GITHUB_MINOR_VERSION }} + git push origin v${{ env.GITHUB_SHORT_VERSION }} + + - name: Create GitHub release + run: | + gh release create v${{ env.GITHUB_SHORT_VERSION }} --generate-notes + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d718c1b..ff3e73d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -49,16 +49,6 @@ jobs: - name: Change Maven version to release version run: mvn --batch-mode versions:set -DgenerateBackupPoms=false -DnewVersion=${{ env.GITHUB_SHORT_VERSION }} - - name: Commit and tag release version - run: | - git config --global user.name "github-actions[bot]" - git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" - git add . - git commit -m "Release v${{ env.GITHUB_SHORT_VERSION }}" - git tag v${{ env.GITHUB_SHORT_VERSION }} - git push origin release/v${{ env.GITHUB_MAJOR_VERSION }}.${{ env.GITHUB_MINOR_VERSION }} - git push origin v${{ env.GITHUB_SHORT_VERSION }} - - name: Build with Maven run: mvn --batch-mode -Pjacoco verify @@ -80,6 +70,22 @@ jobs: -Djib.to.auth.username=gridsuiteci -Djib.to.auth.password=${{ secrets.DOCKERHUB_TOKEN }} + - name: Commit and tag release version + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" + git add . + git commit -m "Release v${{ env.GITHUB_SHORT_VERSION }}" + git tag v${{ env.GITHUB_SHORT_VERSION }} + git push origin release/v${{ env.GITHUB_MAJOR_VERSION }}.${{ env.GITHUB_MINOR_VERSION }} + git push origin v${{ env.GITHUB_SHORT_VERSION }} + + - name: Create GitHub release + run: | + gh release create v${{ env.GITHUB_SHORT_VERSION }} --generate-notes + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Increment minor version run: | minor=${{ env.GITHUB_MINOR_VERSION }} From 98a9163c6e3f6145e6d651a01d533896bf28a378 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 15 Oct 2024 15:11:28 +0000 Subject: [PATCH 4/6] Update SNAPSHOT version to v2.9.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2864cb9..a5c80af 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ org.gridsuite gridsuite-spreadsheet-config-server - 2.8.0-SNAPSHOT + 2.9.0-SNAPSHOT jar Spreadsheet config server From 042ab4db04fe321f7681d855d656e440475843c7 Mon Sep 17 00:00:00 2001 From: Joris Mancini Date: Tue, 15 Oct 2024 17:18:04 +0200 Subject: [PATCH 5/6] test Signed-off-by: Joris Mancini --- .../spreadsheetconfig/server/RestTemplateConfig.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/gridsuite/spreadsheetconfig/server/RestTemplateConfig.java b/src/main/java/org/gridsuite/spreadsheetconfig/server/RestTemplateConfig.java index 054ee4a..25c46df 100644 --- a/src/main/java/org/gridsuite/spreadsheetconfig/server/RestTemplateConfig.java +++ b/src/main/java/org/gridsuite/spreadsheetconfig/server/RestTemplateConfig.java @@ -18,8 +18,8 @@ public class RestTemplateConfig { @Bean - public RestTemplate restTemplate(RestTemplateBuilder builder) { - return builder.build(); + public RestTemplate restTemplate(RestTemplateBuilder test) { + return test.build(); } } From 750e47c38f3d73c3e7abaf572f65416ebfb7fba4 Mon Sep 17 00:00:00 2001 From: Joris Mancini Date: Wed, 16 Oct 2024 11:13:05 +0200 Subject: [PATCH 6/6] chore: delete automatic github release Signed-off-by: Joris Mancini --- .github/workflows/patch.yml | 6 ------ .github/workflows/release.yml | 6 ------ 2 files changed, 12 deletions(-) diff --git a/.github/workflows/patch.yml b/.github/workflows/patch.yml index 5e65bc0..7e857a0 100644 --- a/.github/workflows/patch.yml +++ b/.github/workflows/patch.yml @@ -82,9 +82,3 @@ jobs: git tag v${{ env.GITHUB_SHORT_VERSION }} git push origin release/v${{ env.GITHUB_MAJOR_VERSION }}.${{ env.GITHUB_MINOR_VERSION }} git push origin v${{ env.GITHUB_SHORT_VERSION }} - - - name: Create GitHub release - run: | - gh release create v${{ env.GITHUB_SHORT_VERSION }} --generate-notes - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ff3e73d..2313245 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -80,12 +80,6 @@ jobs: git push origin release/v${{ env.GITHUB_MAJOR_VERSION }}.${{ env.GITHUB_MINOR_VERSION }} git push origin v${{ env.GITHUB_SHORT_VERSION }} - - name: Create GitHub release - run: | - gh release create v${{ env.GITHUB_SHORT_VERSION }} --generate-notes - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Increment minor version run: | minor=${{ env.GITHUB_MINOR_VERSION }}