11name : Auto Build Release
2-
32on :
43 push :
54 tags :
65 - " v*"
7-
86permissions :
97 contents : write
108 packages : write
11-
129env :
1310 CARGO_TERM_COLOR : always
14-
11+ CARGO_INCREMENTAL : 0
12+ RUSTFLAGS : " -C codegen-units=1 -C strip=symbols"
1513jobs :
1614 build :
1715 name : Build ${{ matrix.target }}
@@ -21,20 +19,14 @@ jobs:
2119 include :
2220 - target : x86_64-unknown-linux-gnu
2321 os : ubuntu-latest
24- format : tar.gz
2522 - target : aarch64-unknown-linux-gnu
2623 os : ubuntu-latest
27- format : tar.gz
2824 - target : x86_64-pc-windows-msvc
2925 os : windows-latest
30- format : zip
3126 - target : x86_64-apple-darwin
3227 os : macos-latest
33- format : tar.gz
3428 - target : aarch64-apple-darwin
3529 os : macos-latest
36- format : tar.gz
37-
3830 steps :
3931 - uses : actions/checkout@v4
4032
@@ -45,23 +37,34 @@ jobs:
4537
4638 - uses : Swatinem/rust-cache@v2
4739 with :
40+ prefix-key : release
4841 key : ${{ matrix.target }}
4942 cache-on-failure : true
5043
44+ - name : Cache cargo tools
45+ uses : actions/cache@v4
46+ if : matrix.target == 'x86_64-unknown-linux-gnu'
47+ with :
48+ path : ~/.cargo/bin
49+ key : cargo-tools-${{ runner.os }}-deb-rpm
50+ restore-keys : cargo-tools-${{ runner.os }}-
51+
5152 - name : Install cross-compilation tools
5253 if : matrix.target == 'aarch64-unknown-linux-gnu'
5354 run : |
5455 sudo apt-get update
5556 sudo apt-get install -y gcc-aarch64-linux-gnu
5657 echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
5758
58- - name : Install cargo-deb
59+ - name : Install cargo tools
5960 if : matrix.target == 'x86_64-unknown-linux-gnu'
60- run : cargo install cargo-deb
61-
62- - name : Install cargo-generate-rpm
63- if : matrix.target == 'x86_64-unknown-linux-gnu'
64- run : cargo install cargo-generate-rpm
61+ run : |
62+ if ! command -v cargo-deb &> /dev/null; then
63+ cargo install cargo-deb
64+ fi
65+ if ! command -v cargo-generate-rpm &> /dev/null; then
66+ cargo install cargo-generate-rpm
67+ fi
6568
6669 - name : Build
6770 run : cargo build --release --target ${{ matrix.target }}
@@ -73,22 +76,19 @@ jobs:
7376 echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
7477 shell : bash
7578
76- - name : Create generic archive (Unix)
77- if : runner.os != 'Windows'
79+ - name : Create archives and packages
7880 run : |
7981 cd target/${{ matrix.target }}/release
80- tar czf ../../../${{ steps.crate_info.outputs.name }}-${{ matrix.target }}-${{ steps.crate_info.outputs.version }}.tar.gz ${{ steps.crate_info.outputs.name }}
81-
82- - name : Create generic archive (Windows)
83- if : runner.os == 'Windows'
84- run : |
85- cd target/${{ matrix.target }}/release
86- 7z a ../../../${{ steps.crate_info.outputs.name }}-${{ matrix.target }}-${{ steps.crate_info.outputs.version }}.zip ${{ steps.crate_info.outputs.name }}.exe
87-
88- - name : Create Windows executable
89- if : runner.os == 'Windows'
90- run : |
91- cp target/${{ matrix.target }}/release/${{ steps.crate_info.outputs.name }}.exe ${{ steps.crate_info.outputs.name }}-${{ matrix.target }}-${{ steps.crate_info.outputs.version }}.exe
82+ case "${{ runner.os }}" in
83+ "Windows")
84+ 7z a ../../../${{ steps.crate_info.outputs.name }}-${{ matrix.target }}-${{ steps.crate_info.outputs.version }}.zip ${{ steps.crate_info.outputs.name }}.exe
85+ cp ${{ steps.crate_info.outputs.name }}.exe ../../../${{ steps.crate_info.outputs.name }}-${{ matrix.target }}-${{ steps.crate_info.outputs.version }}.exe
86+ ;;
87+ *)
88+ tar czf ../../../${{ steps.crate_info.outputs.name }}-${{ matrix.target }}-${{ steps.crate_info.outputs.version }}.tar.gz ${{ steps.crate_info.outputs.name }}
89+ ;;
90+ esac
91+ shell : bash
9292
9393 - name : Create DEB package
9494 if : matrix.target == 'x86_64-unknown-linux-gnu'
@@ -112,41 +112,27 @@ jobs:
112112 *.exe
113113 *.deb
114114 *.rpm
115+ retention-days : 1
115116
116117 release :
117118 needs : build
118119 runs-on : ubuntu-latest
119120 steps :
120121 - uses : actions/checkout@v4
121-
122122 - name : Download artifacts
123123 uses : actions/download-artifact@v4
124124 with :
125125 path : artifacts
126-
127126 - name : Get crate info
128127 id : crate_info
129128 run : |
130129 echo "name=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].name')" >> $GITHUB_OUTPUT
131130 echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
132-
133131 - name : Create release
134132 uses : softprops/action-gh-release@v1
135133 with :
136134 files : artifacts/**/*
137135 name : " v${{ steps.crate_info.outputs.version }}"
138- body : |
139- ## Installation
140-
141- | System / Distribution | File | Description |
142- |:----------------------|:-----|:------------|
143- | **Generic Linux** | [${{ steps.crate_info.outputs.name }}-x86_64-unknown-linux-gnu-${{ steps.crate_info.outputs.version }}.tar.gz](https://github.com/${{ github.repository }}/releases/download/v${{ steps.crate_info.outputs.version }}/${{ steps.crate_info.outputs.name }}-x86_64-unknown-linux-gnu-${{ steps.crate_info.outputs.version }}.tar.gz) | Extract and run the binary |
144- | **Debian / Ubuntu** | [${{ steps.crate_info.outputs.name }}-${{ steps.crate_info.outputs.version }}-amd64.deb](https://github.com/${{ github.repository }}/releases/download/v${{ steps.crate_info.outputs.version }}/${{ steps.crate_info.outputs.name }}-${{ steps.crate_info.outputs.version }}-amd64.deb) | Install using `dpkg -i` |
145- | **Fedora / CentOS / openSUSE** | [${{ steps.crate_info.outputs.name }}-${{ steps.crate_info.outputs.version }}-1.x86_64.rpm](https://github.com/${{ github.repository }}/releases/download/v${{ steps.crate_info.outputs.version }}/${{ steps.crate_info.outputs.name }}-${{ steps.crate_info.outputs.version }}-1.x86_64.rpm) | Install using `rpm -i` or `dnf install` |
146- | **Windows** | [${{ steps.crate_info.outputs.name }}-x86_64-pc-windows-msvc-${{ steps.crate_info.outputs.version }}.exe](https://github.com/${{ github.repository }}/releases/download/v${{ steps.crate_info.outputs.version }}/${{ steps.crate_info.outputs.name }}-x86_64-pc-windows-msvc-${{ steps.crate_info.outputs.version }}.exe) | Standalone executable |
147- | **Windows (Archive)** | [${{ steps.crate_info.outputs.name }}-x86_64-pc-windows-msvc-${{ steps.crate_info.outputs.version }}.zip](https://github.com/${{ github.repository }}/releases/download/v${{ steps.crate_info.outputs.version }}/${{ steps.crate_info.outputs.name }}-x86_64-pc-windows-msvc-${{ steps.crate_info.outputs.version }}.zip) | Extract and run |
148- | **macOS Intel** | [${{ steps.crate_info.outputs.name }}-x86_64-apple-darwin-${{ steps.crate_info.outputs.version }}.tar.gz](https://github.com/${{ github.repository }}/releases/download/v${{ steps.crate_info.outputs.version }}/${{ steps.crate_info.outputs.name }}-x86_64-apple-darwin-${{ steps.crate_info.outputs.version }}.tar.gz) | Extract and run the binary |
149- | **macOS Apple Silicon** | [${{ steps.crate_info.outputs.name }}-aarch64-apple-darwin-${{ steps.crate_info.outputs.version }}.tar.gz](https://github.com/${{ github.repository }}/releases/download/v${{ steps.crate_info.outputs.version }}/${{ steps.crate_info.outputs.name }}-aarch64-apple-darwin-${{ steps.crate_info.outputs.version }}.tar.gz) | Extract and run the binary |
150136 generate_release_notes : true
151137 env :
152138 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments