Skip to content

Commit c79c362

Browse files
authored
ci: add releases.toml automation for compatibility tracking (#121)
* ci: add releases.toml automation for compatibility tracking Add CI automation to track dependency versions for each release: - Add `update_releases.sh` script that extracts sway, fuel-core, and fuels-rs versions from Cargo.lock and appends entries to releases.toml - Add `update-releases` job to CI that runs after publish-crates and opens a PR with the updated releases.toml - Update RELEASING.md to document the new compatibility tracking step This implements the compatibility tracking section from the forc-tooling monorepo RFC. The releases.toml file serves as an append-only log that fuelup and fuel.nix can use to determine compatible toolchain versions. Also bump forc-wallet to 0.16.2 to test the automation after merge. * fix: fetch releases.toml from main before appending
1 parent aaf6925 commit c79c362

File tree

6 files changed

+149
-2
lines changed

6 files changed

+149
-2
lines changed

.github/workflows/ci.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,3 +267,49 @@ jobs:
267267
if: github.ref_type == 'tag'
268268
with:
269269
files: ${{ env.ZIP_FILE_NAME }}
270+
271+
update-releases:
272+
name: Update releases.toml
273+
needs: publish-crates
274+
if: github.event_name == 'release' && github.event.action == 'published'
275+
runs-on: ubuntu-latest
276+
permissions:
277+
contents: write
278+
pull-requests: write
279+
280+
steps:
281+
- name: Checkout release tag
282+
uses: actions/checkout@v4
283+
with:
284+
ref: ${{ github.ref }}
285+
286+
- name: Extract crate info from tag
287+
id: extract
288+
run: |
289+
TAG="${{ github.ref_name }}"
290+
CRATE_NAME=$(echo "$TAG" | sed -E 's/-[0-9]+\.[0-9]+\.[0-9]+.*//')
291+
VERSION=$(echo "$TAG" | sed -E 's/^.*-([0-9]+\.[0-9]+\.[0-9]+.*)/\1/')
292+
echo "crate_name=$CRATE_NAME" >> $GITHUB_OUTPUT
293+
echo "version=$VERSION" >> $GITHUB_OUTPUT
294+
295+
- name: Fetch latest releases.toml from main
296+
run: |
297+
git fetch origin main
298+
git checkout origin/main -- releases.toml 2>/dev/null || true
299+
300+
- name: Update releases.toml
301+
run: ./.github/workflows/scripts/update_releases.sh ${{ steps.extract.outputs.crate_name }} ${{ steps.extract.outputs.version }}
302+
303+
- name: Create Pull Request
304+
uses: peter-evans/create-pull-request@v6
305+
with:
306+
token: ${{ secrets.GITHUB_TOKEN }}
307+
base: main
308+
branch: chore/releases-${{ github.ref_name }}
309+
commit-message: "chore: update releases.toml for ${{ github.ref_name }}"
310+
title: "chore: update releases.toml for ${{ github.ref_name }}"
311+
body: |
312+
Auto-generated PR to update `releases.toml` after publishing `${{ github.ref_name }}`.
313+
314+
This tracks the dependency versions used in this release for compatibility reference.
315+
labels: automated,releases
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
# Updates releases.toml with dependency information for a released crate.
5+
# Usage: update_releases.sh <crate-name> <version>
6+
#
7+
# This script extracts resolved dependency versions from Cargo.lock and appends
8+
# a new entry to releases.toml for compatibility tracking.
9+
10+
err() {
11+
echo -e "\e[31m\e[1merror:\e[0m $@" 1>&2;
12+
}
13+
14+
status() {
15+
WIDTH=12
16+
printf "\e[32m\e[1m%${WIDTH}s\e[0m %s\n" "$1" "$2"
17+
}
18+
19+
CRATE_NAME=$1
20+
VERSION=$2
21+
RELEASES_FILE="releases.toml"
22+
23+
if [ -z "$CRATE_NAME" ] || [ -z "$VERSION" ]; then
24+
err "Usage: update_releases.sh <crate-name> <version>"
25+
exit 1
26+
fi
27+
28+
status "Updating" "$RELEASES_FILE for $CRATE_NAME $VERSION"
29+
30+
DATE=$(date -u +"%Y-%m-%d")
31+
CRATE_TOML="${CRATE_NAME}/Cargo.toml"
32+
33+
# Extract resolved version from Cargo.lock
34+
get_lock_version() {
35+
local dep_name=$1
36+
grep -A1 "name = \"$dep_name\"" Cargo.lock 2>/dev/null | \
37+
grep "version = " | head -1 | \
38+
sed 's/.*version = "\(.*\)".*/\1/'
39+
}
40+
41+
# Check if crate depends on a package
42+
# Matches both `dep = "version"` and `dep.workspace = true` styles
43+
crate_depends_on() {
44+
local dep_pattern=$1
45+
grep -qE "^${dep_pattern}([[:space:]]*=|\.)" "$CRATE_TOML" 2>/dev/null
46+
}
47+
48+
# Only record versions for dependencies the crate actually uses
49+
SWAY_VERSION=""
50+
FUEL_CORE_VERSION=""
51+
FUELS_VERSION=""
52+
53+
if crate_depends_on "sway-core"; then
54+
SWAY_VERSION=$(get_lock_version "sway-core")
55+
fi
56+
57+
if crate_depends_on "fuel-core"; then
58+
FUEL_CORE_VERSION=$(get_lock_version "fuel-core")
59+
fi
60+
61+
if crate_depends_on "fuels"; then
62+
FUELS_VERSION=$(get_lock_version "fuels")
63+
fi
64+
65+
# Create releases.toml if it doesn't exist
66+
if [ ! -f "$RELEASES_FILE" ]; then
67+
cat > "$RELEASES_FILE" << 'EOF'
68+
# Auto-generated at release time. Do not edit manually.
69+
# This file tracks which dependency versions each release was built against.
70+
71+
EOF
72+
status "Created" "$RELEASES_FILE"
73+
fi
74+
75+
# Build the TOML entry
76+
{
77+
echo "[[releases]]"
78+
echo "crate = \"$CRATE_NAME\""
79+
echo "version = \"$VERSION\""
80+
echo "date = \"$DATE\""
81+
82+
[ -n "$SWAY_VERSION" ] && echo "sway = \"$SWAY_VERSION\""
83+
[ -n "$FUEL_CORE_VERSION" ] && echo "fuel-core = \"$FUEL_CORE_VERSION\""
84+
[ -n "$FUELS_VERSION" ] && echo "fuels-rs = \"$FUELS_VERSION\""
85+
echo ""
86+
} >> "$RELEASES_FILE"
87+
88+
status "Appended" "release entry for $CRATE_NAME $VERSION"

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

RELEASING.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ When you publish a GitHub release with a tag like `forc-wallet-0.16.0`, the CI w
5656
- Example: `forc-wallet-0.16.0-x86_64-unknown-linux-gnu.tar.gz`
5757
- Uploads all binary archives to the GitHub release
5858

59+
#### 3. Update Compatibility Tracking (`update-releases` job)
60+
61+
- Runs after successful crate publication
62+
- Extracts dependency versions from `Cargo.lock` (sway, fuel-core, fuels-rs)
63+
- Appends an entry to `releases.toml` tracking what versions this release was built against
64+
- Opens a PR to merge the updated `releases.toml` into main
65+
66+
This creates an append-only log of releases and their dependencies, useful for `fuelup` and `fuel.nix` to determine compatible toolchain combinations.
67+
5968
**Key Point:** The CI is fully generic. When you add a new workspace member (e.g., `forc-plugin`) and create a tag `forc-plugin-1.0.0`, the same CI workflow will automatically build and publish that crate without any workflow modifications.
6069

6170
### Release Checklist

forc-wallet/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 0.16.2 (December 6th, 2025)
2+
3+
No functional changes. Version bump to test `releases.toml` automation.
4+
15
# 0.16.1 (November 21st, 2025)
26

37
### Changed

forc-wallet/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name = "forc-wallet"
44
# - Remove path dependencies
55
# - Update CHANGELOG.md.
66
# - Create "forc-wallet-0.16.x" git tag.
7-
version = "0.16.1"
7+
version = "0.16.2"
88
description = "A forc plugin for generating or importing wallets using mnemonic phrases."
99
edition = "2024"
1010
authors.workspace = true

0 commit comments

Comments
 (0)