44 push :
55 tags :
66 - " v*"
7- pull_request :
8- paths :
9- - " .github/workflows/release.yml"
10- - " Cross.toml"
11- - " Dockerfile.release"
12- - " Cargo.toml"
13- - " Cargo.lock"
14- - " src/**"
157
168concurrency :
179 group : release-${{ github.ref_name }}
18- cancel-in-progress : ${{ github.event_name == 'pull_request' }}
10+ cancel-in-progress : false
1911
2012env :
2113 CARGO_TERM_COLOR : always
3729 uses : Swatinem/rust-cache@v2
3830
3931 - name : Ensure tag matches Cargo.toml version
40- if : github.event_name == 'push'
4132 run : |
4233 expected_tag="v$(cargo pkgid | sed -E 's/.*@//')"
4334 if [ "${GITHUB_REF_NAME}" != "${expected_tag}" ]; then
4839 - name : Verify publishable package
4940 run : cargo publish --locked --dry-run
5041
51- # ── 2. Build release binaries (PR: verify only, tag: full build) ───
42+ # ── 2. Publish crate to crates.io ───────────────────────────────────
43+ publish-crate :
44+ runs-on : ubuntu-latest
45+ needs : verify
46+ permissions :
47+ contents : read
48+ id-token : write
49+ env :
50+ HAS_CARGO_REGISTRY_TOKEN : ${{ secrets.CARGO_REGISTRY_TOKEN != '' }}
51+ steps :
52+ - name : Checkout
53+ uses : actions/checkout@v6
54+
55+ - name : Install Rust
56+ uses : dtolnay/rust-toolchain@stable
57+
58+ - name : Cache cargo artifacts
59+ uses : Swatinem/rust-cache@v2
60+
61+ - name : Authenticate to crates.io with trusted publishing
62+ if : env.HAS_CARGO_REGISTRY_TOKEN == 'false'
63+ id : crates-auth
64+ uses : rust-lang/crates-io-auth-action@v1
65+
66+ - name : Publish crate with API token
67+ if : env.HAS_CARGO_REGISTRY_TOKEN == 'true'
68+ run : cargo publish --locked
69+ env :
70+ CARGO_REGISTRY_TOKEN : ${{ secrets.CARGO_REGISTRY_TOKEN }}
71+
72+ - name : Publish crate with trusted publishing
73+ if : env.HAS_CARGO_REGISTRY_TOKEN == 'false'
74+ run : cargo publish --locked
75+ env :
76+ CARGO_REGISTRY_TOKEN : ${{ steps.crates-auth.outputs.token }}
77+
78+ # ── 2b. Build release binaries ──────────────────────────────────────
5279 build-binaries :
5380 needs : verify
5481 strategy :
@@ -100,7 +127,6 @@ jobs:
100127 run : ${{ matrix.cross && 'cross' || 'cargo' }} build --release --locked --target ${{ matrix.target }} --features "s3,gcs,azure"
101128
102129 - name : Determine binary path
103- if : startsWith(github.ref, 'refs/tags/')
104130 id : bin
105131 shell : bash
106132 run : |
@@ -113,30 +139,29 @@ jobs:
113139 fi
114140
115141 - name : Strip binary (Linux/macOS)
116- if : startsWith(github.ref, 'refs/tags/') && matrix.os != 'windows-latest' && !matrix.cross
142+ if : matrix.os != 'windows-latest' && !matrix.cross
117143 run : strip ${{ steps.bin.outputs.path }}
118144
119145 - name : Strip binary (cross aarch64)
120- if : startsWith(github.ref, 'refs/tags/') && matrix.target == 'aarch64-unknown-linux-gnu'
146+ if : matrix.target == 'aarch64-unknown-linux-gnu'
121147 run : aarch64-linux-gnu-strip ${{ steps.bin.outputs.path }}
122148
123149 - name : Create archive (tar.gz)
124- if : startsWith(github.ref, 'refs/tags/') && matrix.archive == 'tar.gz'
150+ if : matrix.archive == 'tar.gz'
125151 run : |
126152 archive_name="truss-${GITHUB_REF_NAME}-${{ matrix.target }}.tar.gz"
127153 tar czf "${archive_name}" -C "$(dirname ${{ steps.bin.outputs.path }})" ${{ steps.bin.outputs.name }}
128154 echo "ARCHIVE=${archive_name}" >> "$GITHUB_ENV"
129155
130156 - name : Create archive (zip)
131- if : startsWith(github.ref, 'refs/tags/') && matrix.archive == 'zip'
157+ if : matrix.archive == 'zip'
132158 shell : bash
133159 run : |
134160 archive_name="truss-${GITHUB_REF_NAME}-${{ matrix.target }}.zip"
135161 (cd "$(dirname "${{ steps.bin.outputs.path }}")" && 7z a "${GITHUB_WORKSPACE}/${archive_name}" "${{ steps.bin.outputs.name }}")
136162 echo "ARCHIVE=${archive_name}" >> "$GITHUB_ENV"
137163
138164 - name : Generate checksum
139- if : startsWith(github.ref, 'refs/tags/')
140165 shell : bash
141166 run : |
142167 if [ "${{ matrix.os }}" = "macos-latest" ]; then
@@ -146,54 +171,15 @@ jobs:
146171 fi
147172
148173 - name : Upload artifacts
149- if : startsWith(github.ref, 'refs/tags/')
150174 uses : actions/upload-artifact@v7
151175 with :
152176 name : binary-${{ matrix.target }}
153177 path : |
154178 ${{ env.ARCHIVE }}
155179 ${{ env.ARCHIVE }}.sha256
156180
157- # ── 3. Publish crate to crates.io (tag push only) ──────────────────
158- publish-crate :
159- if : startsWith(github.ref, 'refs/tags/')
160- runs-on : ubuntu-latest
161- needs : verify
162- permissions :
163- contents : read
164- id-token : write
165- env :
166- HAS_CARGO_REGISTRY_TOKEN : ${{ secrets.CARGO_REGISTRY_TOKEN != '' }}
167- steps :
168- - name : Checkout
169- uses : actions/checkout@v6
170-
171- - name : Install Rust
172- uses : dtolnay/rust-toolchain@stable
173-
174- - name : Cache cargo artifacts
175- uses : Swatinem/rust-cache@v2
176-
177- - name : Authenticate to crates.io with trusted publishing
178- if : env.HAS_CARGO_REGISTRY_TOKEN == 'false'
179- id : crates-auth
180- uses : rust-lang/crates-io-auth-action@v1
181-
182- - name : Publish crate with API token
183- if : env.HAS_CARGO_REGISTRY_TOKEN == 'true'
184- run : cargo publish --locked
185- env :
186- CARGO_REGISTRY_TOKEN : ${{ secrets.CARGO_REGISTRY_TOKEN }}
187-
188- - name : Publish crate with trusted publishing
189- if : env.HAS_CARGO_REGISTRY_TOKEN == 'false'
190- run : cargo publish --locked
191- env :
192- CARGO_REGISTRY_TOKEN : ${{ steps.crates-auth.outputs.token }}
193-
194- # ── 4. Build & push container image (tag push only) ────────────────
181+ # ── 3. Build & push container image ─────────────────────────────────
195182 publish-container :
196- if : startsWith(github.ref, 'refs/tags/')
197183 runs-on : ubuntu-latest
198184 needs : [publish-crate, build-binaries]
199185 permissions :
@@ -285,9 +271,8 @@ jobs:
285271 "${IMAGE}:${{ github.ref_name }}-amd64" \
286272 "${IMAGE}:${{ github.ref_name }}-arm64"
287273
288- # ── 5 . Create GitHub Release (tag push only) ───────────────────────
274+ # ── 4 . Create GitHub Release ───────────────── ───────────────────────
289275 create-release :
290- if : startsWith(github.ref, 'refs/tags/')
291276 runs-on : ubuntu-latest
292277 needs : [publish-container, build-binaries]
293278 permissions :
0 commit comments