-
Notifications
You must be signed in to change notification settings - Fork 0
182 lines (145 loc) · 4.81 KB
/
release.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
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
name: Publish crate
on:
push:
tags: [v*]
permissions:
contents: write
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Run tests
run: cargo test
macos-build:
runs-on: macos-latest
needs: test
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Install cross
run: cargo install cross
- name: Add target to rustup
run: rustup target add x86_64-apple-darwin
- name: Build for Apple x86_64
run: cross build --target x86_64-apple-darwin --release
- name: Add target to rustup
run: rustup target add aarch64-apple-darwin
- name: Build for Apple aarch64
run: cross build --target aarch64-apple-darwin --release
- name: Upload x86_64-apple-darwin artifact
uses: actions/upload-artifact@v4
with:
name: x86_64-apple-darwin
path: target/x86_64-apple-darwin/release/clipcat
if-no-files-found: error
- name: Upload aarch64-apple-darwin artifact
uses: actions/upload-artifact@v4
with:
name: aarch64-apple-darwin
path: target/aarch64-apple-darwin/release/clipcat
if-no-files-found: error
build:
runs-on: ubuntu-latest
needs: test
env:
FILE_PATH: ""
strategy:
matrix:
target:
[
x86_64-unknown-linux-gnu,
arm-unknown-linux-gnueabihf,
x86_64-pc-windows-gnu,
]
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Install cross
run: cargo install cross
- name: Build for ${{ matrix.target }}
run: cross build --target ${{ matrix.target }} --release
- name: Set file path to ENV
run: |
if [ "${{ matrix.target }}" = "x86_64-pc-windows-gnu" ]; then
echo FILE_PATH=target/${{ matrix.target }}/release/clipcat.exe >> $GITHUB_ENV
else
echo FILE_PATH=target/${{ matrix.target }}/release/clipcat >> $GITHUB_ENV
fi
- name: Upload ${{ matrix.target }} artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target }}
path: ${{ env.FILE_PATH }}
if-no-files-found: error
release:
runs-on: ubuntu-latest
needs: [build, macos-build]
steps:
- name: Download Linux x86_64 artifact
uses: actions/download-artifact@v4
with:
name: x86_64-unknown-linux-gnu
path: target/x86_64-unknown-linux-gnu/release/
- name: Download Linux arm artifact
uses: actions/download-artifact@v4
with:
name: arm-unknown-linux-gnueabihf
path: target/arm-unknown-linux-gnueabihf/release/
- name: Download Windows x86_64 artifact
uses: actions/download-artifact@v4
with:
name: x86_64-pc-windows-gnu
path: target/x86_64-pc-windows-gnu/release/
- name: Download Apple x86_64 artifact
uses: actions/download-artifact@v4
with:
name: x86_64-apple-darwin
path: target/x86_64-apple-darwin/release/
- name: Download Apple aarch64 artifact
uses: actions/download-artifact@v4
with:
name: aarch64-apple-darwin
path: target/aarch64-apple-darwin/release/
- name: Rename binaries
run: |
mv target/x86_64-unknown-linux-gnu/release/clipcat clipcat-linux-x86_64
mv target/arm-unknown-linux-gnueabihf/release/clipcat clipcat-linux-arm
mv target/x86_64-pc-windows-gnu/release/clipcat.exe clipcat-windows-x86_64.exe
mv target/x86_64-apple-darwin/release/clipcat clipcat-macos-x86_64
mv target/aarch64-apple-darwin/release/clipcat clipcat-macos-aarch64
- name: Give executable permissions
run: |
chmod +x clipcat-linux-x86_64
chmod +x clipcat-linux-arm
chmod +x clipcat-windows-x86_64.exe
chmod +x clipcat-macos-x86_64
chmod +x clipcat-macos-aarch64
- name: Release ${{ github.ref_name }}
uses: softprops/action-gh-release@v2
with:
files: |
clipcat-linux-x86_64
clipcat-linux-arm
clipcat-windows-x86_64.exe
clipcat-macos-x86_64
clipcat-macos-aarch64
crates-io:
runs-on: ubuntu-latest
needs: [test, release]
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Publish to crates.io
run: cargo publish || true