Skip to content

Commit 986d6e1

Browse files
committed
refactor(ci): split CI and Release workflows
Changes: 1. CI workflow (on push/PR): - Tests - Clippy - Format check - Documentation - NO BUILD (removed to save resources) - Ignores tags 2. Release workflow (on v*.*.* tags): - Builds for 6 platforms: * Linux x86_64 (glibc) * Linux x86_64 (musl) * Linux ARM64 * Windows x86_64 * macOS x86_64 * macOS ARM64 (Apple Silicon) - Creates GitHub release - Uploads binaries as release assets Benefits: - Faster CI (no unnecessary builds) - Clean releases with binaries - Tag-based release process To create a release: git tag v0.1.0 git push origin v0.1.0 Deleted all existing workflow runs.
1 parent 610fe46 commit 986d6e1

File tree

2 files changed

+59
-20
lines changed

2 files changed

+59
-20
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: CI
33
on:
44
push:
55
branches: [ main ]
6+
tags-ignore: [ '**' ]
67
pull_request:
78
branches: [ main ]
89

@@ -44,19 +45,6 @@ jobs:
4445
- name: Check formatting
4546
run: cargo fmt --all -- --check
4647

47-
build:
48-
name: Build
49-
runs-on: ${{ matrix.os }}
50-
strategy:
51-
matrix:
52-
os: [ubuntu-latest, windows-latest, macos-latest]
53-
steps:
54-
- uses: actions/checkout@v4
55-
- uses: dtolnay/rust-toolchain@stable
56-
- uses: Swatinem/rust-cache@v2
57-
- name: Build
58-
run: cargo build --release --all-features
59-
6048
doc:
6149
name: Documentation
6250
runs-on: ubuntu-latest

.github/workflows/release.yml

Lines changed: 58 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ jobs:
1414
runs-on: ubuntu-latest
1515
outputs:
1616
upload_url: ${{ steps.create_release.outputs.upload_url }}
17+
version: ${{ steps.get_version.outputs.version }}
1718
steps:
19+
- name: Get version from tag
20+
id: get_version
21+
run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
22+
1823
- name: Create Release
1924
id: create_release
2025
uses: actions/create-release@v1
@@ -31,41 +36,87 @@ jobs:
3136
needs: create-release
3237
runs-on: ${{ matrix.os }}
3338
strategy:
39+
fail-fast: false
3440
matrix:
3541
include:
3642
- os: ubuntu-latest
3743
target: x86_64-unknown-linux-gnu
3844
artifact_name: rasn
3945
asset_name: rasn-linux-amd64
46+
archive: tar.gz
47+
4048
- os: ubuntu-latest
4149
target: x86_64-unknown-linux-musl
4250
artifact_name: rasn
4351
asset_name: rasn-linux-musl-amd64
44-
- os: macos-latest
45-
target: x86_64-apple-darwin
52+
archive: tar.gz
53+
54+
- os: ubuntu-latest
55+
target: aarch64-unknown-linux-gnu
4656
artifact_name: rasn
47-
asset_name: rasn-macos-amd64
57+
asset_name: rasn-linux-aarch64
58+
archive: tar.gz
59+
4860
- os: windows-latest
4961
target: x86_64-pc-windows-msvc
5062
artifact_name: rasn.exe
5163
asset_name: rasn-windows-amd64.exe
64+
archive: zip
65+
66+
- os: macos-latest
67+
target: x86_64-apple-darwin
68+
artifact_name: rasn
69+
asset_name: rasn-macos-amd64
70+
archive: tar.gz
71+
72+
- os: macos-latest
73+
target: aarch64-apple-darwin
74+
artifact_name: rasn
75+
asset_name: rasn-macos-aarch64
76+
archive: tar.gz
5277

5378
steps:
5479
- uses: actions/checkout@v4
80+
with:
81+
lfs: true
82+
5583
- uses: dtolnay/rust-toolchain@stable
5684
with:
5785
targets: ${{ matrix.target }}
86+
5887
- uses: Swatinem/rust-cache@v2
88+
with:
89+
key: ${{ matrix.target }}
90+
91+
- name: Install cross-compilation tools
92+
if: matrix.target == 'aarch64-unknown-linux-gnu'
93+
run: |
94+
sudo apt-get update
95+
sudo apt-get install -y gcc-aarch64-linux-gnu
5996
6097
- name: Build
61-
run: cargo build --release --target ${{ matrix.target }}
62-
98+
run: cargo build --release --target ${{ matrix.target }} --bin rasn
99+
100+
- name: Package binary (tar.gz)
101+
if: matrix.archive == 'tar.gz'
102+
run: |
103+
cd target/${{ matrix.target }}/release
104+
tar czf ${{ matrix.asset_name }}.tar.gz ${{ matrix.artifact_name }}
105+
mv ${{ matrix.asset_name }}.tar.gz ${{ github.workspace }}
106+
107+
- name: Package binary (zip)
108+
if: matrix.archive == 'zip'
109+
run: |
110+
cd target/${{ matrix.target }}/release
111+
7z a ${{ matrix.asset_name }}.zip ${{ matrix.artifact_name }}
112+
move ${{ matrix.asset_name }}.zip ${{ github.workspace }}
113+
63114
- name: Upload Release Asset
64115
uses: actions/upload-release-asset@v1
65116
env:
66117
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67118
with:
68119
upload_url: ${{ needs.create-release.outputs.upload_url }}
69-
asset_path: ./target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
70-
asset_name: ${{ matrix.asset_name }}
120+
asset_path: ./${{ matrix.asset_name }}.${{ matrix.archive }}
121+
asset_name: ${{ matrix.asset_name }}.${{ matrix.archive }}
71122
asset_content_type: application/octet-stream

0 commit comments

Comments
 (0)