1+ name : Build and Release
2+
3+ on :
4+ push :
5+ branches : [ main ]
6+ tags : [ 'v*' ]
7+ pull_request :
8+ branches : [ main ]
9+
10+ env :
11+ CARGO_TERM_COLOR : always
12+
13+ jobs :
14+ build :
15+ name : Build for ${{ matrix.os }}
16+ runs-on : ${{ matrix.os }}
17+ strategy :
18+ matrix :
19+ include :
20+ - os : windows-latest
21+ target : x86_64-pc-windows-msvc
22+ executable_suffix : .exe
23+ artifact_name : tl-windows-x64
24+ - os : ubuntu-latest
25+ target : x86_64-unknown-linux-gnu
26+ executable_suffix : " "
27+ artifact_name : tl-linux-x64
28+ - os : macos-latest
29+ target : x86_64-apple-darwin
30+ executable_suffix : " "
31+ artifact_name : tl-macos-x64
32+
33+ steps :
34+ - uses : actions/checkout@v4
35+
36+ - name : Install Rust
37+ uses : dtolnay/rust-toolchain@stable
38+ with :
39+ targets : ${{ matrix.target }}
40+
41+ - name : Cache cargo registry
42+ uses : actions/cache@v4
43+ with :
44+ path : |
45+ ~/.cargo/registry
46+ ~/.cargo/git
47+ target
48+ key : ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
49+ restore-keys : |
50+ ${{ runner.os }}-cargo-
51+
52+ - name : Build release binary
53+ run : cargo build --release --target ${{ matrix.target }}
54+
55+ - name : Create artifact directory
56+ shell : bash
57+ run : |
58+ mkdir -p artifacts
59+ cp target/${{ matrix.target }}/release/tl${{ matrix.executable_suffix }} artifacts/
60+ cp README.md artifacts/
61+ cp Cargo.toml artifacts/
62+
63+ - name : Upload artifact
64+ uses : actions/upload-artifact@v4
65+ with :
66+ name : ${{ matrix.artifact_name }}
67+ path : artifacts/
68+
69+ release :
70+ name : Create Release
71+ needs : build
72+ runs-on : ubuntu-latest
73+ if : startsWith(github.ref, 'refs/tags/v')
74+
75+ steps :
76+ - name : Download all artifacts
77+ uses : actions/download-artifact@v4
78+ with :
79+ path : artifacts
80+
81+ - name : Create zip files
82+ run : |
83+ cd artifacts
84+ for dir in */; do
85+ zip -r "${dir%/}.zip" "$dir"
86+ done
87+
88+ - name : Create Release
89+ uses : softprops/action-gh-release@v1
90+ with :
91+ files : artifacts/*.zip
92+ generate_release_notes : true
93+ env :
94+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments