@@ -3,42 +3,117 @@ name: Release
33on :
44 push :
55 tags :
6- - v[0-9]+.*
7-
8- env :
9- CARGO_TERM_COLOR : always
6+ - ' v*'
107
118jobs :
12- create-release :
9+ extract-version :
1310 runs-on : ubuntu-latest
11+ outputs :
12+ version : ${{ steps.getver.outputs.version }}
13+ changelog : ${{ steps.changelog.outputs.changelog }}
1414 steps :
15- - uses : actions/checkout@v2
16- - uses : taiki-e/create-gh-release-action@v1
15+ - uses : actions/checkout@v4
16+
17+ - id : getver
18+ run : |
19+ # Extract version from the tag name (strip leading 'v')
20+ version="${GITHUB_REF##*/}"
21+ version="${version#v}"
22+ echo "version=$version" >> $GITHUB_OUTPUT
23+
24+ - id : changelog
25+ uses : mikepenz/release-changelog-builder-action@v5
26+ with :
27+ configuration : " .github/changelog-config.json"
1728 env :
1829 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
1930
20- upload-assets :
31+ release :
32+ needs : extract-version
2133 strategy :
2234 matrix :
23- os :
24- - ubuntu-latest
25- - macos-latest
26- - windows-latest
35+ include :
36+ - os : ubuntu-latest
37+ target : x86_64-unknown-linux-gnu
38+ archive_cmd : tar czf ice-x86_64-unknown-linux-gnu.tar.gz -C target/x86_64-unknown-linux-gnu/release ice
39+ asset_name : ice-x86_64-unknown-linux-gnu.tar.gz
40+ - os : macos-latest
41+ target : x86_64-apple-darwin
42+ archive_cmd : tar czf ice-x86_64-apple-darwin.tar.gz -C target/x86_64-apple-darwin/release ice
43+ asset_name : ice-x86_64-apple-darwin.tar.gz
44+ - os : windows-latest
45+ target : x86_64-pc-windows-msvc
46+ archive_cmd : 7z a ice-x86_64-pc-windows-msvc.zip target/x86_64-pc-windows-msvc/release/ice.exe
47+ asset_name : ice-x86_64-pc-windows-msvc.zip
48+
2749 runs-on : ${{ matrix.os }}
2850 steps :
29- - uses : actions/checkout@v2
30- - uses : taiki-e/upload-rust-binary-action@v1
51+ - uses : actions/checkout@v4
52+
53+ - name : Install Rust toolchain
54+ uses : dtolnay/rust-toolchain@stable
3155 with :
32- # (required)
33- bin : ice
34- # (optional) On which platform to distribute the `.tar.gz` file.
35- # [default value: unix]
36- # [possible values: all, unix, windows, none]
37- tar : unix
38- # (optional) On which platform to distribute the `.zip` file.
39- # [default value: windows]
40- # [possible values: all, unix, windows, none]
41- zip : windows
56+ targets : ${{ matrix.target }}
57+
58+ - name : Install UPX
59+ run : |
60+ if [ "$RUNNER_OS" == "Linux" ]; then
61+ sudo apt-get update && sudo apt-get install -y upx-ucl
62+ elif [ "$RUNNER_OS" == "macOS" ]; then
63+ brew install upx
64+ elif [ "$RUNNER_OS" == "Windows" ]; then
65+ choco install upx
66+ fi
67+ shell : bash
68+
69+ - name : Build binary
70+ run : cargo build --release --target ${{ matrix.target }} --bin ice
71+
72+ - name : Compress binary (Linux/Windows only)
73+ if : runner.os != 'macOS'
74+ run : |
75+ if [ "$RUNNER_OS" == "Windows" ]; then
76+ upx --best target/${{ matrix.target }}/release/ice.exe
77+ else
78+ upx --best target/${{ matrix.target }}/release/ice
79+ fi
80+ shell : bash
81+
82+ - name : Package binary
83+ run : ${{ matrix.archive_cmd }}
84+ shell : bash
85+
86+ - name : Create or Update Release
87+ uses : ncipollo/release-action@v1
88+ with :
89+ tag : v${{ needs.extract-version.outputs.version }}
90+ name : " Release v${{ needs.extract-version.outputs.version }}"
91+ body : ${{ needs.extract-version.outputs.changelog }}
92+ artifacts : ${{ matrix.asset_name }}
93+ allowUpdates : true
4294 env :
43- # (required)
4495 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
96+
97+ update-aur :
98+ needs : [extract-version, release]
99+ runs-on : ubuntu-latest
100+ steps :
101+ - uses : actions/checkout@v4
102+
103+ - name : Set AUR asset URL
104+ run : echo "ASSET_URL=https://github.com/${{ github.repository }}/releases/download/v${{ needs.extract-version.outputs.version }}/ice-x86_64-unknown-linux-gnu.tar.gz" >> $GITHUB_ENV
105+ shell : bash
106+
107+ - name : Update AUR package
108+ uses : ulises-jeremias/github-actions-aur-publish@v1
109+ with :
110+ pkgname : ice-bin
111+ commit_username : " github-actions[bot]"
112+ commit_email : " 41898282+github-actions[bot]@users.noreply.github.com"
113+ ssh_private_key : ${{ secrets.AUR_SSH_PRIVATE_KEY }}
114+ pkgbuild : ./PKGBUILD
115+ commit_message : " Update to v${{ needs.extract-version.outputs.version }}"
116+ ssh_keyscan_types : rsa,ecdsa,ed25519
117+ env :
118+ PKGVER : ${{ needs.extract-version.outputs.version }}
119+ PKGURL : ${{ env.ASSET_URL }}
0 commit comments