-
Notifications
You must be signed in to change notification settings - Fork 7
175 lines (145 loc) · 4.99 KB
/
pipeline.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
name: pipeline
on: [push, pull_request]
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
- name: build
run: cargo test --no-run
- name: test
run: cargo test -- --nocapture --quiet
- name: formatting
run: cargo fmt --all -- --check
- name: check
run: cargo check
- name: clippy
run: cargo clippy -- -D warnings
cargo_publish:
if: startsWith(github.ref, 'refs/tags/v')
needs: check
name: Publish Cargo Package
runs-on: ubuntu-latest
env:
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo login $CRATES_IO_TOKEN
- run: cargo publish
github_build:
if: startsWith(github.ref, 'refs/tags/v')
needs: check
name: Build release binaries
strategy:
fail-fast: false
matrix:
target:
- x86_64-unknown-linux-gnu
- x86_64-unknown-linux-musl
- x86_64-apple-darwin
- aarch64-apple-darwin
- x86_64-pc-windows-msvc
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
name: git-ignore-x86_64-unknown-linux-gnu.tar.gz
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
name: git-ignore-x86_64-unknown-linux-musl.tar.gz
- target: x86_64-apple-darwin
os: macos-latest
name: git-ignore-x86_64-apple-darwin.tar.gz
- target: aarch64-apple-darwin
os: macos-14
name: git-ignore-aarch64-apple-darwin.tar.gz
- target: x86_64-pc-windows-msvc
os: windows-latest
name: git-ignore-x86_64-pc-windows-msvc.zip
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
target: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
- name: Install musl tools
if: matrix.target == 'x86_64-unknown-linux-musl'
run: sudo apt-get install -y musl-tools libssl-dev
- name: Build target
if: matrix.target != 'x86_64-unknown-linux-musl'
run: cargo build --release --target ${{ matrix.target }}
- name: Build target (musl)
if: matrix.target == 'x86_64-unknown-linux-musl'
run: cargo build --release --target ${{ matrix.target }}
- name: Prepare build artifacts [Windows]
if: matrix.os == 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
strip git-ignore.exe
cp ../assets/* .
7z a ../../../${{ matrix.name }} git-ignore.exe _git-ignore git-ignore.1 git-ignore.bash git-ignore.elv git-ignore.fish _git-ignore.ps1
cd -
- name: Prepare build artifacts [-nix]
if: matrix.os != 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
strip git-ignore
cp ../assets/* .
tar czvf ../../../${{ matrix.name }} git-ignore _git-ignore git-ignore.1 git-ignore.bash git-ignore.elv git-ignore.fish _git-ignore.ps1
cd -
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.name }}
path: ${{ matrix.name }}
github_release:
if: startsWith(github.ref, 'refs/tags/v')
name: Create GitHub Release
needs: github_build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download Linux GNU artifact
uses: actions/download-artifact@v4
with:
name: git-ignore-x86_64-unknown-linux-gnu.tar.gz
path: .
- name: Download Linux MUSL artifact
uses: actions/download-artifact@v4
with:
name: git-ignore-x86_64-unknown-linux-musl.tar.gz
path: .
- name: Download Darwin artifact
uses: actions/download-artifact@v4
with:
name: git-ignore-x86_64-apple-darwin.tar.gz
path: .
- name: Download Darwin artifact
uses: actions/download-artifact@v4
with:
name: git-ignore-aarch64-apple-darwin.tar.gz
path: .
- name: Download Windows artifact
uses: actions/download-artifact@v4
with:
name: git-ignore-x86_64-pc-windows-msvc.zip
path: .
- name: Print directory
run: ls -R
- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
files: |
git-ignore-x86_64-apple-darwin.tar.gz
git-ignore-aarch64-apple-darwin.tar.gz
git-ignore-x86_64-pc-windows-msvc.zip
git-ignore-x86_64-unknown-linux-gnu.tar.gz
git-ignore-x86_64-unknown-linux-musl.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}