Skip to content

Commit 1b36431

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 68fa2db commit 1b36431

3 files changed

Lines changed: 67 additions & 38 deletions

File tree

.github/workflows/CICD.yml

Lines changed: 8 additions & 33 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
@@ -268,45 +272,16 @@ jobs:
268272
name: ${{ steps.debian-package.outputs.DPKG_NAME }}
269273
path: ${{ steps.debian-package.outputs.DPKG_PATH }}
270274

271-
- name: Check for release
272-
id: is-release
273-
shell: bash
274-
run: |
275-
unset IS_RELEASE ; if [[ $GITHUB_REF =~ ^refs/tags/v[0-9].* ]]; then IS_RELEASE='true' ; fi
276-
echo "IS_RELEASE=${IS_RELEASE}" >> $GITHUB_OUTPUT
277-
278275
- name: "Attest artifact: tarball"
279276
uses: actions/attest-build-provenance@v3
280-
if: steps.is-release.outputs.IS_RELEASE
277+
if: inputs.release_version
281278
with:
282279
subject-name: ${{ steps.package.outputs.PKG_NAME }}
283280
subject-digest: sha256::${{ steps.upload-tarball.artifact-digest }}
284281

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

.github/workflows/release.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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+
env:
41+
GH_TOKEN: "${{ github.token }}"
42+
run: |
43+
gh release create --notes-file notes.md \
44+
--verify-tag "${VERSION}" artifacts/*
45+
46+
winget:
47+
name: Publish to Winget
48+
runs-on: ubuntu-latest
49+
needs: publish
50+
steps:
51+
- uses: vedantmgoyal9/winget-releaser@4ffc7888bffd451b357355dc214d43bb9f23917e # v2
52+
with:
53+
identifier: sharkdp.fd
54+
installers-regex: '-pc-windows-msvc\.zip$'
55+
token: ${{ secrets.WINGET_TOKEN }}
56+

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)