diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 27f65e87..c3d2b05a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -55,6 +55,9 @@ jobs: if: github.repository == 'apache/logging-parent' && startsWith(github.ref, 'refs/heads/release/') uses: apache/logging-parent/.github/workflows/deploy-release-reusable.yml@main secrets: inherit + # Write permissions to allow the Maven `revision` property update, changelog release, etc. + permissions: + contents: write with: project-name: logging-parent distribution-attachment-count: 0 diff --git a/.github/workflows/deploy-release-reusable.yml b/.github/workflows/deploy-release-reusable.yml index 496ac907..cb4b0805 100644 --- a/.github/workflows/deploy-release-reusable.yml +++ b/.github/workflows/deploy-release-reusable.yml @@ -78,12 +78,45 @@ jobs: - name: Export version run: | - export PROJECT_VERSION=$(./mvnw \ - --quiet --batch-mode -DforceStdout=true \ - -Dexpression=project.version \ + [[ "$GIT_REF" =~ ^refs/heads/release/.+$ ]] || { + echo "was expecting a \`refs/heads/release/\`-prefixed Git reference, found: \`$GIT_REF\`" + exit 1 + } + export PROJECT_VERSION=$(echo "$GIT_REF | sed 's/^refs\/heads\/release\///') + echo "PROJECT_VERSION=$PROJECT_VERSION" >> $GITHUB_ENV + env: + GIT_REF: ${{ github.ref }} + + - name: Set the Maven `revision` property + run: | + set -x + export REVISION=$(./mvnw \ + --non-recursive --quiet --batch-mode + -DforceStdout=true \ + -Dexpression=revision \ help:evaluate \ | tail -n 1) - echo "PROJECT_VERSION=$PROJECT_VERSION" >> $GITHUB_ENV + if [ "$REVISION" != "$PROJECT_VERSION" ]; then + echo "Maven \`revision\` property \`$REVISION\` doesn't match with the project version \`$PROJECT_VERSION\`, updating \`pom.xml\`..." + ./mvnw \ + --non-recursive --batch-mode --errors --no-transfer-progress \ + -Dproperty=revision \ + -DnewVersion="$PROJECT_VERSION" \ + -DgenerateBackupPoms=false \ + versions:set-property + git commit pom.xml -m "Set version to \`$PROJECT_VERSION\`" + fi + + - name: Release changelog + run: | + set -x + ./mvnw \ + --non-recursive --batch-mode --errors --no-transfer-progress \ + -P changelog-release + git add src/changelog + if [ -n "$(git status --porcelain)" ]; then + git commit src/changelog -m "Release changelog for version \`$PROJECT_VERSION\`" + fi - name: Upload to Nexus run: | @@ -99,7 +132,6 @@ jobs: SIGN_KEY: ${{ secrets.GPG_SECRET_KEY }} - name: Create the distribution - if: startsWith(github.ref, 'refs/heads/release/') run: | # Generate the distribution (i.e., `src.zip` and optional `bin.zip`) diff --git a/RELEASING.adoc b/RELEASING.adoc index c29ea8ee..bc2e05be 100644 --- a/RELEASING.adoc +++ b/RELEASING.adoc @@ -43,20 +43,29 @@ In the code examples below, assuming the version to be released is `7.8.0`. == Stage the release -. Checkout the release branch: `git checkout -B release/7.8.0 origin/main` -. Perform and commit following changes: -.. Set the `revision` property to `7.8.0` in xref:pom.xml[`pom.xml`] -.. For release notes -... Run `./mvnw -N -P changelog-release` and verify `src/changelog` content (e.g., `.release-notes.md.ftl`) -... Run `./mvnw -N -P changelog-export` and verify `target/release-notes` content -. Make sure that `./mvnw clean verify` succeeds – if not, implement necessary fixes -. Commit and push the `release/7.8.0` branch -. Make sure the associated https://github.com/apache/{repository-name}/actions[GitHub Actions workflow] succeeds: +. Create and push the release branch: ++ +[source,bash] +---- +git fetch -p +git checkout -B release/7.8.0 origin/main +git push origin release/7.8.0 +---- +. Verify that the associated https://github.com/apache/{repository-name}/actions[GitHub Actions workflow] succeeds: +.. `revision` property in `pom.xml` is updated +.. Changelog is released (i.e., `src/changelog/7.8.0` folder is populated) .. *Signed artifacts* are uploaded to the _Staging Repositories_ in https://repository.apache.org/[repository.apache.org] -.. *Signed distribution and its checksum* (e.g., `apache-{project-name}-7.8.0.{zip,.zip.asc,.zip.sha512}`) are uploaded to https://dist.apache.org/repos/dist/dev/logging/log4j[dist.apache.org/repos/dist/**dev**/logging/log4j] Subversion repository (along with auxiliary files; email texts, etc.) +.. *Signed distribution and its checksum* (e.g., `apache-{project-name}-7.8.0-{bin,src}.{zip,.zip.asc,.zip.sha512}`) are uploaded to https://dist.apache.org/repos/dist/dev/logging/log4j[dist.apache.org/repos/dist/**dev**/logging/log4j] Subversion repository (along with auxiliary files; email texts, etc.) + If not, commit necessary fixes, push, and repeat. + ++ +[TIP] +==== +GitHub Actions workflow is idempotent. +You can iterate on the `release/7.8.0` branch to perfect it. +==== . _Close_ the repository in https://repository.apache.org/[repository.apache.org] == Vote the release @@ -65,7 +74,8 @@ If not, commit necessary fixes, push, and repeat. + [WARNING] ==== -Double-check the cited https://repository.apache.org[repository.apache.org] URL in the generated email, it might have changed! +**Fix the cited https://repository.apache.org[repository.apache.org] URL** in the generated email! +It changes after every Nexus deployment. ==== + [WARNING] @@ -128,11 +138,6 @@ Once the artifacts are visible in https://central.sonatype.dev/[central.sonatype + [WARNING] ==== -Double-check the cited https://repository.apache.org[repository.apache.org] URL in the generated email, it might have changed! -==== -+ -[WARNING] -==== Make sure your email is sent in plain text, that is, https://infra.apache.org/contrib-email-tips#nohtml[no HTML]! If you are using GMail, simply enable the _"Plain text mode"_ while composing your message. ====