Skip to content

Commit de4e834

Browse files
committed
build: add github workflow
1 parent b9d25ec commit de4e834

1 file changed

Lines changed: 88 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
build:
8+
name: Build — ${{ matrix.name }}
9+
runs-on: ${{ matrix.os }}
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
include:
14+
- name: Linux
15+
os: ubuntu-latest
16+
target: x86_64-unknown-linux-musl
17+
binary: proxy-checker
18+
artifact: proxy-checker-linux
19+
20+
- name: Windows
21+
os: windows-latest
22+
target: x86_64-pc-windows-msvc
23+
binary: proxy-checker.exe
24+
artifact: proxy-checker-windows
25+
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
30+
- name: Install Rust
31+
uses: dtolnay/rust-toolchain@stable
32+
with:
33+
targets: ${{ matrix.target }}
34+
35+
- name: Install musl-tools
36+
if: matrix.target == 'x86_64-unknown-linux-musl'
37+
run: sudo apt-get install -y musl-tools
38+
39+
- name: Cache
40+
uses: actions/cache@v4
41+
with:
42+
path: |
43+
~/.cargo/registry
44+
~/.cargo/git
45+
target
46+
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
47+
restore-keys: ${{ runner.os }}-cargo-
48+
49+
- name: Build
50+
run: cargo build --release --target ${{ matrix.target }}
51+
52+
- name: Upload artifact
53+
uses: actions/upload-artifact@v4
54+
with:
55+
name: ${{ matrix.artifact }}
56+
path: target/${{ matrix.target }}/release/${{ matrix.binary }}
57+
if-no-files-found: error
58+
59+
release:
60+
name: Release
61+
needs: build
62+
runs-on: ubuntu-latest
63+
if: startsWith(github.ref, 'refs/tags/v')
64+
permissions:
65+
contents: write
66+
67+
steps:
68+
- name: Download Linux binary
69+
uses: actions/download-artifact@v4
70+
with:
71+
name: proxy-checker-linux
72+
path: artifacts/linux
73+
74+
- name: Download Windows binary
75+
uses: actions/download-artifact@v4
76+
with:
77+
name: proxy-checker-windows
78+
path: artifacts/windows
79+
80+
- name: Mark Linux binary executable
81+
run: chmod +x artifacts/linux/proxy-checker
82+
83+
- name: Create GitHub Release
84+
uses: softprops/action-gh-release@v2
85+
with:
86+
files: |
87+
artifacts/linux/proxy-checker
88+
artifacts/windows/proxy-checker.exe

0 commit comments

Comments
 (0)