@@ -2,16 +2,44 @@ name: Release
22
33on :
44 push :
5- # Only run on tag pushes like v1.2.3
65 tags :
76 - ' v*'
87
98permissions :
109 contents : write
1110
1211jobs :
13- build-and-publish :
14- name : Build & Publish Release
12+ # ───────────────────────────────────────────────────────────────────────────
13+ # 1. Setup & Cache Dependencies
14+ # ───────────────────────────────────────────────────────────────────────────
15+ setup :
16+ name : Setup & Cache Dependencies
17+ runs-on : ubuntu-latest
18+ outputs :
19+ cache-hit : ${{ steps.cache-deps.outputs.cache-hit }}
20+ steps :
21+ - uses : actions/checkout@v4
22+
23+ - name : Cache Rust registry
24+ id : cache-deps
25+ uses : actions/cache@v4
26+ with :
27+ path : |
28+ ~/.cargo/registry
29+ ~/.cargo/git
30+ key : cargo-deps-${{ hashFiles('**/Cargo.lock') }}
31+ restore-keys : cargo-deps-
32+
33+ - name : Install Rust toolchain
34+ if : steps.cache-deps.outputs.cache-hit != 'true'
35+ uses : dtolnay/rust-toolchain@stable
36+
37+ # ───────────────────────────────────────────────────────────────────────────
38+ # 2. Build & Upload Artifacts
39+ # ───────────────────────────────────────────────────────────────────────────
40+ build :
41+ name : Build Binaries & Upload Artifacts
42+ needs : setup
1543 runs-on : ${{ matrix.os }}
1644 strategy :
1745 matrix :
@@ -27,49 +55,46 @@ jobs:
2755 ext : " .exe"
2856
2957 steps :
30- # 1. Checkout
31- - name : Checkout repository
32- uses : actions/checkout@v4
58+ - uses : actions/checkout@v4
3359
34- # 2. Rust toolchain
35- - name : Install Rust (stable)
36- uses : dtolnay/rust-toolchain@stable
60+ - name : Restore Rust cache
61+ uses : actions/cache@v4
3762 with :
38- targets : ${{ matrix.target }}
63+ path : |
64+ ~/.cargo/registry
65+ ~/.cargo/git
66+ key : cargo-deps-${{ hashFiles('**/Cargo.lock') }}
67+ restore-keys : cargo-deps-
3968
40- # 3. Build
4169 - name : Build release binary
4270 run : cargo build --release --target ${{ matrix.target }}
4371
44- # 4. Prepare dist/
4572 - name : Create dist directory
4673 run : mkdir -p dist
4774
48- - name : Copy & rename binary (Linux/macOS)
75+ - name : Copy binary (Linux/macOS)
4976 if : runner.os != 'Windows'
5077 run : |
5178 cp target/${{ matrix.target }}/release/favis${{ matrix.ext }} \
5279 dist/favis-${{ matrix.target }}${{ matrix.ext }}
5380
54- - name : Copy & rename binary (Windows)
81+ - name : Copy binary (Windows)
5582 if : runner.os == 'Windows'
5683 shell : pwsh
57- run : |
58- Copy-Item -Path "target\${{ matrix.target }}\release\favis${{ matrix.ext }}" `
59- -Destination "dist\favis-${{ matrix.target }}${{ matrix.ext }}"
84+ run : Copy-Item -Path "target\\${{ matrix.target }}\\release\\favis${{ matrix.ext }}" `
85+ -Destination "dist\\favis-${{ matrix.target }}${{ matrix.ext }}"
6086
61- # 5. Checksums
6287 - name : Generate SHA256 checksum (Linux)
6388 if : runner.os == 'Linux'
6489 working-directory : dist
6590 run : sha256sum favis-${{ matrix.target }}${{ matrix.ext }} \
66- > favis-${{ matrix.target }}${{ matrix.ext }}.sha256
91+ > favis-${{ matrix.target }}${{ matrix.ext }}.sha256
6792
6893 - name : Generate SHA256 checksum (macOS)
6994 if : runner.os == 'macOS'
7095 working-directory : dist
7196 run : shasum -a 256 favis-${{ matrix.target }}${{ matrix.ext }} \
72- > favis-${{ matrix.target }}${{ matrix.ext }}.sha256
97+ > favis-${{ matrix.target }}${{ matrix.ext }}.sha256
7398
7499 - name : Generate SHA256 checksum (Windows)
75100 if : runner.os == 'Windows'
@@ -80,17 +105,45 @@ jobs:
80105 $hash = (Get-FileHash -Algorithm SHA256 $file).Hash.ToLower()
81106 "$hash *$file" | Out-File -Encoding utf8 "$file.sha256"
82107
83- # 6. Create or Update Release & Upload
108+ - name : Upload build artifacts
109+ uses : actions/upload-artifact@v4
110+ with :
111+ name : build-dist-${{ matrix.os }}
112+ path : dist/
113+
114+ # ───────────────────────────────────────────────────────────────────────────
115+ # 3. Publish Release & Assets
116+ # ───────────────────────────────────────────────────────────────────────────
117+ publish :
118+ name : Publish Release & Upload Assets
119+ needs : build
120+ runs-on : ubuntu-latest
121+ steps :
122+ - uses : actions/download-artifact@v4
123+ with :
124+ name : build-dist-ubuntu-latest
125+ path : dist-linux
126+
127+ - uses : actions/download-artifact@v4
128+ with :
129+ name : build-dist-macos-latest
130+ path : dist-macos
131+
132+ - uses : actions/download-artifact@v4
133+ with :
134+ name : build-dist-windows-latest
135+ path : dist-windows
136+
84137 - name : Publish Release & Upload Assets
85138 uses : softprops/action-gh-release@v2
86139 with :
87- # token supports create or update of existing release
88- token : ${{ secrets.GITHUB_TOKEN }}
89- tag_name : ${{ github.ref_name }}
90- name : ${{ github.ref_name }}
91- make_latest : true
140+ token : ${{ secrets.GITHUB_TOKEN }}
141+ tag_name : ${{ github.ref_name }}
142+ name : ${{ github.ref_name }}
143+ make_latest : true
92144 files : |
93- dist/favis-${{ matrix.target }}${{ matrix.ext }}
94- dist/favis-${{ matrix.target }}${{ matrix.ext }}.sha256
145+ dist-linux/*
146+ dist-macos/*
147+ dist-windows/*
95148 generate_release_notes : true
96149 fail_on_unmatched_files : true
0 commit comments