@@ -3,7 +3,7 @@ name: Release
33on :
44 push :
55 tags :
6- - ' v* '
6+ - " v* "
77
88permissions :
99 contents : write
@@ -14,21 +14,21 @@ jobs:
1414 runs-on : ubuntu-latest
1515 steps :
1616 - uses : actions/checkout@v4
17-
17+
1818 - name : Extract version from tag
1919 id : tag_version
2020 run : |
2121 TAG="${GITHUB_REF#refs/tags/v}"
2222 echo "version=$TAG" >> $GITHUB_OUTPUT
2323 echo "Tag version: $TAG"
24-
24+
2525 - name : Extract version from Cargo.toml
2626 id : cargo_version
2727 run : |
2828 CARGO_VERSION=$(grep '^version = ' Cargo.toml | head -1 | cut -d'"' -f2)
2929 echo "version=$CARGO_VERSION" >> $GITHUB_OUTPUT
3030 echo "Cargo.toml version: $CARGO_VERSION"
31-
31+
3232 - name : Validate versions match
3333 run : |
3434 if [ "${{ steps.tag_version.outputs.version }}" != "${{ steps.cargo_version.outputs.version }}" ]; then
3737 fi
3838 echo "Version validation passed: ${{ steps.tag_version.outputs.version }}"
3939
40+ test :
41+ name : Run tests before release
42+ needs : validate
43+ runs-on : ubuntu-latest
44+ steps :
45+ - uses : actions/checkout@v4
46+
47+ - name : Install Rust
48+ uses : dtolnay/rust-toolchain@stable
49+
50+ - name : Run tests
51+ run : cargo test --all-features
52+
53+ - name : Run clippy
54+ run : |
55+ rustup component add clippy
56+ cargo clippy --all-features -- -D warnings
57+
4058 build :
4159 name : Build ${{ matrix.target }}
42- needs : validate
60+ needs : test
4361 runs-on : ${{ matrix.os }}
4462 strategy :
4563 matrix :
@@ -56,37 +74,37 @@ jobs:
5674 - os : windows-latest
5775 target : x86_64-pc-windows-msvc
5876 archive_name : cage-${{ github.ref_name }}-windows-x86_64.zip
59-
77+
6078 steps :
6179 - uses : actions/checkout@v4
62-
80+
6381 - name : Install Rust
6482 uses : dtolnay/rust-toolchain@stable
6583 with :
6684 targets : ${{ matrix.target }}
67-
68- - name : Install musl tools (Linux)
85+
86+ - name : Install dependencies (Linux)
6987 if : matrix.target == 'x86_64-unknown-linux-musl'
7088 run : |
7189 sudo apt-get update
7290 sudo apt-get install -y musl-tools
73-
91+
7492 - name : Build
7593 run : cargo build --release --target ${{ matrix.target }}
76-
94+
7795 - name : Create archive (Unix)
7896 if : runner.os != 'Windows'
7997 run : |
8098 cd target/${{ matrix.target }}/release
8199 zip ../../../${{ matrix.archive_name }} cage
82-
100+
83101 - name : Create archive (Windows)
84102 if : runner.os == 'Windows'
85103 shell : pwsh
86104 run : |
87105 cd target/${{ matrix.target }}/release
88106 Compress-Archive -Path cage.exe -DestinationPath ../../../${{ matrix.archive_name }}
89-
107+
90108 - name : Upload artifact
91109 uses : actions/upload-artifact@v4
92110 with :
@@ -99,35 +117,35 @@ jobs:
99117 runs-on : ubuntu-latest
100118 steps :
101119 - uses : actions/checkout@v4
102-
120+
103121 - name : Download all artifacts
104122 uses : actions/download-artifact@v4
105123 with :
106124 path : artifacts
107-
125+
108126 - name : Prepare release files
109127 run : |
110128 mkdir release-files
111129 find artifacts -name "*.zip" -exec cp {} release-files/ \;
112130 ls -lh release-files/
113-
131+
114132 - name : Extract changelog for this version
115133 id : changelog
116134 run : |
117135 VERSION="${GITHUB_REF#refs/tags/v}"
118136 echo "Extracting changelog for version $VERSION"
119-
137+
120138 # Extract the section between this version and the next one
121139 CHANGELOG=$(awk "/## $VERSION/,/## [0-9]/" CHANGELOG.md | sed '1d;$d')
122-
140+
123141 # If empty, use a default message
124142 if [ -z "$CHANGELOG" ]; then
125143 CHANGELOG="Release $VERSION"
126144 fi
127-
145+
128146 # Save to file for multi-line handling
129147 echo "$CHANGELOG" > changelog.txt
130-
148+
131149 - name : Create Release
132150 uses : softprops/action-gh-release@v2
133151 with :
@@ -137,4 +155,3 @@ jobs:
137155 prerelease : false
138156 env :
139157 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
140-
0 commit comments