Skip to content

Commit cf830ff

Browse files
author
Fabiana Severin
committed
feat(release): add changelog entry, GitHub Releases, lastPublished, and RELEASING.md
1 parent f42fcc3 commit cf830ff

8 files changed

Lines changed: 105 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ on:
2727
description: 'Next development version override (optional, must end with -SNAPSHOT)'
2828
required: false
2929
type: string
30+
changelogEntry:
31+
description: 'Changelog entry (Markdown bullets, e.g. "- Fix X"). Prepended to the module RELEASE.CHANGELOG.md in the version-bump PR and used as the GitHub Release notes. Required.'
32+
required: true
33+
type: string
3034
skip_publish:
3135
description: 'Skip publish (dry-run validation)'
3236
required: false
@@ -48,6 +52,7 @@ env:
4852
MODULE: ${{ github.event.inputs.module }}
4953
RELEASE_VERSION_INPUT: ${{ github.event.inputs.releaseVersion }}
5054
DEVELOPMENT_VERSION_INPUT: ${{ github.event.inputs.developmentVersion }}
55+
CHANGELOG_ENTRY_INPUT: ${{ github.event.inputs.changelogEntry }}
5156
# Batch mode + no transfer-progress spam for every Maven call (Maven 3.9+).
5257
MAVEN_ARGS: "-B --no-transfer-progress"
5358
AWS_REGION: ${{ vars.AWS_REGION_MAVEN_RELEASE }}
@@ -252,6 +257,34 @@ jobs:
252257
-Darguments="-gs $MAVEN_SETTINGS -Prelease -Dgpg.keyname=$GPG_KEYNAME -Dgpg.passphrase=$GPG_PASSPHRASE" \
253258
--file "$MODULE/pom.xml"
254259
260+
# Bump the lastPublished comment under <version>; rides in the bump PR.
261+
- name: Record last published version in POM
262+
if: ${{ github.event.inputs.skip_publish != 'true' }}
263+
run: |
264+
if ! grep -q "<!-- lastPublished:" "$MODULE/pom.xml"; then
265+
echo "::notice::$MODULE has no lastPublished comment; skipping"
266+
exit 0
267+
fi
268+
sed -i "s|<!-- lastPublished:.*-->|<!-- lastPublished: ${EFFECTIVE_RELEASE_VERSION} (auto-updated by release.yml) -->|" "$MODULE/pom.xml"
269+
git commit -am "chore(release): record ${MODULE} lastPublished=${EFFECTIVE_RELEASE_VERSION}"
270+
271+
# Prepend the changelog entry so it ships in the version-bump PR. Passed
272+
# via env, never interpolated into the script, so it can't inject shell.
273+
- name: Prepend changelog entry
274+
if: ${{ github.event.inputs.skip_publish != 'true' }}
275+
run: |
276+
CHANGELOG="$MODULE/RELEASE.CHANGELOG.md"
277+
TMP="$(mktemp)"
278+
{
279+
echo "### $(date +'%B %d, %Y')"
280+
echo "\`${EFFECTIVE_RELEASE_VERSION}\`:"
281+
printf '%s\n\n' "$CHANGELOG_ENTRY_INPUT"
282+
[ -f "$CHANGELOG" ] && cat "$CHANGELOG"
283+
} > "$TMP"
284+
mv "$TMP" "$CHANGELOG"
285+
git add "$CHANGELOG"
286+
git commit -m "docs(release): add ${MODULE} ${EFFECTIVE_RELEASE_VERSION} changelog entry"
287+
255288
# main is protected (no direct push), so push the tag and open a PR for
256289
# the version-bump commits instead. Skipping this would leave the POM on
257290
# the just-released -SNAPSHOT.
@@ -273,6 +306,22 @@ jobs:
273306
--title "chore(release): ${MODULE} ${EFFECTIVE_RELEASE_VERSION}" \
274307
--body "Post-release version bump for ${MODULE} ${EFFECTIVE_RELEASE_VERSION} (already on Maven Central, tag ${TAG} pushed)."
275308
309+
# GitHub Release on the pushed tag: changelog entry + Central link.
310+
- name: Create GitHub Release
311+
if: ${{ github.event.inputs.skip_publish != 'true' }}
312+
env:
313+
GH_TOKEN: ${{ github.token }}
314+
run: |
315+
TAG="${MODULE}-${EFFECTIVE_RELEASE_VERSION}"
316+
NOTES="$(mktemp)"
317+
{
318+
printf '%s\n\n' "$CHANGELOG_ENTRY_INPUT"
319+
echo "Published to Maven Central: https://central.sonatype.com/artifact/com.amazonaws/${MODULE}/${EFFECTIVE_RELEASE_VERSION}"
320+
} > "$NOTES"
321+
gh release create "$TAG" \
322+
--title "${MODULE} ${EFFECTIVE_RELEASE_VERSION}" \
323+
--notes-file "$NOTES"
324+
276325
- name: Dry-run release (prepare only, no publish)
277326
if: ${{ github.event.inputs.skip_publish == 'true' }}
278327
run: |

RELEASING.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Releasing to Maven Central
2+
3+
How maintainers publish a module using the
4+
[`Release to Maven Central`](.github/workflows/release.yml) workflow.
5+
6+
Releasable modules: `aws-lambda-java-core`, `aws-lambda-java-events`,
7+
`aws-lambda-java-events-sdk-transformer`, `aws-lambda-java-log4j2`,
8+
`aws-lambda-java-serialization`, `aws-lambda-java-tests`.
9+
10+
> `aws-lambda-java-runtime-interface-client` has its own pipeline,
11+
> [`release-runtime-interface-client.yml`](.github/workflows/release-runtime-interface-client.yml).
12+
13+
## Cutting a release
14+
15+
1. **Actions → Release to Maven Central → Run workflow**, with the branch set to
16+
**`main`** (releases only run from `main`).
17+
2. Fill in the inputs:
18+
19+
| Input | Required | Notes |
20+
|-------|----------|-------|
21+
| `module` | yes | Module directory to release. |
22+
| `changelogEntry` | yes | Markdown bullets, e.g. `- Fix X`. Added to the module `RELEASE.CHANGELOG.md` and used as the GitHub Release notes. |
23+
| `releaseVersion` | no | Defaults to the POM version without `-SNAPSHOT`. |
24+
| `developmentVersion` | no | Next dev version; must end with `-SNAPSHOT`. |
25+
| `skip_publish` | no | Dry run: build and validate, publish nothing. |
26+
27+
3. Run it and approve the `Release` environment when prompted.
28+
29+
## What it does
30+
31+
1. Validates the branch and resolves the release version from the POM (or your override).
32+
2. Builds and tests the module.
33+
3. Publishes to Maven Central and pushes the tag `<module>-<version>`.
34+
4. Opens a **version-bump PR** into `main` with the next `-SNAPSHOT`, the updated
35+
`lastPublished` comment, and your changelog entry.
36+
5. Creates a GitHub Release on the tag from your changelog entry.
37+
38+
Merge the version-bump PR to return `main` to a clean `-SNAPSHOT` state.
39+
40+
## Dry runs
41+
42+
Set `skip_publish` to build, test, and `release:prepare -DdryRun=true` without
43+
pushing anything. A `changelogEntry` is still required by the form but unused.
44+
45+
## If a release fails
46+
47+
- **Before publish:** nothing was pushed. Fix and re-run.
48+
- **After publish:** the Central version is immutable and the tag exists. Don't
49+
re-run for the same version (it fails at `release:prepare`); finish the
50+
remaining steps by hand (merge the bump PR, or `gh release create`).

aws-lambda-java-core/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<groupId>com.amazonaws</groupId>
77
<artifactId>aws-lambda-java-core</artifactId>
88
<version>1.4.1-SNAPSHOT</version>
9+
<!-- lastPublished: 1.4.0 (auto-updated by release.yml) -->
910
<packaging>jar</packaging>
1011

1112
<name>AWS Lambda Java Core Library</name>

aws-lambda-java-events-sdk-transformer/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<groupId>com.amazonaws</groupId>
77
<artifactId>aws-lambda-java-events-sdk-transformer</artifactId>
88
<version>3.1.2-SNAPSHOT</version>
9+
<!-- lastPublished: 3.1.1 (auto-updated by release.yml) -->
910
<packaging>jar</packaging>
1011

1112
<name>AWS Lambda Java Events SDK Transformer Library</name>

aws-lambda-java-events/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<groupId>com.amazonaws</groupId>
77
<artifactId>aws-lambda-java-events</artifactId>
88
<version>3.16.2-SNAPSHOT</version>
9+
<!-- lastPublished: 3.16.1 (auto-updated by release.yml) -->
910
<packaging>jar</packaging>
1011

1112
<name>AWS Lambda Java Events Library</name>

aws-lambda-java-log4j2/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<groupId>com.amazonaws</groupId>
77
<artifactId>aws-lambda-java-log4j2</artifactId>
88
<version>1.6.5-SNAPSHOT</version>
9+
<!-- lastPublished: 1.6.4 (auto-updated by release.yml) -->
910
<packaging>jar</packaging>
1011

1112
<name>AWS Lambda Java Log4j 2.x Libraries</name>

aws-lambda-java-serialization/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<groupId>com.amazonaws</groupId>
66
<artifactId>aws-lambda-java-serialization</artifactId>
77
<version>1.4.2-SNAPSHOT</version>
8+
<!-- lastPublished: 1.4.1 (auto-updated by release.yml) -->
89
<packaging>jar</packaging>
910

1011
<name>AWS Lambda Java Runtime Serialization</name>

aws-lambda-java-tests/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<groupId>com.amazonaws</groupId>
77
<artifactId>aws-lambda-java-tests</artifactId>
88
<version>1.1.3-SNAPSHOT</version>
9+
<!-- lastPublished: 1.1.2 (auto-updated by release.yml) -->
910
<packaging>jar</packaging>
1011

1112
<name>AWS Lambda Java Tests</name>

0 commit comments

Comments
 (0)