Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: associate a commit with beta release #5530

Merged
45 changes: 34 additions & 11 deletions chore/release-beta.sh
Original file line number Diff line number Diff line change
@@ -1,35 +1,58 @@
#!/usr/bin/env bash
set -euo pipefail

CURRENT_VERSION="$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout | sed 's/-SNAPSHOT//')"
CURRENT_VERSION_WITH_SNAPSHOT="$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)"
# Version used to create the beta release
OLD_VERSION="$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout | sed 's/-SNAPSHOT//')"
# Version that will be reset back to after the beta release
OLD_VERSION_WITH_SNAPSHOT="$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)"

if [[ ! $CURRENT_VERSION_WITH_SNAPSHOT =~ .*-SNAPSHOT ]]; then
if [[ ! $OLD_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-beta-(.*)\") | .captures[0].string) // \"0\") | .[0]")"
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(\"$OLD_VERSION-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-beta-$NEW_BETA_NUMBER"
NEXT_BETA_VERSION="$OLD_VERSION-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
BRANCH_NAME="beta-release/$NEXT_BETA_VERSION"

echo "::group::Setting beta-release version"
mvn -f spoon-pom --no-transfer-progress --batch-mode versions:set -DnewVersion="$NEXT_BETA_VERSION" -DprocessAllModules
mvn --no-transfer-progress --batch-mode versions:set -DnewVersion="$NEXT_BETA_VERSION" -DprocessAllModules
mvn -f spoon-javadoc --no-transfer-progress --batch-mode versions:set -DnewVersion="$NEXT_BETA_VERSION" -DprocessAllModules
echo "::endgroup::"

echo "::group::Commit & Push changes"
git checkout -b "$BRANCH_NAME"
git commit -am "release: Releasing version $NEXT_BETA_VERSION"
git push --set-upstream origin "$BRANCH_NAME"
echo "::endgroup::"

echo "::group::Staging release"
echo "::group::Staging beta-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
JRELEASER_PROJECT_VERSION="$NEXT_BETA_VERSION" jreleaser-cli release
echo "::endgroup::"

echo "::group::Reverting to old SNAPSHOT version"
git revert --no-commit HEAD
git commit -m "release: Reverting to SNAPSHOT version $OLD_VERSION_WITH_SNAPSHOT"
git push origin "$BRANCH_NAME"
echo "::endgroup::"

echo "::group::Merging into master (fast-forward)"
git checkout master
git merge --ff-only "$BRANCH_NAME"
git push origin master
I-Al-Istannen marked this conversation as resolved.
Show resolved Hide resolved
git push origin --delete "$BRANCH_NAME"
echo "::endgroup::"