Skip to content

Commit 3b4dd3a

Browse files
committed
feat[build]: Rearchitect release workflow
This makes the following changes: - Creates a new "release" workflow that re-uses the CIDCD workflow for build steps. This allows us to avoid having to check if it is a release in several steps. - Remove dependency on third party action for release, and uses the `gh` command directly. - Automatically generates release notes from the changelog.
1 parent 15b57b9 commit 3b4dd3a

3 files changed

Lines changed: 77 additions & 42 deletions

File tree

.github/workflows/CICD.yml

Lines changed: 20 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@ env:
66

77
on:
88
workflow_dispatch:
9+
workflow_call:
10+
inputs:
11+
release_version:
12+
description: 'Tag of the release to create'
13+
required: false
14+
type: string
915
pull_request:
1016
push:
1117
branches:
1218
- master
13-
tags:
14-
- '*'
1519

1620
permissions:
1721
contents: read
@@ -134,10 +138,18 @@ jobs:
134138

135139
- name: Install cross
136140
if: matrix.job.use-cross
137-
uses: taiki-e/install-action@6f9c7cc51aa54b13cbcbd12f8bbf69d8ba405b4b # v2.62.47
138-
with:
139-
tool: cross
140-
141+
env:
142+
cross_version: "v0.2.5"
143+
package_name: "cross-x86_64-unknown-linux-gnu.tar.gz"
144+
run: |
145+
dir="$HOME/.local/bin/"
146+
mkdir "$dir"
147+
cd "$dir"
148+
gh release download --repo cross-rs/cross \
149+
--pattern "${package_name}" -o - "${cross_version}" \
150+
| tar xz
151+
echo "$dir" >> $GITHUB_PATH
152+
echo "Installed cross $cross_version" >> $GITHUB_STEP_SUMMARY
141153
- name: Show version information (Rust, cargo, GCC)
142154
shell: bash
143155
run: |
@@ -260,45 +272,16 @@ jobs:
260272
name: ${{ steps.debian-package.outputs.DPKG_NAME }}
261273
path: ${{ steps.debian-package.outputs.DPKG_PATH }}
262274

263-
- name: Check for release
264-
id: is-release
265-
shell: bash
266-
run: |
267-
unset IS_RELEASE ; if [[ $GITHUB_REF =~ ^refs/tags/v[0-9].* ]]; then IS_RELEASE='true' ; fi
268-
echo "IS_RELEASE=${IS_RELEASE}" >> $GITHUB_OUTPUT
269-
270275
- name: "Attest artifact: tarball"
271276
uses: actions/attest-build-provenance@v3
272-
if: steps.is-release.outputs.IS_RELEASE
277+
if: inputs.release_version
273278
with:
274279
subject-name: ${{ steps.package.outputs.PKG_NAME }}
275280
subject-digest: sha256::${{ steps.upload-tarball.artifact-digest }}
276281

277282
- name: "Attest artifact: Debian package"
278283
uses: actions/attest-build-provenance@v3
279-
if: 'steps.is-release.outputs.IS_RELEASE && steps.debian-package.outputs.DPKG_NAME'
284+
if: 'inputs.release_version && steps.debian-package.outputs.DPKG_NAME'
280285
with:
281286
subject-name: ${{ steps.debian-package.outputs.DPKG_NAME }}
282287
subject-digest: sha256::${{ steps.upload-deb.outputs.artifact-digest }}
283-
284-
- name: Publish archives and packages
285-
uses: softprops/action-gh-release@6da8fa9354ddfdc4aeace5fc48d7f679b5214090 # v2.4.1
286-
if: steps.is-release.outputs.IS_RELEASE
287-
with:
288-
files: |
289-
${{ steps.package.outputs.PKG_PATH }}
290-
${{ steps.debian-package.outputs.DPKG_PATH }}
291-
env:
292-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
293-
294-
winget:
295-
name: Publish to Winget
296-
runs-on: ubuntu-latest
297-
needs: build
298-
if: startsWith(github.ref, 'refs/tags/v')
299-
steps:
300-
- uses: vedantmgoyal9/winget-releaser@4ffc7888bffd451b357355dc214d43bb9f23917e # v2
301-
with:
302-
identifier: sharkdp.fd
303-
installers-regex: '-pc-windows-msvc\.zip$'
304-
token: ${{ secrets.WINGET_TOKEN }}

.github/workflows/release.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: read
10+
11+
env:
12+
VERSION: "${{ github.ref_name }}"
13+
14+
jobs:
15+
build:
16+
uses: ./.github/workflows/CICD.yml
17+
with:
18+
release_version: "${{ github.ref_name }}"
19+
20+
publish:
21+
name: Publish Release
22+
needs: build
23+
permissions:
24+
contents: write
25+
steps:
26+
- name: Download Artifacts
27+
uses: actions/download-artifact@v6
28+
with:
29+
merge-multiple: true
30+
path: artifacts
31+
- name: Get CHANGELOG
32+
uses: actions/checkout@v5
33+
with:
34+
persist-credentials: false
35+
sparse-checkout: CHANGLEOG.md
36+
- name: Generate Release Notes
37+
run: |
38+
awk '/^# / { if (p) { exit }; p=1; next } p' CHANGELOG.md > notes.md
39+
- name: Publish Release
40+
run: |
41+
gh release create --notes-file notes.md \
42+
--verify-tag "${VERSION}" artifacts/*
43+
44+
winget:
45+
name: Publish to Winget
46+
runs-on: ubuntu-latest
47+
needs: publish
48+
steps:
49+
- uses: vedantmgoyal9/winget-releaser@4ffc7888bffd451b357355dc214d43bb9f23917e # v2
50+
with:
51+
identifier: sharkdp.fd
52+
installers-regex: '-pc-windows-msvc\.zip$'
53+
token: ${{ secrets.WINGET_TOKEN }}
54+

doc/release-checklist.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,9 @@ necessary changes for the upcoming release.
3636
This will trigger the deployment via GitHub Actions.
3737
REMINDER: If your `origin` is a fork, don't forget to push to e.g. `upstream`
3838
instead.
39-
- [ ] Go to https://github.com/sharkdp/fd/releases/new to create the new
40-
release. Select the new tag and also use it as the release title. For the
41-
release notes, copy the corresponding section from `CHANGELOG.md` and
42-
possibly add additional remarks for package maintainers.
43-
Publish the release.
39+
- [ ] Go to https://github.com/sharkdp/fd/releases to create the new
40+
release and wait for the new release to finish (creating the tag will automatically
41+
create a new release). If necessary, make any adjustments to the release notes.
4442
- [ ] Check if the binary deployment works (archives and Debian packages should
4543
appear when the CI run *for the Git tag* has finished).
4644
- [ ] Publish to crates.io by running `cargo publish` in a *clean* repository.

0 commit comments

Comments
 (0)