-
-
Notifications
You must be signed in to change notification settings - Fork 2
142 lines (122 loc) ยท 4.19 KB
/
ci-cd.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
name: โ๏ธ๐
on:
pull_request:
workflow_dispatch:
push:
branches: [main]
tags: ["*"]
concurrency:
group: ci-cd-${{ github.ref }}
cancel-in-progress: true
jobs:
code-quality:
name: ๐ฆ Code Quality
runs-on: ubuntu-latest
steps:
- name: ๐๏ธ Checkout
uses: actions/checkout@v4.1.0
- name: ๐ฆ Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- name: โป๏ธ Manage Cache
uses: actions/cache@v3.3.2
with:
path: |
~/.cargo/
target/
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
cargo-${{ runner.os }}-
- name: ๐จ Check Formatting
run: cargo fmt --check --all
- name: ๐ Check Linting
run: cargo clippy --locked --all-targets --all-features -- -D warnings
- name: ๐งช Run Tests
run: cargo test --locked --all-targets --all-features
build-artifacts:
name: โ๏ธ Build (${{ matrix.artifact-name }})
needs: [code-quality]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
artifact-name: chara-x86_64-unknown-linux-gnu
cargo-target: x86_64-unknown-linux-gnu
- os: ubuntu-latest
artifact-name: chara-aarch64-unknown-linux-gnu
cargo-target: aarch64-unknown-linux-gnu
linker: gcc-aarch64-linux-gnu
- os: ubuntu-latest
artifact-name: chara-aarch64-linux-android
cargo-target: aarch64-linux-android
- os: macos-latest
artifact-name: chara-x86_64-apple-darwin
cargo-target: x86_64-apple-darwin
- os: windows-latest
artifact-name: chara-x86_64-pc-windows-gnu
cargo-target: x86_64-pc-windows-gnu
steps:
- name: ๐๏ธ Checkout
uses: actions/checkout@v4.1.0
- name: ๐ฆ Install Rust
uses: dtolnay/rust-toolchain@stable
with:
target: ${{ matrix.cargo-target }}
- name: ๐ Install Linker packages
if: matrix.linker != ''
run: |
sudo apt-get -y update
sudo apt-get -y install ${{ matrix.linker }}
- name: ๐ฃ๏ธ Set Linker Path
if: matrix.cargo-target == 'aarch64-linux-android'
run: echo "$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin" >> $GITHUB_PATH
- name: โป๏ธ Manage Build Cache
uses: actions/cache@v3.3.2
with:
path: |
~/.cargo/
target/
key: cargo-${{ matrix.artifact-name }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
cargo-${{ matrix.artifact-name }}-${{ hashFiles('**/Cargo.lock') }}
cargo-${{ matrix.artifact-name }}-
- name: ๐ ๏ธ Build Binary
run: cargo build --locked --release --target ${{ matrix.cargo-target }}
- name: ๐ Setup Archive + Extension
shell: bash
run: |
mkdir -p staging
if [ "${{ matrix.os }}" = "windows-latest" ]; then
cp "target/${{ matrix.cargo-target }}/release/chara.exe" staging/
cd staging
7z a ../${{ matrix.artifact-name }}.zip *
else
cp "target/${{ matrix.cargo-target }}/release/chara" staging/
cd staging
zip ../${{ matrix.artifact-name }}.zip *
fi
- name: โฌ๏ธ Upload Binary Artifact
uses: actions/upload-artifact@v3.1.3
with:
name: ${{ matrix.artifact-name }}
path: ${{ matrix.artifact-name }}.zip
retention-days: 5
release:
name: ๐ Create Release
if: github.ref_type == 'tag'
needs: [build-artifacts]
runs-on: ubuntu-latest
steps:
- name: โฌ๏ธ Download All Binary Artifacts
uses: actions/download-artifact@v3.0.2
- name: ๐๏ธCreate Release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
generate_release_notes: true
files: chara-*/*.zip