From 1ef0d1ebe9520cc2e641d1977bd176dcf0f887e3 Mon Sep 17 00:00:00 2001 From: Martin Wittlinger Date: Sat, 13 May 2023 11:03:01 +0200 Subject: [PATCH 01/11] =?UTF-8?q?=F0=9F=8E=89=20Add=20release=20workflow?= =?UTF-8?q?=20and=20config?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created `.github/workflows/jreleaser.yml` to trigger the next release version. The workflow dispatches on user input for `major`, `minor`, and `patch` versions by setting up the environment using JDK 11, Go, and `semver`. Configuration files such as `.gitignore` and `jreleaser.yml` were also updated to ignore specific files and to set the `MIT` license. --- .github/workflows/jreleaser.yml | 102 ++++++++++++++++++++++++++++++++ .gitignore | 2 + jreleaser.yml | 41 +++++++++++++ 3 files changed, 145 insertions(+) create mode 100644 .github/workflows/jreleaser.yml create mode 100644 jreleaser.yml diff --git a/.github/workflows/jreleaser.yml b/.github/workflows/jreleaser.yml new file mode 100644 index 00000000000..8ac4c469e8a --- /dev/null +++ b/.github/workflows/jreleaser.yml @@ -0,0 +1,102 @@ +name: Release + +on: + workflow_dispatch: + inputs: + version: + description: 'Next release version' + required: true + default: 'patch' + type: choice + options: + - major + - minor + - patch + +jobs: + + build: + runs-on: ubuntu-latest + steps: +# Setups the environment + - name: Checkout + uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3 + with: + fetch-depth: 0 + - name: Set up JDK 11 + uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 # v3 + with: + java-version: '11' + distribution: 'temurin' + cache: maven + + - name: install go + uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4 + - name: install semversion + run: go install github.com/ffurrer2/semver/cmd/semver@latest +# Get current version from pom and remove snapshot if present. + - name: Get current version from pom and remove snapshot if present. + run: echo "CURRENT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout | sed 's/-SNAPSHOT//')" >> $GITHUB_ENV + - name: Get version with snapshot + run: echo "CURRENT_VERSION_WITH_SNAPSHOT=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV +# Calculate next version: +# - if version is patch, we just increment the patch version +# - if version is minor or major, we increment the minor or major version and set the patch version to 0 +# As we are using a snapshot version, we need to run semver next twice to get the next version for mahor and minor releases. Reason: Any X.Y.Z-SNAPSHOT version will be released as X.Y.Z if we run semver next major X.Y.Z-SNAPSHOT + - name: Set next version + if: ${{ github.event.inputs.version == 'patch' }} + run: echo "NEXT_VERSION=$(semver next ${{ github.event.inputs.version }} $CURRENT_VERSION_WITH_SNAPSHOT)" >> $GITHUB_ENV + - name: Set next version + # semver next for a snapshot only releases the snapshot version, so we need to run it 2 times + if: ${{ github.event.inputs.version == 'major' || github.event.inputs.version == 'minor' }} + run: echo "NEXT_VERSION=$(semver next ${{ github.event.inputs.version }} $CURRENT_VERSION)" >> $GITHUB_ENV + - name: Set release version + run: mvn --no-transfer-progress --batch-mode versions:set -DnewVersion=$NEXT_VERSION -DprocessAllModules + - name: Commit & Push changes + uses: actions-js/push@master + with: + github_token: ${{ secrets.JRELEASER_GITHUB_TOKEN }} + message: 🔖 Releasing version ${{ env.NEXT_VERSION }} + +# Now we can run the release + - name: Stage release + run: mvn --no-transfer-progress --batch-mode -Ppublication clean deploy -DaltDeploymentRepository=local::default::file://`pwd`/target/staging-deploy + - name: Print next version + run: mvn help:evaluate -Dexpression=project.version -q -DforceStdout | sed 's/-SNAPSHOT//' + - name: Run JReleaser + uses: jreleaser/release-action@v2 + with: + setup-java: false + version: 1.4.0 + arguments: full-release + env: + JRELEASER_PROJECT_VERSION: ${{ env.NEXT_VERSION }} + JRELEASER_GITHUB_TOKEN: ${{ secrets.JRELEASER_GITHUB_TOKEN }} + JRELEASER_GPG_PASSPHRASE: ${{ secrets.JRELEASER_GPG_PASSPHRASE }} + JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.JRELEASER_GPG_PUBLIC_KEY }} + JRELEASER_GPG_SECRET_KEY: ${{ secrets.JRELEASER_GPG_SECRET_KEY }} + JRELEASER_NEXUS2_MAVEN_CENTRAL_USERNAME: ${{ secrets.JRELEASER_NEXUS2_MAVEN_CENTRAL_USERNAME }} + JRELEASER_NEXUS2_MAVEN_CENTRAL_PASSWORD: ${{ secrets.JRELEASER_NEXUS2_MAVEN_CENTRAL_PASSWORD }} +# Time to set the next version: The next version of any Release is a snapshot version of the next patch version + - name : Set next version (patch of release version) with -SNAPSHOT suffix + run: | + echo "NEXT_RELEASE_VERSION=$(semver next patch $NEXT_VERSION)-SNAPSHOT" >> $GITHUB_ENV + echo "NEXT_RELEASE_VERSION_WITHOUT_SNAPSHOT=$(semver next patch $NEXT_VERSION)" >> $GITHUB_ENV + - name: Set release version + run: mvn --no-transfer-progress --batch-mode versions:set -DnewVersion=$NEXT_RELEASE_VERSION -DprocessAllModules +# Commit and push changes + - name: Commit & Push changes + uses: actions-js/push@master + with: + github_token: ${{ secrets.JRELEASER_GITHUB_TOKEN }} + message: 🔖 Setting SNAPSHOT version ${{ env.NEXT_VERSION }} + +# Log failure: + - name: JReleaser release output + if: always() + uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3 + with: + name: jreleaser-release + path: | + out/jreleaser/trace.log + out/jreleaser/output.properties diff --git a/.gitignore b/.gitignore index 8d151e03f7b..af1d8e9e359 100644 --- a/.gitignore +++ b/.gitignore @@ -57,3 +57,5 @@ gradle-app.setting ## Gradle Enterprise ID File ## .mvn/.gradle-enterprise/gradle-enterprise-workspace-id +# Jreleaser files +out/ \ No newline at end of file diff --git a/jreleaser.yml b/jreleaser.yml new file mode 100644 index 00000000000..915f419e6e9 --- /dev/null +++ b/jreleaser.yml @@ -0,0 +1,41 @@ +project: + name: spoon-core + description: A plugin to lock and validate the integrity of the dependencies of a maven based project. + longDescription: Spoon is an open-source library to analyze, rewrite, transform, transpile Java source code. + It parses source files to build a well-designed AST with powerful analysis and transformation API. + It supports modern Java versions up to Java 20. + authors: + - MartinWitt + license: (MIT OR CECILL-C) + links: + homepage: https://github.com/chains-project/maven-lockfile + java: + groupId: fr.inria.gforge.spoon + version: 11 + inceptionYear: 2015 + +release: + github: + owner: INRIA + changelog: + formatted: ALWAYS + format: '- {{commitShortHash}} {{commitTitle}}' + contributors: + format: '- {{contributorName}} ({{contributorUsernameAsLink}})' + hide: + contributors: + - '[bot]' + - 'GitHub' +signing: + active: ALWAYS + armored: true +deploy: + maven: + nexus2: + maven-central: + active: ALWAYS + url: https://s01.oss.sonatype.org/service/local + closeRepository: true + releaseRepository: true + stagingRepositories: + - target/staging-deploy \ No newline at end of file From 95aa480483e4c0ec05c9af602951cecf401fd745 Mon Sep 17 00:00:00 2001 From: Martin Date: Tue, 16 May 2023 13:09:42 +0200 Subject: [PATCH 02/11] add missing authors --- jreleaser.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/jreleaser.yml b/jreleaser.yml index 915f419e6e9..c557933e765 100644 --- a/jreleaser.yml +++ b/jreleaser.yml @@ -5,7 +5,12 @@ project: It parses source files to build a well-designed AST with powerful analysis and transformation API. It supports modern Java versions up to Java 20. authors: - - MartinWitt + - slarse + - monperrus + - nharrand + - martinwitt + - sirywell + - I-Al-Istannen license: (MIT OR CECILL-C) links: homepage: https://github.com/chains-project/maven-lockfile From bc701d95d658bf49fafbcc6b1c77d39916ce6b1f Mon Sep 17 00:00:00 2001 From: Martin Date: Tue, 16 May 2023 13:36:44 +0200 Subject: [PATCH 03/11] use correct profile. --- .github/workflows/jreleaser.yml | 2 +- spoon-pom/pom.xml | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/jreleaser.yml b/.github/workflows/jreleaser.yml index 8ac4c469e8a..f1c4f2e1e78 100644 --- a/.github/workflows/jreleaser.yml +++ b/.github/workflows/jreleaser.yml @@ -60,7 +60,7 @@ jobs: # Now we can run the release - name: Stage release - run: mvn --no-transfer-progress --batch-mode -Ppublication clean deploy -DaltDeploymentRepository=local::default::file://`pwd`/target/staging-deploy + run: mvn --no-transfer-progress --batch-mode -Prelease clean deploy -DaltDeploymentRepository=local::default::file://`pwd`/target/staging-deploy - name: Print next version run: mvn help:evaluate -Dexpression=project.version -q -DforceStdout | sed 's/-SNAPSHOT//' - name: Run JReleaser diff --git a/spoon-pom/pom.xml b/spoon-pom/pom.xml index d91f0054327..a2e42e7e5e9 100644 --- a/spoon-pom/pom.xml +++ b/spoon-pom/pom.xml @@ -419,6 +419,11 @@ + + org.apache.maven.plugins + maven-deploy-plugin + 3.1.1 + From 6c142596e109da7963a5482eb61b6c2a68c29362 Mon Sep 17 00:00:00 2001 From: Martin Date: Tue, 16 May 2023 13:44:23 +0200 Subject: [PATCH 04/11] update commit message and set correct branch --- .github/workflows/jreleaser.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/jreleaser.yml b/.github/workflows/jreleaser.yml index f1c4f2e1e78..6aa070b22d7 100644 --- a/.github/workflows/jreleaser.yml +++ b/.github/workflows/jreleaser.yml @@ -56,7 +56,8 @@ jobs: uses: actions-js/push@master with: github_token: ${{ secrets.JRELEASER_GITHUB_TOKEN }} - message: 🔖 Releasing version ${{ env.NEXT_VERSION }} + message: "release: Releasing version ${{ env.NEXT_VERSION }}" + branch: master # Now we can run the release - name: Stage release @@ -89,7 +90,8 @@ jobs: uses: actions-js/push@master with: github_token: ${{ secrets.JRELEASER_GITHUB_TOKEN }} - message: 🔖 Setting SNAPSHOT version ${{ env.NEXT_VERSION }} + message: "release: Setting SNAPSHOT version ${{ env.NEXT_VERSION }}" + branch: master # Log failure: - name: JReleaser release output From 6a9d4bdd1b27fa95071dab9b50e07b0a957b55fe Mon Sep 17 00:00:00 2001 From: Martin Date: Tue, 16 May 2023 14:05:54 +0200 Subject: [PATCH 05/11] add FF merge --- .github/workflows/jreleaser.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/jreleaser.yml b/.github/workflows/jreleaser.yml index 6aa070b22d7..d2f0cd83a39 100644 --- a/.github/workflows/jreleaser.yml +++ b/.github/workflows/jreleaser.yml @@ -50,6 +50,8 @@ jobs: # semver next for a snapshot only releases the snapshot version, so we need to run it 2 times if: ${{ github.event.inputs.version == 'major' || github.event.inputs.version == 'minor' }} run: echo "NEXT_VERSION=$(semver next ${{ github.event.inputs.version }} $CURRENT_VERSION)" >> $GITHUB_ENV + - name: set branchname to next version + run: echo "BRANCH_NAME=release/$NEXT_VERSION" >> $GITHUB_ENV - name: Set release version run: mvn --no-transfer-progress --batch-mode versions:set -DnewVersion=$NEXT_VERSION -DprocessAllModules - name: Commit & Push changes @@ -57,7 +59,7 @@ jobs: with: github_token: ${{ secrets.JRELEASER_GITHUB_TOKEN }} message: "release: Releasing version ${{ env.NEXT_VERSION }}" - branch: master + branch: ${{ env.BRANCH_NAME }} # Now we can run the release - name: Stage release @@ -91,7 +93,16 @@ jobs: with: github_token: ${{ secrets.JRELEASER_GITHUB_TOKEN }} message: "release: Setting SNAPSHOT version ${{ env.NEXT_VERSION }}" + branch: ${{ env.BRANCH_NAME }} + - name: Merge Fast Forward + uses: MaximeHeckel/github-action-merge-fast-forward@v1.1.0 + with: + # Branch to merge + branchtomerge: ${{ env.BRANCH_NAME }} + # Branch that will be updated branch: master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Log failure: - name: JReleaser release output From 1b81891769dc40cd0047110060382a1ff354eef1 Mon Sep 17 00:00:00 2001 From: Martin Wittlinger Date: Tue, 16 May 2023 21:06:12 +0200 Subject: [PATCH 06/11] Update .github/workflows/jreleaser.yml Co-authored-by: I-Al-Istannen --- .github/workflows/jreleaser.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/jreleaser.yml b/.github/workflows/jreleaser.yml index d2f0cd83a39..d58d482e985 100644 --- a/.github/workflows/jreleaser.yml +++ b/.github/workflows/jreleaser.yml @@ -42,7 +42,7 @@ jobs: # Calculate next version: # - if version is patch, we just increment the patch version # - if version is minor or major, we increment the minor or major version and set the patch version to 0 -# As we are using a snapshot version, we need to run semver next twice to get the next version for mahor and minor releases. Reason: Any X.Y.Z-SNAPSHOT version will be released as X.Y.Z if we run semver next major X.Y.Z-SNAPSHOT +# As we are using a snapshot version, we need to run semver next twice to get the next version for major and minor releases. Reason: Any X.Y.Z-SNAPSHOT version will be released as X.Y.Z if we run semver next major X.Y.Z-SNAPSHOT - name: Set next version if: ${{ github.event.inputs.version == 'patch' }} run: echo "NEXT_VERSION=$(semver next ${{ github.event.inputs.version }} $CURRENT_VERSION_WITH_SNAPSHOT)" >> $GITHUB_ENV From 683856279f8585b7ae273ac8e532149d96e7b7d6 Mon Sep 17 00:00:00 2001 From: Martin Wittlinger Date: Tue, 16 May 2023 21:07:39 +0200 Subject: [PATCH 07/11] newline --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index af1d8e9e359..4492b7993a8 100644 --- a/.gitignore +++ b/.gitignore @@ -58,4 +58,4 @@ gradle-app.setting ## Gradle Enterprise ID File ## .mvn/.gradle-enterprise/gradle-enterprise-workspace-id # Jreleaser files -out/ \ No newline at end of file +out/ From 50416e4b49ea37574908a433f942a8dc5edae7fa Mon Sep 17 00:00:00 2001 From: Martin Wittlinger Date: Tue, 16 May 2023 21:08:12 +0200 Subject: [PATCH 08/11] Update jreleaser.yml --- jreleaser.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jreleaser.yml b/jreleaser.yml index c557933e765..d6678d61d91 100644 --- a/jreleaser.yml +++ b/jreleaser.yml @@ -1,6 +1,6 @@ project: name: spoon-core - description: A plugin to lock and validate the integrity of the dependencies of a maven based project. + description: Spoon is an open-source library to analyze, rewrite, transform, transpile Java source code. longDescription: Spoon is an open-source library to analyze, rewrite, transform, transpile Java source code. It parses source files to build a well-designed AST with powerful analysis and transformation API. It supports modern Java versions up to Java 20. @@ -13,7 +13,7 @@ project: - I-Al-Istannen license: (MIT OR CECILL-C) links: - homepage: https://github.com/chains-project/maven-lockfile + homepage: https://github.com/INRIA/spoon java: groupId: fr.inria.gforge.spoon version: 11 @@ -43,4 +43,4 @@ deploy: closeRepository: true releaseRepository: true stagingRepositories: - - target/staging-deploy \ No newline at end of file + - target/staging-deploy From 7e030a96549c23489f4c8b44244bb87e0ca93d0f Mon Sep 17 00:00:00 2001 From: Martin Wittlinger Date: Tue, 16 May 2023 21:12:17 +0200 Subject: [PATCH 09/11] Update jreleaser.yml --- .github/workflows/jreleaser.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/jreleaser.yml b/.github/workflows/jreleaser.yml index d58d482e985..5dcf051faa7 100644 --- a/.github/workflows/jreleaser.yml +++ b/.github/workflows/jreleaser.yml @@ -47,7 +47,7 @@ jobs: if: ${{ github.event.inputs.version == 'patch' }} run: echo "NEXT_VERSION=$(semver next ${{ github.event.inputs.version }} $CURRENT_VERSION_WITH_SNAPSHOT)" >> $GITHUB_ENV - name: Set next version - # semver next for a snapshot only releases the snapshot version, so we need to run it 2 times + # semver next for a snapshot only releases the snapshot version, so we need to run without the snapshot suffix if: ${{ github.event.inputs.version == 'major' || github.event.inputs.version == 'minor' }} run: echo "NEXT_VERSION=$(semver next ${{ github.event.inputs.version }} $CURRENT_VERSION)" >> $GITHUB_ENV - name: set branchname to next version From 3f1c0a4f99a53dccae275b612ad0351f8c8ddd9f Mon Sep 17 00:00:00 2001 From: Martin Wittlinger Date: Tue, 16 May 2023 21:41:11 +0200 Subject: [PATCH 10/11] Update jreleaser.yml --- .github/workflows/jreleaser.yml | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/.github/workflows/jreleaser.yml b/.github/workflows/jreleaser.yml index 5dcf051faa7..8fbff53c6bb 100644 --- a/.github/workflows/jreleaser.yml +++ b/.github/workflows/jreleaser.yml @@ -39,15 +39,24 @@ jobs: run: echo "CURRENT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout | sed 's/-SNAPSHOT//')" >> $GITHUB_ENV - name: Get version with snapshot run: echo "CURRENT_VERSION_WITH_SNAPSHOT=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV -# Calculate next version: -# - if version is patch, we just increment the patch version -# - if version is minor or major, we increment the minor or major version and set the patch version to 0 -# As we are using a snapshot version, we need to run semver next twice to get the next version for major and minor releases. Reason: Any X.Y.Z-SNAPSHOT version will be released as X.Y.Z if we run semver next major X.Y.Z-SNAPSHOT - - name: Set next version +# Calculate release version: +# - if `version` is patch, we just increment drop the `-SNAPSHOT` suffix +# (e.g. 10.0.1-SNAPSHOT -> 10.0.1) +# - if `version` is minor or major, we increment the minor or major version and +# set the patch version to `0` (e.g. 10.0.1-SNAPSHOT -> 11.0.0 or 10.1.0) +# +# As we are using a snapshot version, the first call to `semver next` slices +# off only the `-SNAPSHOT` suffix. We therefore run `semver next` on the +# version *without* the `-SNAPSHOT` prefix for major and minor bumps. +# +# After release, we run `semver next` once again and append the `-SNAPSHOT` +# suffix. This results in our patch version from above becoming +# `10.0.2-SNAPSHOT`. The major/minor just get the patch set to `1` and +# `-SNAPSHOT` appended. + - name: Set next version for patch if: ${{ github.event.inputs.version == 'patch' }} run: echo "NEXT_VERSION=$(semver next ${{ github.event.inputs.version }} $CURRENT_VERSION_WITH_SNAPSHOT)" >> $GITHUB_ENV - - name: Set next version - # semver next for a snapshot only releases the snapshot version, so we need to run without the snapshot suffix + - name: Set next version for major/minor if: ${{ github.event.inputs.version == 'major' || github.event.inputs.version == 'minor' }} run: echo "NEXT_VERSION=$(semver next ${{ github.event.inputs.version }} $CURRENT_VERSION)" >> $GITHUB_ENV - name: set branchname to next version From 2b822003cc4d081700e1b7603c1173469744fd52 Mon Sep 17 00:00:00 2001 From: Martin Wittlinger Date: Tue, 16 May 2023 22:35:23 +0200 Subject: [PATCH 11/11] Update jreleaser.yml --- jreleaser.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jreleaser.yml b/jreleaser.yml index d6678d61d91..3dbe9a28f30 100644 --- a/jreleaser.yml +++ b/jreleaser.yml @@ -13,7 +13,7 @@ project: - I-Al-Istannen license: (MIT OR CECILL-C) links: - homepage: https://github.com/INRIA/spoon + homepage: https://spoon.gforge.inria.fr/ java: groupId: fr.inria.gforge.spoon version: 11