Repository navigation
219 lines (186 loc) · 6.12 KB
/
Copy pathrelease.yml
File metadata and controls
219 lines (186 loc) · 6.12 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
name: release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: "Tag to build and upload (e.g. v1.2.3)"
required: true
type: string
permissions:
contents: write
jobs:
meta:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.meta.outputs.tag }}
steps:
- id: meta
shell: bash
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "tag=${{ github.event.inputs.tag }}" >> "$GITHUB_OUTPUT"
else
echo "tag=${{ github.ref_name }}" >> "$GITHUB_OUTPUT"
fi
verify:
runs-on: ubuntu-latest
timeout-minutes: 30
needs: meta
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ needs.meta.outputs.tag }}
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: "1.3.8"
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Run CI checks
run: make test-all
create_release:
runs-on: ubuntu-latest
needs: [meta, verify]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ needs.meta.outputs.tag }}
- name: Create GitHub Release (if missing)
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG='${{ needs.meta.outputs.tag }}'
if gh release view "$TAG" >/dev/null 2>&1; then
echo "Release already exists: $TAG"
exit 0
fi
gh release create "$TAG" --generate-notes
build_upload:
needs: [meta, create_release]
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
bun_target: bun-linux-x64
platform: linux-x64
exe: roboppi
opentui_pkg: ""
- os: ubuntu-latest
bun_target: bun-linux-arm64
platform: linux-arm64
exe: roboppi
opentui_pkg: "@opentui/core-linux-arm64"
- os: macos-latest
bun_target: bun-darwin-arm64
platform: macos-arm64
exe: roboppi
opentui_pkg: ""
- os: macos-latest
bun_target: bun-darwin-x64
platform: macos-x64
exe: roboppi
opentui_pkg: "@opentui/core-darwin-x64"
- os: windows-latest
bun_target: bun-windows-x64
platform: windows-x64
exe: roboppi.exe
opentui_pkg: ""
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ needs.meta.outputs.tag }}
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: "1.3.8"
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Install OpenTUI platform package (for cross builds)
if: ${{ matrix.opentui_pkg != '' }}
shell: bash
env:
PKG: ${{ matrix.opentui_pkg }}
run: |
set -euo pipefail
VER=$(node -e "const p=require('./package.json'); process.stdout.write(String((p.dependencies||{})['@opentui/core']||''));")
if [[ -z "$VER" ]]; then
echo "@opentui/core version not found in package.json" >&2
exit 1
fi
TARBALL=$(VER="$VER" python - <<'PY'
import json
import os
import urllib.request
import urllib.parse
pkg = os.environ['PKG']
ver = os.environ['VER']
meta_url = 'https://registry.npmjs.org/' + urllib.parse.quote(pkg, safe='')
with urllib.request.urlopen(meta_url) as r:
meta = json.load(r)
try:
tarball = meta['versions'][ver]['dist']['tarball']
except Exception as e:
raise SystemExit(f'could not resolve tarball for {pkg}@{ver}: {e}')
print(tarball)
PY
)
echo "Installing $PKG@$VER from $TARBALL" >&2
rm -f /tmp/opentui-pkg.tgz
curl -fsSL "$TARBALL" -o /tmp/opentui-pkg.tgz
SCOPE=$(node -e "const s=process.env.PKG; process.stdout.write(s.startsWith('@')?s.split('/')[0].slice(1):'');")
NAME=$(node -e "const s=process.env.PKG; process.stdout.write(s.startsWith('@')?s.split('/')[1]:s);")
if [[ -z "$SCOPE" || -z "$NAME" ]]; then
echo "Could not parse scoped package name: $PKG" >&2
exit 1
fi
DEST="node_modules/@${SCOPE}/${NAME}"
mkdir -p "$DEST"
tar -xzf /tmp/opentui-pkg.tgz -C "$DEST" --strip-components=1 package
- name: Build standalone binary
shell: bash
run: |
rm -rf dist release stage
mkdir -p dist
bun build --compile --target=${{ matrix.bun_target }} --outfile "dist/${{ matrix.exe }}" src/cli.ts
- name: Package (tar.gz)
shell: bash
run: |
TAG='${{ needs.meta.outputs.tag }}'
ASSET="roboppi-${TAG}-${{ matrix.platform }}"
mkdir -p stage release
cp "dist/${{ matrix.exe }}" stage/
cp README.md stage/
if [[ -f README.ja.md ]]; then cp README.ja.md stage/; fi
tar -czf "release/${ASSET}.tar.gz" -C stage .
ASSET="$ASSET" python - <<'PY'
import os
import hashlib
from pathlib import Path
asset = os.environ["ASSET"]
p = Path("release") / f"{asset}.tar.gz"
h = hashlib.sha256(p.read_bytes()).hexdigest()
(p.parent / (p.name + ".sha256")).write_text(f"{h} {p.name}\n", encoding="utf-8")
PY
- name: Upload assets to GitHub Release
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG='${{ needs.meta.outputs.tag }}'
ASSET="roboppi-${TAG}-${{ matrix.platform }}"
gh release upload "$TAG" \
"release/${ASSET}.tar.gz" \
"release/${ASSET}.tar.gz.sha256" \
--clobber