-
Notifications
You must be signed in to change notification settings - Fork 2
143 lines (122 loc) · 4.1 KB
/
ci.yaml
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
143
name: "Continuous Integration"
on: [push, pull_request]
env:
CARGO_TERM_COLOR: always
jobs:
# check and build
build:
strategy:
fail-fast: false
matrix:
job:
- target: x86_64-unknown-linux-gnu
os: linux
runs-on: ubuntu-20.04
- target: x86_64-pc-windows-gnu
os: windows
runs-on: windows-latest
- target: aarch64-apple-darwin
os: macos
runs-on: macos-latest
runs-on: ${{ matrix.job.runs-on }}
steps:
- uses: actions/checkout@v4
- uses: mitoma/sver-actions/setup@v2
with:
os: ${{ matrix.job.os }}
# ci phase
- name: check all
uses: mitoma/sver-actions/exec@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
phase: check-${{ matrix.job.target }}
command: |
cargo fmt --all -- --check
cargo clippy -- -D warnings
cargo build
cargo test
cache_save_enable: false
cache_key: ${{ matrix.job.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
cache_restore-keys: ${{ matrix.job.target }}-cargo-
cache_path: |
~/.cargo/registry
~/.cargo/git
target
# build and upload artifact
build_artifact:
# run on branch [main] or tag [v*]
if: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) }}
needs: [build]
strategy:
fail-fast: false
matrix:
job:
- target: x86_64-unknown-linux-gnu
os: linux
runs-on: ubuntu-20.04
- target: x86_64-pc-windows-gnu
os: windows
runs-on: windows-latest
- target: x86_64-apple-darwin
os: macos
runs-on: macos-latest
- target: aarch64-unknown-linux-gnu
os: linux
runs-on: ubuntu-20.04
- target: aarch64-apple-darwin
os: macos
runs-on: macos-latest
runs-on: ${{ matrix.job.runs-on }}
steps:
- uses: actions/checkout@v4
- uses: mitoma/sver-actions/setup@v2
with:
os: ${{ matrix.job.os }}
# artifact phase
- name: build artifact
uses: mitoma/sver-actions/exec@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
phase: artifact-${{ matrix.job.target }}
command: |
rustup target add "${{ matrix.job.target }}"
if [[ "${{ matrix.job.os }}" == linux && "${{ matrix.job.target }}" == aarch64-* ]]; then
sudo apt-get install gcc-aarch64-linux-gnu
fi
# debug build for cache optimization
cargo build --target=${{ matrix.job.target }}
# release build for create artifact
cargo build --release --target=${{ matrix.job.target }}
mkdir artifact
cd artifact
cp ../LICENSE .
cp ../README.md .
if [[ "${{ matrix.job.os }}" == windows ]]; then
cp ../target/${{ matrix.job.target }}/release/sver.exe .
else
cp ../target/${{ matrix.job.target }}/release/sver .
fi
cache_key: ${{ matrix.job.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
cache_restore-keys: ${{ matrix.job.target }}-cargo-
cache_path: |
~/.cargo/registry
~/.cargo/git
target
artifact_name: sver-${{ matrix.job.target }}
artifact_path: artifact
# release sver
release_sver:
# run on tag [v*]
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') }}
needs: [build_artifact]
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: mitoma/sver-actions/setup@v2
- id: extract_tag
name: Extract tag name
run: echo "tag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
- name: create release
run: ./release.sh "${{ steps.extract_tag.outputs.tag }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}