diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9e36b343..772c3986 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,8 +3,12 @@ name: Prepare release on: workflow_dispatch: inputs: + releaseVersion: + description: "Version to release, such as 1.2.3. Leave empty to release the pom's version without -SNAPSHOT." + required: false + default: "" developmentVersion: - description: "Default version to use for new local working copy." + description: "Next development version, set on main after the release, such as 1.2.4-SNAPSHOT." required: true default: "X.Y.Z-SNAPSHOT" dryRun: @@ -51,16 +55,21 @@ jobs: git config --global user.name "${{ github.actor }}" git config --global user.email "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com" - # The version is the one release:prepare will tag: the pom's version without - # -SNAPSHOT. git-cliff is told it rather than bumping from the commit types, so - # that the changelog, the Maven tag and the GitHub release always agree. + # The version is the one release:prepare will tag: the releaseVersion input, + # or else the pom's version without -SNAPSHOT. git-cliff is told it rather than + # bumping from the commit types, so that the changelog, the Maven tag and the + # GitHub release always agree. - name: Determine and check the versions id: release-version env: + RELEASE_VERSION: ${{ inputs.releaseVersion }} DEVELOPMENT_VERSION: ${{ inputs.developmentVersion }} run: | - version=$(sed -n '0,//s|.*\([^<]*\).*|\1|p' pom.xml) - version="${version%-SNAPSHOT}" + version="$RELEASE_VERSION" + if [ -z "$version" ]; then + version=$(sed -n '0,//s|.*\([^<]*\).*|\1|p' pom.xml) + version="${version%-SNAPSHOT}" + fi if ! [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then echo "::error::The release version must look like 1.2.3" exit 1 @@ -125,6 +134,7 @@ jobs: mvn -B release:prepare -DpushChanges=false \ -DpreparationGoals="clean validate" \ -DdryRun=${{ inputs.dryRun }} \ + -DreleaseVersion="$EXPECTED_VERSION" \ -DdevelopmentVersion="$DEVELOPMENT_VERSION" # Get the release version from the release.properties file diff --git a/docs/guide/build.md b/docs/guide/build.md index e8a71450..67cd5d98 100644 --- a/docs/guide/build.md +++ b/docs/guide/build.md @@ -117,9 +117,10 @@ caches, so a native rebuild also includes the updated patches. ## Release workflow Maintainers start **Prepare release** (`release.yml`) from `main`, providing the -next development version, such as `0.16.0-SNAPSHOT`. Preparation commits the -changelog and version changes and atomically pushes `main` and the release tag. -It then dispatches **Publish release** (`release-publish.yml`) on that tag using +next development version, such as `0.16.0-SNAPSHOT`, and optionally the version +to release, such as `0.15.0`. Without one, the release takes the root pom's +version without `-SNAPSHOT`. Preparation commits the changelog and version +changes and atomically pushes `main` and the release tag. It then dispatches **Publish release** (`release-publish.yml`) on that tag using `GITHUB_TOKEN` with `actions: write`; no additional token is needed. A push made with `GITHUB_TOKEN` does not trigger a tag push workflow on its own.