-
Notifications
You must be signed in to change notification settings - Fork 0
154 lines (129 loc) · 3.93 KB
/
Copy pathci.yml
File metadata and controls
154 lines (129 loc) · 3.93 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
name: CI and Release
on:
push:
branches: [main]
tags:
- "v*"
pull_request:
workflow_dispatch:
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
BINARY_NAME: roon-beacon
jobs:
quality:
name: Quality gate
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Cache Cargo
uses: Swatinem/rust-cache@v2
- name: Check formatting
run: cargo fmt --all -- --check
- name: Run Clippy
run: cargo clippy --workspace --all-targets -- -D warnings
- name: Run tests
run: cargo test --workspace --all-targets
build:
name: Build ${{ matrix.name }}
needs: quality
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- name: linux-x86_64
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
exe: roon-beacon
archive: roon-beacon-linux-x86_64.tar.gz
- name: macos-x86_64
os: macos-latest
target: x86_64-apple-darwin
exe: roon-beacon
archive: roon-beacon-macos-x86_64.tar.gz
- name: macos-aarch64
os: macos-latest
target: aarch64-apple-darwin
exe: roon-beacon
archive: roon-beacon-macos-aarch64.tar.gz
- name: windows-x86_64
os: windows-latest
target: x86_64-pc-windows-msvc
exe: roon-beacon.exe
archive: roon-beacon-windows-x86_64.zip
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Cache Cargo
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Build release binary
run: cargo build --release --target ${{ matrix.target }} --bin roon-beacon
- name: Package binary
shell: bash
env:
TARGET: ${{ matrix.target }}
EXE: ${{ matrix.exe }}
ARCHIVE: ${{ matrix.archive }}
run: |
set -euo pipefail
mkdir -p dist package
cp "target/${TARGET}/release/${EXE}" package/
cp README.md README.zh-CN.md LICENSE package/
if [[ "${RUNNER_OS}" == "Windows" ]]; then
(cd package && 7z a -tzip "../dist/${ARCHIVE}" ./*)
else
chmod +x "package/${EXE}"
tar -C package -czf "dist/${ARCHIVE}" .
fi
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.name }}
path: dist/${{ matrix.archive }}
if-no-files-found: error
publish-release:
name: Publish GitHub Release
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: release-artifacts
merge-multiple: true
- name: List artifacts
run: ls -lh release-artifacts/
- name: Create or update release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if ! gh release view "${{ github.ref_name }}" >/dev/null 2>&1; then
gh release create "${{ github.ref_name }}" \
--title "${{ github.ref_name }}" \
--generate-notes
fi
- name: Upload release assets
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
find release-artifacts -type f -print0 | while IFS= read -r -d '' file; do
gh release upload "${{ github.ref_name }}" "$file" --clobber
done