Skip to content

Commit f10613e

Browse files
ErikUggeldahlErikUggeldahl
andcommitted
fix(Android): Pass changelog versions through environment (#12905) fbdbfc95f6
# Description Fix the Android maintenance release workflow failing before the version bump. `release-it` renders `git.changelog` before its `latestVersion` and `version` template variables are available, causing the release to exit before creating a commit or tag. # Details - Pass the validated current and target versions to `release-it` as environment variables - Use `CURRENT_VERSION` to anchor pre-bump release notes to the selected release line - Use `TARGET_VERSION` to assign the post-bump changelog entry to the new release - Update the release documentation to describe the corrected version lifecycle - Validate the fix against the locked `release-it` 19.0.3 dependency in dry-run mode; it now passes the template-rendering stage Co-authored-by: Erik <erik@rive.app>
1 parent 1950c52 commit f10613e

4 files changed

Lines changed: 27 additions & 21 deletions

File tree

.github/scripts/release/.release-it.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"git": {
33
"commitMessage": "chore: release v${version}",
44
"tagName": "${version}",
5-
"changelog": "npx auto-changelog --stdout --commit-limit false --unreleased --latest-version ${latestVersion} --template https://raw.githubusercontent.com/release-it/release-it/master/templates/changelog-compact.hbs"
5+
"changelog": "npx auto-changelog --stdout --commit-limit false --unreleased --latest-version \"$CURRENT_VERSION\" --template https://raw.githubusercontent.com/release-it/release-it/master/templates/changelog-compact.hbs"
66
},
77
"github": {
88
"release": true,
@@ -26,7 +26,7 @@
2626
},
2727
"hooks": {
2828
"after:bump": [
29-
"npx auto-changelog --latest-version ${version} -o ../../../CHANGELOG.md --hide-empty-releases",
29+
"npx auto-changelog --latest-version \"$TARGET_VERSION\" -o ../../../CHANGELOG.md --hide-empty-releases",
3030
"git add ../../../CHANGELOG.md",
3131
"git add ../../../VERSION"
3232
]

.github/scripts/release/README.md

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,38 +45,43 @@ For `TARGET_VERSION=12.0.1`, this effectively runs `release-it 12.0.1 --ci`. The
4545

4646
## Current and Target Versions
4747

48-
The `.release-it.json` configuration uses two variables supplied by `release-it`:
48+
The release step passes two workflow outputs through its environment:
4949

50-
- `${latestVersion}` is the version read from the Android `VERSION` file before it is bumped. It
51-
is the current completed release, such as `12.0.0`.
52-
- `${version}` is the target version passed to `release-it`, such as `12.0.1`.
50+
- `$CURRENT_VERSION` is the version read from the Android `VERSION` file before it is bumped. It is
51+
the current completed release, such as `12.0.0`.
52+
- `$TARGET_VERSION` is the version calculated by the workflow and passed to `release-it`, such as
53+
`12.0.1`.
54+
55+
These are workflow environment variables rather than release-it template variables. Release-it
56+
generates `git.changelog` before it adds its `latestVersion` and `version` values to the global
57+
template context, so those template variables are not available when this command is rendered.
5358

5459
The `@release-it/bumper` plugin's `in` configuration makes the Android `VERSION` file the source
55-
of `latestVersion`. Its `out` configuration writes `version` back to that file during the bump. The
56-
plugin does not choose the target version; the workflow passes that version as the positional
57-
argument. Without this plugin, release-it would normally read the current version from
58-
`package.json` or the latest Git tag and persist the target through its corresponding version
59-
mechanism.
60+
of release-it's current version. Its `out` configuration writes release-it's target version back to
61+
that file during the bump. The plugin does not choose the target version; the workflow passes that
62+
version as the positional argument. Without this plugin, release-it would normally read the current
63+
version from `package.json` or the latest Git tag and persist the target through its corresponding
64+
version mechanism.
6065

6166
## Release Notes and `CHANGELOG.md`
6267

6368
The two `auto-changelog` commands serve different phases of the release:
6469

6570
1. `git.changelog` runs before the bump and writes release-note text to standard output. The
66-
`--unreleased --latest-version ${latestVersion}` arguments mean "collect changes after the
67-
selected branch's current completed release through `HEAD`." Pinning `latestVersion` prevents a
71+
`--unreleased --latest-version $CURRENT_VERSION` arguments mean "collect changes after the
72+
selected branch's current completed release through `HEAD`." Pinning `CURRENT_VERSION` prevents a
6873
newer tag from another release line, such as `12.1.0`, from becoming the boundary for a
6974
`12.0.1` maintenance release.
70-
2. The `after:bump` hook regenerates and stages `CHANGELOG.md`. At this point `${version}` is the
71-
new target, so `--latest-version ${version}` assigns those formerly unreleased changes to the
72-
new `12.0.1` section.
75+
2. The `after:bump` hook regenerates and stages `CHANGELOG.md`. At this point `$TARGET_VERSION` is
76+
the new target, so `--latest-version $TARGET_VERSION` assigns those formerly unreleased changes
77+
to the new `12.0.1` section.
7378

7479
For a `12.0.1` maintenance release, the lifecycle is therefore:
7580

7681
```text
7782
VERSION contains 12.0.0
78-
latestVersion = 12.0.0
83+
CURRENT_VERSION = 12.0.0
7984
→ collect commits after 12.0.0 as unreleased release notes
80-
→ bump to version = 12.0.1
85+
→ bump to TARGET_VERSION = 12.0.1
8186
→ write those commits under 12.0.1 in CHANGELOG.md
8287
```

.github/workflows/release.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,13 @@ jobs:
157157
git config --local user.email 'hello@rive.app'
158158
git config --local user.name ${{ github.actor }}
159159
160-
# The validation step writes target_version to GITHUB_OUTPUT. GitHub resolves the expression
161-
# below and supplies it to release-it as the TARGET_VERSION environment variable.
160+
# The validation step writes both versions to GITHUB_OUTPUT. GitHub resolves the expressions
161+
# below and supplies them to release-it as environment variables.
162162
- name: ${{ inputs.bump }} release - Bump version number, update changelog, push and tag
163163
run: npm run release -- "$TARGET_VERSION" --ci
164164
working-directory: ./.github/scripts/release
165165
env:
166+
CURRENT_VERSION: ${{ steps.release.outputs.current_version }}
166167
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
167168
TARGET_VERSION: ${{ steps.release.outputs.target_version }}
168169

.rive_head

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
d03d3b14f7021e32975257ed7e6b8c42595d30b6
1+
fbdbfc95f628879b5c1a7a4ced445f8a34581dfa

0 commit comments

Comments
 (0)