-
Notifications
You must be signed in to change notification settings - Fork 1
257 lines (221 loc) · 9 KB
/
release.yml
File metadata and controls
257 lines (221 loc) · 9 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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
# ── Job 1: Create source tarball and draft release ─────────────────────────
source-tarball:
name: Source tarball
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
tarball_sha256: ${{ steps.tarball.outputs.sha256 }}
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Extract version from tag
id: version
run: echo "version=${GITHUB_REF#refs/tags/v}" >> "$GITHUB_OUTPUT"
- name: Create source tarball
id: tarball
run: |
VERSION=${{ steps.version.outputs.version }}
tar czf /tmp/mavsim-viewer-${VERSION}.tar.gz \
--exclude='.git' \
--exclude='tests/fixtures/*.ulg' \
--exclude='build' \
--transform="s,^\.,mavsim-viewer-${VERSION}," \
.
mv /tmp/mavsim-viewer-${VERSION}.tar.gz .
SHA=$(sha256sum mavsim-viewer-${VERSION}.tar.gz | awk '{print $1}')
echo "sha256=${SHA}" >> "$GITHUB_OUTPUT"
echo "Tarball SHA256: ${SHA}"
- name: Create release
run: |
gh release create ${{ github.ref_name }} \
--title "${{ github.ref_name }}" \
--generate-notes
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload source tarball
run: |
VERSION=${{ steps.version.outputs.version }}
gh release upload ${{ github.ref_name }} mavsim-viewer-${VERSION}.tar.gz
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# ── Job 2a: macOS arm64 bottle ─────────────────────────────────────────────
bottle-arm64:
name: Bottle (arm64)
needs: source-tarball
runs-on: macos-14
outputs:
bottle_sha256: ${{ steps.bottle.outputs.sha256 }}
bottle_tag: ${{ steps.bottle.outputs.tag }}
steps:
- name: Set up tap with formula
env:
VERSION: ${{ needs.source-tarball.outputs.version }}
TARBALL_SHA: ${{ needs.source-tarball.outputs.tarball_sha256 }}
TAG: ${{ github.ref_name }}
run: |
export FORMULA_DIR="$(brew --repo)/Library/Taps/mavlink/homebrew-tap/Formula"
mkdir -p "$FORMULA_DIR"
python3 -c "
import os
formula = '''class MavsimViewer < Formula
desc \"3D MAVLink vehicle viewer for SITL simulation\"
homepage \"https://github.com/mavlink/mavsim-viewer\"
url \"https://github.com/mavlink/mavsim-viewer/releases/download/{tag}/mavsim-viewer-{version}.tar.gz\"
sha256 \"{sha}\"
license \"BSD-3-Clause\"
depends_on \"cmake\" => :build
def install
system \"cmake\", \"-S\", \".\", \"-B\", \"build\", \"-DCMAKE_BUILD_TYPE=Release\", \"-DHOMEBREW_ALLOW_FETCHCONTENT=ON\", *std_cmake_args
system \"cmake\", \"--build\", \"build\"
system \"cmake\", \"--install\", \"build\", \"--prefix\", prefix
end
test do
assert_predicate bin/\"mavsim-viewer\", :executable?
end
end
'''.format(
tag=os.environ['TAG'],
version=os.environ['VERSION'],
sha=os.environ['TARBALL_SHA'],
)
with open(os.environ['FORMULA_DIR'] + '/mavsim-viewer.rb', 'w') as f:
f.write(formula)
"
- name: Build bottle
run: brew install --build-bottle mavlink/tap/mavsim-viewer
- name: Package bottle
id: bottle
run: |
TAG=${{ github.ref_name }}
brew bottle \
--json \
--root-url="https://github.com/mavlink/mavsim-viewer/releases/download/${TAG}" \
mavlink/tap/mavsim-viewer
BOTTLE_JSON=$(ls mavsim-viewer--*.bottle.json)
BOTTLE_FILE=$(ls mavsim-viewer--*.bottle.tar.gz)
CLEAN_NAME=$(echo "$BOTTLE_FILE" | sed 's/--/-/')
mv "$BOTTLE_FILE" "$CLEAN_NAME"
BOTTLE_SHA=$(python3 -c "
import json, sys
data = json.load(open(sys.argv[1]))
formula = list(data.keys())[0]
tags = data[formula]['bottle']['tags']
tag = list(tags.keys())[0]
print(tags[tag]['sha256'])
" "$BOTTLE_JSON")
BOTTLE_TAG=$(python3 -c "
import json, sys
data = json.load(open(sys.argv[1]))
formula = list(data.keys())[0]
tags = data[formula]['bottle']['tags']
print(list(tags.keys())[0])
" "$BOTTLE_JSON")
echo "sha256=${BOTTLE_SHA}" >> "$GITHUB_OUTPUT"
echo "tag=${BOTTLE_TAG}" >> "$GITHUB_OUTPUT"
echo "file=${CLEAN_NAME}" >> "$GITHUB_OUTPUT"
- name: Upload bottle to release
run: gh release upload ${{ github.ref_name }} ${{ steps.bottle.outputs.file }} --repo ${{ github.repository }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# ── Job 2b: Linux amd64 .deb ──────────────────────────────────────────────
deb-amd64:
name: Deb (amd64)
needs: source-tarball
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get install -y libgl1-mesa-dev libx11-dev libxrandr-dev \
libxinerama-dev libxcursor-dev libxi-dev
- name: Configure
run: |
cmake -B build \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
-DMAVSIM_VERSION=${{ needs.source-tarball.outputs.version }}
- name: Build
run: cmake --build build --config Release
- name: Package .deb
run: cd build && cpack -G DEB
- name: Smoke test
run: |
sudo dpkg -i build/*.deb
which mavsim-viewer
ls /usr/share/mavsim-viewer/models/
ls /usr/share/mavsim-viewer/shaders/
ls /usr/share/mavsim-viewer/fonts/
- name: Upload .deb to release
run: gh release upload ${{ github.ref_name }} build/*.deb
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# ── Job 3: Update Homebrew tap ─────────────────────────────────────────────
update-tap:
name: Update Homebrew tap
needs: [source-tarball, bottle-arm64]
runs-on: ubuntu-latest
steps:
- name: Update formula in tap
env:
VERSION: ${{ needs.source-tarball.outputs.version }}
TAG: ${{ github.ref_name }}
TARBALL_SHA: ${{ needs.source-tarball.outputs.tarball_sha256 }}
ARM64_SHA: ${{ needs.bottle-arm64.outputs.bottle_sha256 }}
ARM64_TAG: ${{ needs.bottle-arm64.outputs.bottle_tag }}
TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
run: |
git clone https://x-access-token:${TAP_TOKEN}@github.com/mavlink/homebrew-tap.git tap
mkdir -p tap/Formula
python3 -c "
import os
formula = '''class MavsimViewer < Formula
desc \"3D MAVLink vehicle viewer for SITL simulation\"
homepage \"https://github.com/mavlink/mavsim-viewer\"
url \"https://github.com/mavlink/mavsim-viewer/releases/download/{tag}/mavsim-viewer-{version}.tar.gz\"
sha256 \"{tarball_sha}\"
license \"BSD-3-Clause\"
bottle do
root_url \"https://github.com/mavlink/mavsim-viewer/releases/download/{tag}\"
sha256 cellar: :any_skip_relocation, {arm64_tag}: \"{arm64_sha}\"
end
depends_on \"cmake\" => :build
def install
system \"cmake\", \"-S\", \".\", \"-B\", \"build\",
\"-DCMAKE_BUILD_TYPE=Release\",
\"-DHOMEBREW_ALLOW_FETCHCONTENT=ON\",
*std_cmake_args
system \"cmake\", \"--build\", \"build\"
system \"cmake\", \"--install\", \"build\", \"--prefix\", prefix
end
test do
assert_predicate bin/\"mavsim-viewer\", :executable?
end
end
'''.format(
tag=os.environ['TAG'],
version=os.environ['VERSION'],
tarball_sha=os.environ['TARBALL_SHA'],
arm64_sha=os.environ['ARM64_SHA'],
arm64_tag=os.environ['ARM64_TAG'],
)
with open('tap/Formula/mavsim-viewer.rb', 'w') as f:
f.write(formula)
"
cd tap
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Formula/mavsim-viewer.rb
git commit -m "mavsim-viewer ${VERSION}"
git push