Skip to content

Commit 73720d9

Browse files
committed
ci(release): stamp package version from tag and bump action versions
Add scripts/ci/stamp_version.sh to rewrite Cargo.toml's [package] version from the release tag before publishing, and wire it into release-prepare.yml and release.yml. Since publish now runs against a possibly-edited Cargo.toml, pass --allow-dirty to cargo publish. Also bump pinned GitHub Actions across the release and test workflows (checkout v6->v7, upload-artifact v4->v7, download-artifact v4->v8, action-gh-release v2->v3) and labeler's checkout v4->v7.
1 parent da5a4d5 commit 73720d9

6 files changed

Lines changed: 53 additions & 17 deletions

File tree

.github/workflows/labels.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
sync:
1515
runs-on: ubuntu-latest
1616
steps:
17-
- uses: actions/checkout@v4
17+
- uses: actions/checkout@v7
1818
- uses: crazy-max/ghaction-github-labeler@v5
1919
with:
2020
yaml-file: .github/labels.yml

.github/workflows/release-prepare.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ jobs:
7070
label: windows-x64
7171
ext: ".exe"
7272
steps:
73-
- uses: actions/checkout@v6
73+
- uses: actions/checkout@v7
7474

7575
- name: Install Rust + target
7676
uses: dtolnay/rust-toolchain@stable
@@ -81,6 +81,10 @@ jobs:
8181
with:
8282
prefix-key: fsck-${{ matrix.target }}
8383

84+
- name: Set version from tag
85+
shell: bash
86+
run: bash scripts/ci/stamp_version.sh "${{ needs.validate-version.outputs.version }}"
87+
8488
- name: Build pagedb-fsck
8589
run: cargo build --release --bin pagedb-fsck --target ${{ matrix.target }}
8690

@@ -100,7 +104,7 @@ jobs:
100104
$name = "pagedb-fsck-${{ needs.validate-version.outputs.version }}-${{ matrix.label }}.zip"
101105
Compress-Archive -Path "pagedb-fsck${{ matrix.ext }}" -DestinationPath $name
102106
103-
- uses: actions/upload-artifact@v4
107+
- uses: actions/upload-artifact@v7
104108
with:
105109
name: fsck-${{ matrix.label }}
106110
path: |

.github/workflows/release-validate.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
version: ${{ steps.version.outputs.version }}
3131
is_full_release: ${{ steps.version.outputs.is_full_release }}
3232
steps:
33-
- uses: actions/checkout@v6
33+
- uses: actions/checkout@v7
3434
with:
3535
ref: ${{ inputs.ref }}
3636

.github/workflows/release.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
runs-on: ubuntu-latest
6969
environment: crates.io
7070
steps:
71-
- uses: actions/checkout@v6
71+
- uses: actions/checkout@v7
7272
with:
7373
ref: ${{ inputs.tag }}
7474

@@ -82,6 +82,9 @@ jobs:
8282
- name: Install LLVM/Clang
8383
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends clang libclang-dev
8484

85+
- name: Set version from tag
86+
run: bash scripts/ci/stamp_version.sh "${{ needs.validate-version.outputs.version }}"
87+
8588
- name: Publish pagedb
8689
env:
8790
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
@@ -102,7 +105,9 @@ jobs:
102105
fi
103106
104107
echo "Publishing pagedb@$VERSION..."
105-
cargo publish -p pagedb
108+
# --allow-dirty: stamp_version.sh may have edited Cargo.toml for a
109+
# prerelease tag; the verifying publish still runs.
110+
cargo publish -p pagedb --allow-dirty
106111
107112
# ── GitHub Release ───────────────────────────────────────────────────────────
108113
# Independent of publish-crate: a crates.io outage must not block cutting the
@@ -116,13 +121,13 @@ jobs:
116121
contents: write
117122
actions: read
118123
steps:
119-
- uses: actions/checkout@v6
124+
- uses: actions/checkout@v7
120125
with:
121126
ref: ${{ inputs.tag }}
122127
fetch-depth: 0
123128

124129
- name: Download fsck artifacts
125-
uses: actions/download-artifact@v4
130+
uses: actions/download-artifact@v8
126131
with:
127132
pattern: "fsck-*"
128133
run-id: ${{ inputs.prepare_run_id }}
@@ -131,7 +136,7 @@ jobs:
131136
merge-multiple: true
132137

133138
- name: Create GitHub Release
134-
uses: softprops/action-gh-release@v2
139+
uses: softprops/action-gh-release@v3
135140
with:
136141
tag_name: ${{ inputs.tag }}
137142
name: pagedb ${{ needs.validate-version.outputs.version }}

.github/workflows/test.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
name: Lint, Format & Docs
4040
runs-on: ubuntu-latest
4141
steps:
42-
- uses: actions/checkout@v6
42+
- uses: actions/checkout@v7
4343

4444
- name: Install Rust
4545
uses: dtolnay/rust-toolchain@stable
@@ -90,7 +90,7 @@ jobs:
9090
matrix:
9191
os: [ubuntu-latest, macos-latest, windows-latest]
9292
steps:
93-
- uses: actions/checkout@v6
93+
- uses: actions/checkout@v7
9494

9595
- name: Install Rust
9696
uses: dtolnay/rust-toolchain@stable
@@ -124,7 +124,7 @@ jobs:
124124

125125
- name: Upload nextest report
126126
if: always()
127-
uses: actions/upload-artifact@v4
127+
uses: actions/upload-artifact@v7
128128
with:
129129
name: nextest-${{ matrix.os }}
130130
path: target/nextest/default/junit.xml
@@ -155,7 +155,7 @@ jobs:
155155
- target: armv7-linux-androideabi
156156
label: android-armv7 (AndroidVfs / thread-pool)
157157
steps:
158-
- uses: actions/checkout@v6
158+
- uses: actions/checkout@v7
159159

160160
- name: Install Rust + target
161161
uses: dtolnay/rust-toolchain@stable
@@ -184,7 +184,7 @@ jobs:
184184
features: ""
185185
label: wasi (WasiVfs)
186186
steps:
187-
- uses: actions/checkout@v6
187+
- uses: actions/checkout@v7
188188

189189
- name: Install Rust + target
190190
uses: dtolnay/rust-toolchain@stable
@@ -211,7 +211,7 @@ jobs:
211211
- "--features compression"
212212
- "--all-features"
213213
steps:
214-
- uses: actions/checkout@v6
214+
- uses: actions/checkout@v7
215215

216216
- name: Install Rust
217217
uses: dtolnay/rust-toolchain@stable
@@ -233,7 +233,7 @@ jobs:
233233
name: Benchmark (dry run)
234234
runs-on: ubuntu-latest
235235
steps:
236-
- uses: actions/checkout@v6
236+
- uses: actions/checkout@v7
237237

238238
- name: Install Rust
239239
uses: dtolnay/rust-toolchain@stable
@@ -258,7 +258,7 @@ jobs:
258258
name: Dependency audit
259259
runs-on: ubuntu-latest
260260
steps:
261-
- uses: actions/checkout@v6
261+
- uses: actions/checkout@v7
262262
- name: Install Rust
263263
uses: dtolnay/rust-toolchain@stable
264264
- name: Install cargo-deny

scripts/ci/stamp_version.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
# Stamp the package version from a release tag.
3+
#
4+
# scripts/ci/stamp_version.sh <version> # e.g. 0.1.0, 0.1.0-beta.2
5+
#
6+
# Rewrites `[package] version` in Cargo.toml. pagedb is a single leaf crate with
7+
# no internal path deps, so there is nothing else to pin.
8+
#
9+
# No-ops when Cargo.toml already carries the target version, which keeps
10+
# re-running a stage idempotent.
11+
12+
set -euo pipefail
13+
14+
VERSION="${1:?usage: stamp_version.sh <version>}"
15+
16+
CURRENT=$(cargo metadata --no-deps --format-version=1 \
17+
| jq -r '.packages[] | select(.name == "pagedb") | .version')
18+
19+
if [[ "$VERSION" == "$CURRENT" ]]; then
20+
echo "Version already $VERSION — nothing to stamp."
21+
exit 0
22+
fi
23+
24+
# First `version = "..."` in the file is [package].
25+
perl -i -pe 'if (!$done && /^version = "/) { s/^version = ".*"/version = "'"$VERSION"'"/; $done=1 }' Cargo.toml
26+
27+
echo "Stamped package version: $CURRENT -> $VERSION"

0 commit comments

Comments
 (0)