Skip to content

Commit 2af1f30

Browse files
galarghBigLep
andauthored
chore: revive and improve release automation (#2266)
* ci: automate creation of GitHub releases and tags * docs: update documentation on release creation * feat: release individual packages * fix: trigger release workflows on Cargo.toml changes * chore: simplify cargo-publish job check * ci: limit duplication in release workflows * docs: document the new release process and possible improvements * chore: apply suggestions from code review Co-authored-by: Steve Loeppky <biglep@filoz.org> * chore: modernize release automation with workspace-aware publishing - Update release-check.yml to use 'cargo publish --workspace --dry-run' - Update releaser.yml to automate 'cargo publish --workspace' on merge - Update CONTRIBUTING.md to reflect the new automated process and remove outdated limitations * chore: enable trusted publishing and fix OpenCL linkage - Enable OIDC trusted publishing for crates.io (id-token: write) - Use --no-default-features for cargo publish to avoid OpenCL dependency - Update release documentation to reflect these changes * ci: install opencl in release workflows * Apply changes requested in review --------- Co-authored-by: Steve Loeppky <biglep@filoz.org>
1 parent 5ed7dd3 commit 2af1f30

3 files changed

Lines changed: 133 additions & 46 deletions

File tree

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Release Checker
2+
3+
on:
4+
# Change to pull_request_target for the workflow to function correctly on PRs from forks
5+
pull_request:
6+
paths:
7+
- "**/Cargo.toml"
8+
types: [ opened, synchronize, reopened, labeled, unlabeled ]
9+
workflow_dispatch:
10+
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref }}
17+
cancel-in-progress: true
18+
19+
jobs:
20+
release-check:
21+
uses: ipdxco/unified-github-workflows/.github/workflows/release-check.yml@v1.0
22+
if: ${{ github.event_name == 'workflow_dispatch' || !github.event.pull_request.head.repo.fork }}
23+
with:
24+
sources: |
25+
[
26+
"fvm/Cargo.toml",
27+
"testing/integration/Cargo.toml",
28+
"ipld/amt/Cargo.toml",
29+
"ipld/bitfield/Cargo.toml",
30+
"ipld/blockstore/Cargo.toml",
31+
"ipld/car/Cargo.toml",
32+
"ipld/encoding/Cargo.toml",
33+
"ipld/hamt/Cargo.toml",
34+
"ipld/kamt/Cargo.toml",
35+
"sdk/Cargo.toml",
36+
"shared/Cargo.toml"
37+
]
38+
separator: "@"
39+
cargo-publish:
40+
needs: [release-check]
41+
if: needs.release-check.outputs.json != '{}'
42+
runs-on: ubuntu-latest
43+
steps:
44+
- uses: actions/checkout@v6
45+
- name: Install required packages
46+
uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4.0.0
47+
with:
48+
timeout_minutes: 10
49+
max_attempts: 3
50+
shell: bash
51+
command: |
52+
sudo apt-get update
53+
sudo apt-get install --no-install-recommends --yes libhwloc-dev ocl-icd-opencl-dev
54+
- name: Dry-run publish
55+
run: |
56+
# Use cargo publish --workspace --dry-run to verify the entire workspace at once.
57+
# This correctly handles interdependent crates which a matrix-based approach misses.
58+
cargo publish --workspace --dry-run

.github/workflows/releaser.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Releaser
2+
3+
on:
4+
push:
5+
paths:
6+
- "**/Cargo.toml"
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
id-token: write
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.sha }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
releaser:
19+
uses: ipdxco/unified-github-workflows/.github/workflows/releaser.yml@v1.0
20+
with:
21+
sources: |
22+
[
23+
"fvm/Cargo.toml",
24+
"testing/integration/Cargo.toml",
25+
"ipld/amt/Cargo.toml",
26+
"ipld/bitfield/Cargo.toml",
27+
"ipld/blockstore/Cargo.toml",
28+
"ipld/car/Cargo.toml",
29+
"ipld/encoding/Cargo.toml",
30+
"ipld/hamt/Cargo.toml",
31+
"ipld/kamt/Cargo.toml",
32+
"sdk/Cargo.toml",
33+
"shared/Cargo.toml"
34+
]
35+
separator: "@"
36+
secrets:
37+
UCI_GITHUB_TOKEN: ${{ secrets.UCI_GITHUB_TOKEN }}
38+
39+
cargo-publish:
40+
needs: [releaser]
41+
if: needs.releaser.outputs.json != '{}'
42+
runs-on: ubuntu-latest
43+
steps:
44+
- uses: actions/checkout@v6
45+
- name: Install required packages
46+
uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4.0.0
47+
with:
48+
timeout_minutes: 10
49+
max_attempts: 3
50+
shell: bash
51+
command: |
52+
sudo apt-get update
53+
sudo apt-get install --no-install-recommends --yes libhwloc-dev ocl-icd-opencl-dev
54+
- name: Publish to crates.io
55+
run: |
56+
# Use cargo publish --workspace to publish all changed crates in the workspace.
57+
# This handles interdependent crates correctly and only publishes those with version bumps.
58+
cargo publish --workspace

RELEASE.md

Lines changed: 17 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ The FVM is a workspace of crates which have different release schedules:
1414
> When releasing a new version of the FVM, make sure to check if any backports are needed and do them in separate PRs targeting the appropriate branches. Afterwards, make sure to create a new release for the backported changes.
1515
> Note that the v2 and v3 tracks no longer contain the `fvm_integration_tests` crate so there is no need to backport and release it.
1616
17-
The primary crates are `fvm`, `fvm_shared`, `fvm_sdk`, and the integration testing framework `fvm_integration_tests`. These are the crates that have [`version.workspace = true`](https://github.com/search?q=repo%3Afilecoin-project%2Fref-fvm%20version.workspace%20%3D%20true&type=code).
17+
The primary crates are `fvm`, `fvm_shared`, `fvm_sdk`, and the integration testing framework `fvm_integration_tests`. These are the crates that have [`version.workspace = true`](https://github.com/search?q=repo%3Afilecoin-project%2Fref-fvm%20version.workspace%20%3D%20true&type=code).
1818

1919
## Versioning
2020
Versioning of the [primary crates](#primary-crates) is not strictly semver compatible:
@@ -33,9 +33,6 @@ To propose a new release, open a pull request with the following changes:
3333
2. Update the version of the coupled workspace dependencies in `Cargo.toml` to match the new version
3434
(leaving semver range specifier `~` intact):
3535
1. `workspace.dependencies→fvm→version`
36-
2. `wokspace.dependencies→fvm_shared→version`
37-
3. `wokspace.dependencies→fvm_sdk→version`
38-
1. `workspace.dependencies→fvm→version`
3936
2. `workspace.dependencies→fvm_shared→version`
4037
3. `workspace.dependencies→fvm_sdk→version`
4138
4. `workspace.dependencies→fvm_integration_tests→version`
@@ -47,6 +44,11 @@ To propose a new release, open a pull request with the following changes:
4744

4845
See [PR #2002](https://github.com/filecoin-project/ref-fvm/pull/2002) for an example.
4946

47+
When a release PR is opened or updated, the **Release Checker** GitHub Action will:
48+
* Verify that the version bump is correct.
49+
* Perform a workspace-wide dry-run publish (`cargo publish --workspace --dry-run`) to ensure all crates are in a valid state for release.
50+
* Create a draft GitHub Release and comment on the PR with a summary.
51+
5052
## Preparing Other/Non-Primary Crates
5153

5254
To propose a release of a crate other than `fvm`, `fvm_shared`, `fvm_sdk`, or
@@ -58,59 +60,28 @@ To propose a release of a crate other than `fvm`, `fvm_shared`, `fvm_sdk`, or
5860
3. Make sure the `CHANGELOG.md` files are all up-to-date (look through `git log -- path/to/crate`),
5961
set the release date & version, and add a new "Unreleased" section.
6062

63+
The **Release Checker** will also handle these crates independently based on the paths modified in the PR.
64+
6165
## Review and Release
6266

6367
Once the release is prepared, it'll go through a review:
6468

6569
1. Make sure that we're _ready_ to release. E.g., make sure downstream can consume the release.
6670
2. Make sure that we're correctly following semver.
6771
3. Make sure that we're not missing anything in the changelogs.
72+
4. Verify that the **Release Checker** action has passed, including the "Dry-run publish" step.
6873

6974
Finally, an [FVM "owner"](https://github.com/orgs/filecoin-project/teams/fvm-crate-owners/members) will:
7075

7176
1. Merge the release PR to master.
72-
2. For each released crate, create a git tag: `crate_name@crate_version`.
73-
3. Run `cargo publish` for each released crate (in dependency order).
74-
75-
Example steps for an FVM "owner" to release `MINOR` and `PATCH` crates:
76-
77-
1. Merge the `PATCH` release PR to master (e.g., [PR #2030](https://github.com/filecoin-project/ref-fvm/pull/2030)).
78-
2. Publish all [primary crates](#primary-crates) . For each crate (fvm, fvm_shared, fvm_sdk, fvm_integration_tests):
79-
80-
```bash
81-
# Declare an associative array for crate_name → crate_directory
82-
declare -A crates
83-
crates["fvm"]="fvm"
84-
crates["fvm_shared"]="shared"
85-
crates["fvm_sdk"]="fvm_sdk"
86-
crates["fvm_integration_tests"]="testing/integration"
87-
88-
workspace_package_version = `tomlq '.workspace.package.version' Cargo.toml`
89-
90-
for crate_name in "${!crates[@]}"; do
91-
crate_directory = ${crates[$key]}
92-
pushd $crate_directory
93-
cargo publish
94-
workspace_package_version=`tomlq '.workspace.package.version' Cargo.toml`
95-
96-
for crate_name in "${!my_map[@]}"; do
97-
crate_directory=${crates[$key]}
98-
pushd $crate_directory
99-
cargo publish
100-
git_tag="$crate_name@v$workspace_package_version"
101-
git tag $git_tag
102-
popd
103-
done
104-
```
105-
106-
3. After creating all tags, push them:
107-
108-
```shell
109-
git push --tags
110-
```
111-
112-
4. Verify the releases on crates.io:
77+
2. The **Releaser** GitHub Action will automatically:
78+
* Create git tags for each released crate (`crate_name@vX.Y.Z`).
79+
* Publish the draft GitHub Release(s).
80+
* Publish the crates to [crates.io](https://crates.io) using `cargo publish --workspace --no-default-features`.
81+
- Note: This repository uses **trusted publishing** via OIDC. No `CARGO_REGISTRY_TOKEN` secret is required, but the repository must be configured as a trusted publisher on crates.io.
82+
83+
3. Verify the releases on crates.io:
11384
https://crates.io/crates/fvm/versions
11485
https://crates.io/crates/fvm_shared/versions
11586
https://crates.io/crates/fvm_sdk/versions
116-
https://crates.io/crates/fvm_integration_tests/versions
87+
https://crates.io/crates/fvm_integration_tests/versions

0 commit comments

Comments
 (0)