Skip to content

Commit 2842031

Browse files
authored
Merge pull request #1 from dcodesdev/dev
Dev
2 parents 194a140 + b4832eb commit 2842031

File tree

11 files changed

+1347
-2
lines changed

11 files changed

+1347
-2
lines changed

.github/workflows/release.yaml

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
name: Publish crate
2+
3+
on:
4+
push:
5+
tags: [v*]
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- uses: actions-rs/toolchain@v1
18+
with:
19+
toolchain: stable
20+
21+
- name: Run tests
22+
run: cargo test
23+
24+
macos-build:
25+
runs-on: macos-latest
26+
needs: test
27+
28+
steps:
29+
- uses: actions/checkout@v4
30+
31+
- uses: actions-rs/toolchain@v1
32+
with:
33+
toolchain: stable
34+
35+
- name: Install cross
36+
run: cargo install cross
37+
38+
- name: Add target to rustup
39+
run: rustup target add x86_64-apple-darwin
40+
41+
- name: Build for Apple x86_64
42+
run: cross build --target x86_64-apple-darwin --release
43+
44+
- name: Add target to rustup
45+
run: rustup target add aarch64-apple-darwin
46+
47+
- name: Build for Apple aarch64
48+
run: cross build --target aarch64-apple-darwin --release
49+
50+
- name: Upload x86_64-apple-darwin artifact
51+
uses: actions/upload-artifact@v4
52+
with:
53+
name: x86_64-apple-darwin
54+
path: target/x86_64-apple-darwin/release/clipcat
55+
if-no-files-found: error
56+
57+
- name: Upload aarch64-apple-darwin artifact
58+
uses: actions/upload-artifact@v4
59+
with:
60+
name: aarch64-apple-darwin
61+
path: target/aarch64-apple-darwin/release/clipcat
62+
if-no-files-found: error
63+
64+
build:
65+
runs-on: ubuntu-latest
66+
needs: test
67+
env:
68+
FILE_PATH: ""
69+
70+
strategy:
71+
matrix:
72+
target:
73+
[
74+
x86_64-unknown-linux-gnu,
75+
arm-unknown-linux-gnueabihf,
76+
x86_64-pc-windows-gnu,
77+
]
78+
79+
steps:
80+
- uses: actions/checkout@v4
81+
82+
- uses: actions-rs/toolchain@v1
83+
with:
84+
toolchain: stable
85+
86+
- name: Install cross
87+
run: cargo install cross
88+
89+
- name: Build for ${{ matrix.target }}
90+
run: cross build --target ${{ matrix.target }} --release
91+
92+
- name: Set file path to ENV
93+
run: |
94+
if [ "${{ matrix.target }}" = "x86_64-pc-windows-gnu" ]; then
95+
echo FILE_PATH=target/${{ matrix.target }}/release/clipcat.exe >> $GITHUB_ENV
96+
else
97+
echo FILE_PATH=target/${{ matrix.target }}/release/clipcat >> $GITHUB_ENV
98+
fi
99+
100+
- name: Upload ${{ matrix.target }} artifact
101+
uses: actions/upload-artifact@v4
102+
with:
103+
name: ${{ matrix.target }}
104+
path: ${{ env.FILE_PATH }}
105+
if-no-files-found: error
106+
107+
release:
108+
runs-on: ubuntu-latest
109+
needs: [build, macos-build]
110+
111+
steps:
112+
- name: Download Linux x86_64 artifact
113+
uses: actions/download-artifact@v4
114+
with:
115+
name: x86_64-unknown-linux-gnu
116+
path: target/x86_64-unknown-linux-gnu/release/
117+
118+
- name: Download Linux arm artifact
119+
uses: actions/download-artifact@v4
120+
with:
121+
name: arm-unknown-linux-gnueabihf
122+
path: target/arm-unknown-linux-gnueabihf/release/
123+
124+
- name: Download Windows x86_64 artifact
125+
uses: actions/download-artifact@v4
126+
with:
127+
name: x86_64-pc-windows-gnu
128+
path: target/x86_64-pc-windows-gnu/release/
129+
130+
- name: Download Apple x86_64 artifact
131+
uses: actions/download-artifact@v4
132+
with:
133+
name: x86_64-apple-darwin
134+
path: target/x86_64-apple-darwin/release/
135+
136+
- name: Download Apple aarch64 artifact
137+
uses: actions/download-artifact@v4
138+
with:
139+
name: aarch64-apple-darwin
140+
path: target/aarch64-apple-darwin/release/
141+
142+
- name: Rename binaries
143+
run: |
144+
mv target/x86_64-unknown-linux-gnu/release/clipcat clipcat-linux-x86_64
145+
mv target/arm-unknown-linux-gnueabihf/release/clipcat clipcat-linux-arm
146+
mv target/x86_64-pc-windows-gnu/release/clipcat.exe clipcat-windows-x86_64.exe
147+
mv target/x86_64-apple-darwin/release/clipcat clipcat-macos-x86_64
148+
mv target/aarch64-apple-darwin/release/clipcat clipcat-macos-aarch64
149+
150+
- name: Give executable permissions
151+
run: |
152+
chmod +x clipcat-linux-x86_64
153+
chmod +x clipcat-linux-arm
154+
chmod +x clipcat-windows-x86_64.exe
155+
chmod +x clipcat-macos-x86_64
156+
chmod +x clipcat-macos-aarch64
157+
158+
- name: Release ${{ github.ref_name }}
159+
uses: softprops/action-gh-release@v2
160+
with:
161+
files: |
162+
clipcat-linux-x86_64
163+
clipcat-linux-arm
164+
clipcat-windows-x86_64.exe
165+
clipcat-macos-x86_64
166+
clipcat-macos-aarch64
167+
168+
crates-io:
169+
runs-on: ubuntu-latest
170+
needs: [test, release]
171+
env:
172+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
173+
174+
steps:
175+
- uses: actions/checkout@v4
176+
177+
- uses: actions-rs/toolchain@v1
178+
with:
179+
toolchain: stable
180+
181+
- name: Publish to crates.io
182+
run: cargo publish || true

0 commit comments

Comments
 (0)