Skip to content

Commit

Permalink
Automate revision update and changelog release
Browse files Browse the repository at this point in the history
  • Loading branch information
vy committed Sep 6, 2023
1 parent 6913eb2 commit a418848
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 21 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
42 changes: 37 additions & 5 deletions .github/workflows/deploy-release-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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`)
Expand Down
37 changes: 21 additions & 16 deletions RELEASING.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
Expand Down Expand Up @@ -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.
====

0 comments on commit a418848

Please sign in to comment.