diff --git a/.github/workflows/beta-release.yml b/.github/workflows/beta-release.yml new file mode 100644 index 00000000000..146cdd2bf63 --- /dev/null +++ b/.github/workflows/beta-release.yml @@ -0,0 +1,47 @@ +name: Release beta version + +on: + schedule: + - cron: '0 0 * * 0' # Sundays at 00:00 (https://crontab.guru/#0_0_*_*_0) + +jobs: + snapshot: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3 + with: + fetch-depth: 0 + token: ${{ secrets.JRELEASER_GITHUB_TOKEN }} + - name: Install Nix + uses: DeterminateSystems/nix-installer-action@v4 + - uses: DeterminateSystems/magic-nix-cache-action@v2 + - name: Check Nixpkgs inputs + uses: DeterminateSystems/flake-checker-action@v5 + with: + fail-mode: true + - name: Use Maven dependency cache + uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 + with: + path: ~/.m2/repository + key: ${{ runner.os }} + + - name: Make beta release + run: nix develop .#jReleaser --command chore/release-beta.sh + env: + 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 }} + + # Log failures + - 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/.github/workflows/nightly-release.yml b/.github/workflows/nightly-release.yml new file mode 100644 index 00000000000..e3f5d3a473a --- /dev/null +++ b/.github/workflows/nightly-release.yml @@ -0,0 +1,47 @@ +name: Release nightly version + +on: + schedule: + - cron: '0 0 * * *' # Every day at 00:00 UTC (https://crontab.guru/#0_0_*_*_*) + +jobs: + nightly: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3 + with: + fetch-depth: 0 + token: ${{ secrets.JRELEASER_GITHUB_TOKEN }} + - name: Install Nix + uses: DeterminateSystems/nix-installer-action@v4 + - uses: DeterminateSystems/magic-nix-cache-action@v2 + - name: Check Nixpkgs inputs + uses: DeterminateSystems/flake-checker-action@v5 + with: + fail-mode: true + - name: Use Maven dependency cache + uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 + with: + path: ~/.m2/repository + key: ${{ runner.os }} + + - name: Make beta release + run: nix develop .#jReleaser --command chore/release-nightly.sh + env: + 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 }} + + # Log failures + - 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/chore/release-beta.sh b/chore/release-beta.sh new file mode 100644 index 00000000000..a73d13e6109 --- /dev/null +++ b/chore/release-beta.sh @@ -0,0 +1,31 @@ +CURRENT_VERSION_WITH_SNAPSHOT="$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" + +if [[ ! $CURRENT_VERSION_WITH_SNAPSHOT =~ .*-SNAPSHOT ]]; then + echo "Not a snapshot version, skipping" + exit 78 +fi + +# Compute next beta number +echo "::group::Computing next beta number" +LAST_BETA_NUMBER="$(curl -L "http://search.maven.org/solrsearch/select?q=a:spoon-core+g:fr.inria.gforge.spoon&rows=40&wt=json&core=gav" | jq -r ".response.docs | map(.v) | map((match(\"$CURRENT_VERSION_NO_SNAPSHOT-beta-(.*)\") | .captures[0].string) // \"0\") | .[0]")" +echo "LAST_BETA_NUMBER $LAST_BETA_NUMBER" + +NEW_BETA_NUMBER=$((LAST_BETA_NUMBER + 1)) +echo "NEW_BETA_NUMBER $NEW_BETA_NUMBER" +NEXT_VERSION="$CURRENT_VERSION_NO_SNAPSHOT-beta-$NEW_BETA_NUMBER" +echo "::endgroup::" + +echo "::group::Setting release version" +mvn -f spoon-pom --no-transfer-progress --batch-mode versions:set -DnewVersion="$NEXT_VERSION" -DprocessAllModules +mvn --no-transfer-progress --batch-mode versions:set -DnewVersion="$NEXT_VERSION" -DprocessAllModules +mvn -f spoon-javadoc --no-transfer-progress --batch-mode versions:set -DnewVersion="$NEXT_VERSION" -DprocessAllModules +echo "::endgroup::" + +echo "::group::Staging release" +mvn -f spoon-pom --no-transfer-progress --batch-mode -Pjreleaser clean deploy -DaltDeploymentRepository=local::default::file:./target/staging-deploy +mvn --no-transfer-progress --batch-mode -Pjreleaser deploy:deploy-file -Dfile="./spoon-pom/pom.xml" -DpomFile="./spoon-pom/pom.xml" -Durl="file://$(mvn help:evaluate -D"expression=project.basedir" -q -DforceStdout)/target/staging-deploy" +echo "::endgroup::" + +echo "::group::Running jreleaser" +JRELEASER_PROJECT_VERSION="$NEXT_VERSION" jreleaser-cli deploy +echo "::endgroup::" diff --git a/chore/release-nightly.sh b/chore/release-nightly.sh new file mode 100644 index 00000000000..d4e5598ff93 --- /dev/null +++ b/chore/release-nightly.sh @@ -0,0 +1,15 @@ +CURRENT_VERSION_WITH_SNAPSHOT="$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" + +if [[ ! $CURRENT_VERSION_WITH_SNAPSHOT =~ .*-SNAPSHOT ]]; then + echo "Not a snapshot version, skipping" + exit 78 +fi + +echo "::group::Staging release" +mvn -f spoon-pom --no-transfer-progress --batch-mode -Pjreleaser clean deploy -DaltDeploymentRepository=local::default::file:./target/staging-deploy +mvn --no-transfer-progress --batch-mode -Pjreleaser deploy:deploy-file -Dfile="./spoon-pom/pom.xml" -DpomFile="./spoon-pom/pom.xml" -Durl="file://$(mvn help:evaluate -D"expression=project.basedir" -q -DforceStdout)/target/staging-deploy" +echo "::endgroup::" + +echo "::group::Running jreleaser" +JRELEASER_PROJECT_VERSION="$NEXT_VERSION" jreleaser-cli deploy +echo "::endgroup::"