Skip to content

Commit bb34cde

Browse files
authored
Merge pull request #45 from nicoovh/feat/enable_ci_on_push
ci: enable binary build on push
2 parents a4e9863 + f05cbac commit bb34cde

File tree

2 files changed

+219
-0
lines changed

2 files changed

+219
-0
lines changed

.github/workflows/ci.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: CI Build
2+
3+
on:
4+
push:
5+
branches: [ dev/*, feature/*, fix/* ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build:
11+
name: Build for ${{ matrix.os }}
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
matrix:
15+
include:
16+
- os: ubuntu-latest
17+
target: x86_64-unknown-linux-musl
18+
binary_name: shai
19+
asset_name: shai-linux-x86_64
20+
- os: windows-latest
21+
target: x86_64-pc-windows-msvc
22+
binary_name: shai.exe
23+
asset_name: shai-windows-x86_64.exe
24+
- os: macos-latest
25+
target: x86_64-apple-darwin
26+
binary_name: shai
27+
asset_name: shai-macos-x86_64
28+
- os: macos-latest
29+
target: aarch64-apple-darwin
30+
binary_name: shai
31+
asset_name: shai-macos-aarch64
32+
33+
steps:
34+
- name: Checkout code
35+
uses: actions/checkout@v4
36+
37+
- name: Install Rust
38+
uses: dtolnay/rust-toolchain@stable
39+
with:
40+
targets: ${{ matrix.target }}
41+
42+
- name: Install dependencies (Linux)
43+
if: matrix.os == 'ubuntu-latest'
44+
run: |
45+
sudo apt-get update
46+
sudo apt-get install -y build-essential musl-tools
47+
48+
- name: Add musl target (Linux)
49+
if: matrix.target == 'x86_64-unknown-linux-musl'
50+
run: rustup target add x86_64-unknown-linux-musl
51+
52+
- name: Cache cargo registry
53+
uses: actions/cache@v4
54+
with:
55+
path: ~/.cargo/registry
56+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
57+
restore-keys: |
58+
${{ runner.os }}-cargo-registry-
59+
60+
- name: Cache cargo index
61+
uses: actions/cache@v4
62+
with:
63+
path: ~/.cargo/git
64+
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
65+
restore-keys: |
66+
${{ runner.os }}-cargo-index-
67+
68+
- name: Cache target directory
69+
uses: actions/cache@v4
70+
with:
71+
path: target
72+
key: ${{ runner.os }}-${{ matrix.target }}-target-${{ hashFiles('**/Cargo.lock') }}
73+
restore-keys: |
74+
${{ runner.os }}-${{ matrix.target }}-target-
75+
76+
- name: Build binary
77+
run: cargo build --release --target ${{ matrix.target }}
78+
79+
- name: Prepare binary (Unix)
80+
if: matrix.os != 'windows-latest'
81+
run: |
82+
cp target/${{ matrix.target }}/release/${{ matrix.binary_name }} ${{ matrix.asset_name }}
83+
strip ${{ matrix.asset_name }}
84+
85+
- name: Prepare binary (Windows)
86+
if: matrix.os == 'windows-latest'
87+
run: |
88+
cp target/${{ matrix.target }}/release/${{ matrix.binary_name }} ${{ matrix.asset_name }}
89+
90+
- name: Upload build artifacts
91+
uses: actions/upload-artifact@v4
92+
with:
93+
name: ${{ matrix.asset_name }}
94+
path: ${{ matrix.asset_name }}
95+
retention-days: 10

.github/workflows/unstable.yml

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
name: Unstable Build
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
jobs:
8+
build:
9+
name: Build Unstable for ${{ matrix.os }}
10+
runs-on: ${{ matrix.os }}
11+
strategy:
12+
matrix:
13+
include:
14+
- os: ubuntu-latest
15+
target: x86_64-unknown-linux-musl
16+
binary_name: shai
17+
asset_name: shai-unstable-linux-x86_64
18+
- os: windows-latest
19+
target: x86_64-pc-windows-msvc
20+
binary_name: shai.exe
21+
asset_name: shai-unstable-windows-x86_64.exe
22+
- os: macos-latest
23+
target: x86_64-apple-darwin
24+
binary_name: shai
25+
asset_name: shai-unstable-macos-x86_64
26+
- os: macos-latest
27+
target: aarch64-apple-darwin
28+
binary_name: shai
29+
asset_name: shai-unstable-macos-aarch64
30+
31+
steps:
32+
- name: Checkout code
33+
uses: actions/checkout@v4
34+
35+
- name: Install Rust
36+
uses: dtolnay/rust-toolchain@stable
37+
with:
38+
targets: ${{ matrix.target }}
39+
40+
- name: Install dependencies (Linux)
41+
if: matrix.os == 'ubuntu-latest'
42+
run: |
43+
sudo apt-get update
44+
sudo apt-get install -y build-essential musl-tools
45+
46+
- name: Add musl target (Linux)
47+
if: matrix.target == 'x86_64-unknown-linux-musl'
48+
run: rustup target add x86_64-unknown-linux-musl
49+
50+
- name: Cache cargo registry
51+
uses: actions/cache@v4
52+
with:
53+
path: ~/.cargo/registry
54+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
55+
restore-keys: |
56+
${{ runner.os }}-cargo-registry-
57+
58+
- name: Cache cargo index
59+
uses: actions/cache@v4
60+
with:
61+
path: ~/.cargo/git
62+
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
63+
restore-keys: |
64+
${{ runner.os }}-cargo-index-
65+
66+
- name: Cache target directory
67+
uses: actions/cache@v4
68+
with:
69+
path: target
70+
key: ${{ runner.os }}-${{ matrix.target }}-target-${{ hashFiles('**/Cargo.lock') }}
71+
restore-keys: |
72+
${{ runner.os }}-${{ matrix.target }}-target-
73+
74+
- name: Build binary
75+
run: cargo build --release --target ${{ matrix.target }}
76+
77+
- name: Prepare binary (Unix)
78+
if: matrix.os != 'windows-latest'
79+
run: |
80+
cp target/${{ matrix.target }}/release/${{ matrix.binary_name }} ${{ matrix.asset_name }}
81+
strip ${{ matrix.asset_name }}
82+
83+
- name: Prepare binary (Windows)
84+
if: matrix.os == 'windows-latest'
85+
run: |
86+
cp target/${{ matrix.target }}/release/${{ matrix.binary_name }} ${{ matrix.asset_name }}
87+
88+
- name: Upload unstable artifacts
89+
uses: actions/upload-artifact@v4
90+
with:
91+
name: ${{ matrix.asset_name }}
92+
path: ${{ matrix.asset_name }}
93+
retention-days: 30
94+
95+
create-unstable-release:
96+
needs: build
97+
runs-on: ubuntu-latest
98+
steps:
99+
- name: Get current date
100+
id: date
101+
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
102+
103+
- name: Download all artifacts
104+
uses: actions/download-artifact@v4
105+
106+
- name: Delete existing unstable release
107+
continue-on-error: true
108+
run: |
109+
gh release delete unstable --yes
110+
env:
111+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
112+
113+
- name: Create unstable release
114+
run: |
115+
gh release create unstable \
116+
--title "Unstable Build (${{ steps.date.outputs.date }})" \
117+
--notes "Automated unstable build from commit ${{ github.sha }}" \
118+
--prerelease \
119+
shai-unstable-linux-x86_64/shai-unstable-linux-x86_64 \
120+
shai-unstable-windows-x86_64.exe/shai-unstable-windows-x86_64.exe \
121+
shai-unstable-macos-x86_64/shai-unstable-macos-x86_64 \
122+
shai-unstable-macos-aarch64/shai-unstable-macos-aarch64
123+
env:
124+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)