Skip to content

Commit 3160ed1

Browse files
committed
ci: test release
1 parent e93dff4 commit 3160ed1

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

.github/workflows/release.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
build-and-release:
13+
name: Build & Release (${{ matrix.os }})
14+
runs-on: ${{ matrix.os }}
15+
16+
strategy:
17+
matrix:
18+
include:
19+
- os: ubuntu-latest
20+
target: x86_64-unknown-linux-gnu
21+
artifact_ext: tar.gz
22+
archive_cmd: tar -czvf
23+
binary_ext: ""
24+
- os: windows-latest
25+
target: x86_64-pc-windows-msvc
26+
artifact_ext: zip
27+
archive_cmd: powershell Compress-Archive -Path
28+
binary_ext: ".exe"
29+
30+
steps:
31+
- name: Checkout source
32+
uses: actions/checkout@v4
33+
34+
- name: Install Rust
35+
uses: dtolnay/rust-toolchain@stable
36+
37+
- name: Build release binary
38+
run: cargo build --release --target ${{ matrix.target }}
39+
40+
- name: Prepare release assets
41+
run: |
42+
mkdir release
43+
cp README.md release/
44+
if [ "${{ matrix.os }}" = "Windows_NT" ]; then
45+
# This block is only used on Windows runners
46+
powershell Copy-Item "target\\${{ matrix.target }}\\release\\magnet.exe" release\\
47+
powershell Compress-Archive -Path release\\* -DestinationPath magnet-${{ github.ref_name }}-windows-x86_64.zip
48+
else
49+
cp target/${{ matrix.target }}/release/magnet release/
50+
tar -czvf magnet-${{ github.ref_name }}-linux-x86_64.tar.gz -C release .
51+
fi
52+
shell: bash
53+
54+
- name: Upload release asset
55+
uses: softprops/action-gh-release@v2
56+
with:
57+
files: |
58+
magnet-${{ github.ref_name }}-linux-x86_64.tar.gz
59+
magnet-${{ github.ref_name }}-windows-x86_64.zip
60+
env:
61+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62+
if: matrix.os == 'ubuntu-latest' # upload only once (after linux build)

0 commit comments

Comments
 (0)