-
Notifications
You must be signed in to change notification settings - Fork 0
222 lines (194 loc) · 7.63 KB
/
Copy pathci.yml
File metadata and controls
222 lines (194 loc) · 7.63 KB
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
name: CI/CD
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
release:
types: [published]
env:
CARGO_TERM_COLOR: always
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: clippy
- name: Cache dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Run checks
run: cargo clippy -- -D warnings
- name: Run tests
run: cargo test
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
needs: test
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact_name: killallgit
asset_name: killallgit-linux-x86_64
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
artifact_name: killallgit
asset_name: killallgit-linux-aarch64
cross: true
- os: macos-latest
target: aarch64-apple-darwin
artifact_name: killallgit
asset_name: killallgit-macos-aarch64
- os: macos-15-intel
target: x86_64-apple-darwin
artifact_name: killallgit
asset_name: killallgit-macos-x86_64
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact_name: killallgit.exe
asset_name: killallgit-windows-x86_64
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: ${{ matrix.target }}
- name: Cache dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.target }}-cargo-
- name: Install cross-compilation tools (Linux ARM64)
if: matrix.cross == true
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Build release
run: cargo build --release --target ${{ matrix.target }}
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: ${{ matrix.cross && 'aarch64-linux-gnu-gcc' || '' }}
- name: Strip binary (Unix native)
if: runner.os != 'Windows' && matrix.cross != true
run: strip target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
- name: Strip binary (Cross-compiled ARM64)
if: matrix.cross == true
run: aarch64-linux-gnu-strip target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
- name: Create tarball (Unix)
if: runner.os != 'Windows'
run: |
cd target/${{ matrix.target }}/release
tar -czvf ${{ matrix.asset_name }}.tar.gz ${{ matrix.artifact_name }}
shasum -a 256 ${{ matrix.asset_name }}.tar.gz > ${{ matrix.asset_name }}.tar.gz.sha256
- name: Create zip (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
cd target/${{ matrix.target }}/release
Compress-Archive -Force -Path ${{ matrix.artifact_name }} -DestinationPath ${{ matrix.asset_name }}.zip
(Get-FileHash -Algorithm SHA256 ${{ matrix.asset_name }}.zip).Hash.ToLower() + " " + "${{ matrix.asset_name }}.zip" | Out-File -Encoding ASCII ${{ matrix.asset_name }}.zip.sha256
- name: Upload tarball artifact (Unix)
if: runner.os != 'Windows'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.asset_name }}.tar.gz
path: target/${{ matrix.target }}/release/${{ matrix.asset_name }}.tar.gz
- name: Upload sha256 artifact (Unix)
if: runner.os != 'Windows'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.asset_name }}.tar.gz.sha256
path: target/${{ matrix.target }}/release/${{ matrix.asset_name }}.tar.gz.sha256
- name: Upload zip artifact (Windows)
if: runner.os == 'Windows'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.asset_name }}.zip
path: target/${{ matrix.target }}/release/${{ matrix.asset_name }}.zip
- name: Upload sha256 artifact (Windows)
if: runner.os == 'Windows'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.asset_name }}.zip.sha256
path: target/${{ matrix.target }}/release/${{ matrix.asset_name }}.zip.sha256
release:
name: Release
if: github.event_name == 'release'
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
version: ${{ steps.version.outputs.version }}
macos_arm64_sha256: ${{ steps.checksums.outputs.macos_arm64_sha256 }}
macos_x86_64_sha256: ${{ steps.checksums.outputs.macos_x86_64_sha256 }}
linux_x86_64_sha256: ${{ steps.checksums.outputs.linux_x86_64_sha256 }}
linux_arm64_sha256: ${{ steps.checksums.outputs.linux_arm64_sha256 }}
steps:
- name: Get version
id: version
run: echo "version=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Display structure of downloaded files
run: ls -R artifacts
- name: Flatten artifacts
run: |
mkdir -p release
find artifacts -type f \( -name "*.tar.gz" -o -name "*.zip" \) -exec mv {} release/ \;
ls -la release/
- name: Extract checksums
id: checksums
run: |
cd artifacts
echo "macos_arm64_sha256=$(cat killallgit-macos-aarch64.tar.gz.sha256/killallgit-macos-aarch64.tar.gz.sha256 | awk '{print $1}')" >> $GITHUB_OUTPUT
echo "macos_x86_64_sha256=$(cat killallgit-macos-x86_64.tar.gz.sha256/killallgit-macos-x86_64.tar.gz.sha256 | awk '{print $1}')" >> $GITHUB_OUTPUT
echo "linux_x86_64_sha256=$(cat killallgit-linux-x86_64.tar.gz.sha256/killallgit-linux-x86_64.tar.gz.sha256 | awk '{print $1}')" >> $GITHUB_OUTPUT
echo "linux_arm64_sha256=$(cat killallgit-linux-aarch64.tar.gz.sha256/killallgit-linux-aarch64.tar.gz.sha256 | awk '{print $1}')" >> $GITHUB_OUTPUT
- name: Upload release assets
uses: softprops/action-gh-release@v2
with:
files: release/*
token: ${{ secrets.GITHUB_TOKEN }}
update-homebrew:
name: Update Homebrew Formula
if: github.event_name == 'release'
needs: release
runs-on: ubuntu-latest
steps:
- name: Trigger Homebrew tap update
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
repository: killallgit/homebrew-killallgit
event-type: formula-update
client-payload: |
{
"version": "${{ needs.release.outputs.version }}",
"macos_arm64_sha256": "${{ needs.release.outputs.macos_arm64_sha256 }}",
"macos_x86_64_sha256": "${{ needs.release.outputs.macos_x86_64_sha256 }}",
"linux_x86_64_sha256": "${{ needs.release.outputs.linux_x86_64_sha256 }}",
"linux_arm64_sha256": "${{ needs.release.outputs.linux_arm64_sha256 }}"
}