-
Notifications
You must be signed in to change notification settings - Fork 0
141 lines (114 loc) · 3.82 KB
/
auto-build.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
name: Automatic builds
on:
push:
branches:
- main
tags:
- "*"
env:
CARGO_TERM_COLOR: always
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install the rust toolchain
run: |
rustup toolchain install stable
rustup default stable
rustup component add clippy rustfmt
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y libudev-dev
- name: Clippy
run: cargo clippy
- name: Format check
run: cargo fmt --check
- name: Documentation check
run: cargo doc --no-deps
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
steps:
- name: checkout
uses: actions/checkout@v3
- name: Install Rust
run: |
rustup toolchain install stable
rustup default stable
- name: Install Additional targets (macOS)
if: runner.os == 'macOS'
run: |
rustup target add aarch64-apple-darwin
- name: Install dependencies
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y libudev-dev
- name: Test
run: cargo test
- name: Build (Linux, Windows)
if: runner.os != 'macOS'
run: cargo build --release
- name: Build (macOS)
if: runner.os == 'macOS'
run: |
cargo build --release
cargo build --release --target aarch64-apple-darwin
install -d target/universal-apple-darwin/release
lipo target/release/focus \
target/aarch64-apple-darwin/release/focus \
-create -output target/universal-apple-darwin/release/focus
lipo target/release/focus-send \
target/aarch64-apple-darwin/release/focus-send \
-create -output target/universal-apple-darwin/release/focus-send
lipo -info target/universal-apple-darwin/release/focus \
target/universal-apple-darwin/release/focus-send
- name: Prepare compressed binary (Linux)
if: runner.os == 'Linux'
run: |
tar -cf - -C target/release focus-send focus | \
xz -c > target/release/kaleidoscope-focus.linux_amd64.tar.xz
- name: Prepare compressed binary (macOS)
if: runner.os == 'macOS'
run: |
tar -cf - -C target/universal-apple-darwin/release focus-send focus | \
xz -c > target/release/kaleidoscope-focus.macOS_universal.tar.xz
- name: Prepare compressed binary (Windows)
if: runner.os == 'Windows'
shell: bash
run: |
cd target/release && \
7z a -tzip kaleidoscope-focus.windows_amd64.zip focus-send.exe focus.exe
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ runner.os }}-artifact
path: |
target/release/*.xz
target/release/*.zip
publish:
needs: build
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: artifacts
- name: Snapshot release
if: github.ref_type == 'branch'
uses: docker://antonyurchenko/git-release:latest
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
UNRELEASED: "update"
RELEASE_NAME_SUFFIX: " (snapshot build)"
with:
args: artifacts/*/*.xz artifacts/*/*.zip
- name: Release
if: github.ref_type == 'tag'
uses: docker://antonyurchenko/git-release:latest
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
with:
args: artifacts/*/*.xz artifacts/*/*.zip