Repository navigation
206 lines (174 loc) · 5.78 KB
/
Copy pathrelease.yml
File metadata and controls
206 lines (174 loc) · 5.78 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
name: Release
on:
push:
tags:
- 'v*.*.*'
workflow_dispatch:
inputs:
tag:
description: Existing version tag to release, for example v2.0.2
required: true
type: string
permissions:
contents: read
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
env:
BINARY_NAME: openhomeb
PLUGIN_ID: com.infamous-pattern.openhomeb
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Rust formatting
run: cargo fmt --all -- --check
- name: Rust tests
run: cargo test --all-targets
- name: Rust Clippy
run: cargo clippy --all-targets -- -D warnings
- name: Property inspector syntax
run: node --check assets/propertyInspector/openhomeb.js
- name: Property inspector tests
run: node test/test_property_inspector.js
- name: Homebridge API and package contracts
run: python3 -m unittest discover -v
build:
needs: validate
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target:
- x86_64-unknown-linux-gnu
- aarch64-unknown-linux-gnu
steps:
- uses: actions/checkout@v7
- name: Install Rust target
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install aarch64 linker
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Build release binary
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
run: cargo build --release --target '${{ matrix.target }}'
- name: Verify binary
run: |
test -x "target/${{ matrix.target }}/release/${BINARY_NAME}"
file "target/${{ matrix.target }}/release/${BINARY_NAME}"
- name: Stage binary
run: |
mkdir -p "release/${{ matrix.target }}"
install -m 0755 \
"target/${{ matrix.target }}/release/${BINARY_NAME}" \
"release/${{ matrix.target }}/${BINARY_NAME}"
sha256sum "release/${{ matrix.target }}/${BINARY_NAME}" \
> "release/${{ matrix.target }}/${BINARY_NAME}.sha256"
- uses: actions/upload-artifact@v7
with:
name: binary-${{ matrix.target }}
path: release/${{ matrix.target }}/
if-no-files-found: error
package:
needs: build
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.version.outputs.tag }}
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: actions/download-artifact@v8
with:
pattern: binary-*
path: downloaded
- name: Resolve release tag
id: version
env:
DISPATCH_TAG: ${{ inputs.tag }}
run: |
if [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]]; then
tag="${DISPATCH_TAG}"
else
tag="${GITHUB_REF_NAME}"
fi
[[ "${tag}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] || {
echo "Invalid release tag: ${tag}" >&2
exit 1
}
echo "tag=${tag}" >> "$GITHUB_OUTPUT"
- name: Arrange binaries
run: |
mkdir -p release/x86_64-unknown-linux-gnu release/aarch64-unknown-linux-gnu
for target in x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu; do
install -m 0755 \
"downloaded/binary-${target}/${BINARY_NAME}" \
"release/${target}/${BINARY_NAME}"
done
- name: Package universal plugin
run: |
sudo apt-get update
sudo apt-get install -y zip
chmod +x scripts/*.sh
./scripts/package-universal.sh release
- name: Build release assets
env:
RELEASE_TAG: ${{ steps.version.outputs.tag }}
run: |
version="${RELEASE_TAG#v}"
mkdir -p release-assets
cp "dist/${PLUGIN_ID}.streamDeckPlugin" \
"release-assets/openhomeb-${version}-linux-universal.streamDeckPlugin"
for target in x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu; do
cp "release/${target}/${BINARY_NAME}" \
"release-assets/${BINARY_NAME}-${version}-${target}"
done
git archive --format=zip \
--output="release-assets/openhomeb-${version}-source.zip" \
HEAD
git archive --format=tar.gz \
--output="release-assets/openhomeb-${version}-source.tar.gz" \
HEAD
notes_file="RELEASE_NOTES_${version}.md"
test -f "${notes_file}"
cp "${notes_file}" release-assets/
(
cd release-assets
sha256sum * > SHA256SUMS
)
- uses: actions/upload-artifact@v7
with:
name: release-assets
path: release-assets/
if-no-files-found: error
publish:
permissions:
contents: write
needs: package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/download-artifact@v8
with:
name: release-assets
path: release-assets
- name: Create GitHub release and upload assets
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ needs.package.outputs.tag }}
run: |
gh release view "${RELEASE_TAG}" >/dev/null 2>&1 || \
gh release create "${RELEASE_TAG}" \
--title "OpenHomeB ${RELEASE_TAG#v}" \
--notes-file "RELEASE_NOTES_${RELEASE_TAG#v}.md" \
--verify-tag
gh release upload "${RELEASE_TAG}" release-assets/* --clobber