Skip to content

Commit 41a684f

Browse files
authored
Release process tweaks
* Verify release commit is in the main branch Typically the tag is pushed first, CI runs, clearing the way for 'main' to be pushed. However we must not release until this is done. * Improve CI status check Execute logic within jq; look for any passing workflow and fail if there are none. * Execute package.json check within jq No need for Bash, jq can handle this. * Perform package.json check first It's the most important check, are we publishing what we think we're publishing. * Update instructions
1 parent bc3ef72 commit 41a684f

File tree

2 files changed

+65
-39
lines changed

2 files changed

+65
-39
lines changed

.github/workflows/release.yml

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,30 +31,40 @@ jobs:
3131
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref }}
3232
fetch-depth: 0
3333

34-
- name: Check CI status
35-
if: ${{ !inputs.skip_ci_check }}
34+
- name: Verify tag matches package.json version
3635
run: |
37-
# Check if CI has completed successfully for this commit
38-
RESULT=$(gh run list --commit ${{ github.sha }} --status success --json conclusion,workflowName | jq '.[]|select(.workflowName == "Install and test AVA")')
39-
if [ -z "$RESULT" ]; then
40-
echo "CI has not completed successfully for this commit"
41-
exit 1
42-
fi
43-
echo "All CI checks have passed!"
36+
jq --raw-output --exit-status --arg tag "$RELEASE_TAG" '
37+
if (.version == ($tag | ltrimstr("v"))) then
38+
"Package version (\(.version)) matches tag version (\($tag | ltrimstr("v")))"
39+
else
40+
"Package version (\(.version)) does not match tag version (\($tag | ltrimstr("v")))" | halt_error(1)
41+
end' package.json
4442
env:
45-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }}
4644

47-
- name: Verify tag matches package.json version
45+
- name: Verify commit is in main branch
4846
run: |
49-
PACKAGE_VERSION=$(jq -r '.version' package.json)
50-
TAG_VERSION=${RELEASE_TAG#v}
51-
if [ "$PACKAGE_VERSION" != "$TAG_VERSION" ]; then
52-
echo "Package version ($PACKAGE_VERSION) does not match tag version ($TAG_VERSION)"
47+
# Check if the tagged commit is included in the main branch
48+
if git merge-base --is-ancestor ${{ github.sha }} origin/main; then
49+
echo "Tagged commit is properly included in main branch"
50+
else
51+
echo "Tagged commit is not included in the main branch"
52+
echo "Please push the commit to main before releasing"
5353
exit 1
5454
fi
55-
env:
56-
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }}
5755
56+
- name: Check CI status
57+
if: ${{ !inputs.skip_ci_check }}
58+
run: |
59+
# Check if CI has completed successfully for this commit
60+
gh run list --commit ${{ github.sha }} --status success --json workflowName | jq --raw-output --exit-status '
61+
if any(.[]; .workflowName == "Install and test AVA") then
62+
"All CI checks have passed!"
63+
else
64+
"CI has not completed successfully for this commit" | halt_error(1)
65+
end'
66+
env:
67+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5868

5969
- name: Setup Node.js
6070
uses: actions/setup-node@v4

maintaining.md

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,51 +6,67 @@
66

77
## Testing
88

9-
* `npm test`: Lint the code and run the entire test suite with coverage.
10-
* `npx test-ava`: Run self-hosted tests from `test/`. Wraps a stable version of AVA.
11-
* `npx tap`: Run legacy tests from `test-tap/`.
12-
13-
Note that in CI we only run linting with the Node.js version set in the `package.json` file under the `"volta"` key.
9+
- `npm test`: Lint the code and run the entire test suite with coverage.
10+
- `npx tap test-tap/fork.js --bail`: Run a specific test file and bail on the first failure (useful when hunting bugs).
11+
- `npx test-ava test/{file}.js`: Run self-hosted tests.
1412

1513
## CI
1614

17-
We test across Linux, macOS and Windows, across all supported Node.js versions. The occasional failure in a specific environment is to be expected. If jobs fail, review carefully.
18-
19-
TypeScript jobs should all pass.
15+
- Tests sometimes fail on Windows. Review the errors carefully.
16+
- At least one Windows job must pass.
17+
- All other jobs must pass.
2018

2119
## Updating dependencies
2220

23-
* Make sure new dependency versions are compatible with our supported Node.js versions.
24-
* TypeScript dependency changes require CI changes to ensure backwards compatibility, see below.
25-
* Open a PR with the updates and only merge when CI passes (see the previous section).
21+
- Make sure new dependency versions are compatible with our supported Node.js versions.
22+
- Leave the TypeScript dependency as it is, to avoid accidental breakage.
23+
- Open a PR with the updates and only merge when CI passes (see the previous section).
2624

2725
## Updating TypeScript
2826

2927
TypeScript itself does not follow SemVer. Consequently we may have to make changes to the type definition that, technically, are breaking changes for users with an older TypeScript version. That's OK, but we should be aware.
3028

31-
When updating the TypeScript dependency, *also* add it to the CI workflow. This enables us to do typechecking with previous TypeScript versions and avoid unintentional breakage. For instance we won't accidentally rely on newer TypeScript features.
29+
Only update the TypeScript dependency when truly necessary. This helps avoid accidental breakage. For instance we won't accidentally rely on newer TypeScript features.
3230

3331
Speaking of, using newer TypeScript features could be considered a breaking change. This needs to be assessed on a case-by-case basis.
3432

3533
## Pull requests
3634

37-
* New features should come with tests and documentation.
38-
* Ensure the [contributing guidelines](.github/CONTRIBUTING.md) are followed.
39-
* Usually we squash commits when merging. Rebases may sometimes be appropriate.
35+
- New features should come with tests and documentation.
36+
- Ensure the [contributing guidelines](.github/CONTRIBUTING.md) are followed.
37+
- Squash commits when merging.
4038

4139
## Experiments
4240

43-
* Implement breaking changes as an experiment first, requiring opt-in.
44-
* Ship new features early by treating them as an experiment, requiring opt-in.
41+
- Implement breaking changes as an experiment first, requiring opt-in.
42+
- Ship new features early by treating them as an experiment, requiring opt-in.
4543

4644
## Release process
4745

48-
* Use `npm version` with the correct increment and push the resulting tag and `main` branch.
49-
* CI will run against the tag. Wait for this to complete.
50-
* Approve the Release workflow within GitHub. The workflow includes npm provenance for enhanced security and supply chain transparency.
46+
1. In the `main` branch, use `npm version` with the correct increment.
47+
1. Push the resulting tag (`git push --tags`).
48+
1. Wait for minimal CI checks to pass and push the `main` branch.
49+
1. Wait for full CI run to complete on the tag.
50+
1. The *Release* workflow will automatically run and publish to npm with provenance. It will also create a draft GitHub release.
51+
1. Review and publish the [draft GitHub release](https://github.com/avajs/ava/releases).
52+
53+
The *Release* workflow includes several safety checks:
54+
55+
- Validates the tag version matches `package.json`
56+
- Verifies the tagged commit is included in the `main` branch
57+
- Confirms CI has passed for the commit
58+
59+
### Manual Release
60+
61+
If CI fails for the tag and you're confident this is not due to a fault in the release, you can manually trigger the *Release* workflow:
62+
63+
1. Go to the [*Release* workflow](https://github.com/avajs/ava/actions/workflows/release.yml)
64+
1. Click "Run workflow"
65+
1. Enter the release tag (e.g., `v1.2.3`)
66+
1. Optionally check "Skip CI status check"
5167

5268
### Setup Requirements
5369

54-
For the automated workflows to work, the following secrets must be configured in the repository:
70+
For the Release workflow to work, the `NPM_TOKEN` must be configured in the [`npm` environment](https://github.com/avajs/ava/settings/environments/7070437878/edit#environment-secrets).
5571

56-
- `NPM_TOKEN`: An npm automation token with publish permissions to the AVA package, within the `npm` environment
72+
This must be a granular automation token which can publish the AVA package. It must be set to expire after no more than 90 days.

0 commit comments

Comments
 (0)