Repository navigation
155 lines (135 loc) · 4.01 KB
/
Copy pathrelease.yml
File metadata and controls
155 lines (135 loc) · 4.01 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
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: 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
- os: ubuntu-latest
bun_target: bun-linux-arm64
platform: linux-arm64
exe: roboppi
- os: macos-latest
bun_target: bun-darwin-arm64
platform: macos-arm64
exe: roboppi
- os: macos-latest
bun_target: bun-darwin-x64
platform: macos-x64
exe: roboppi
- os: windows-latest
bun_target: bun-windows-x64
platform: windows-x64
exe: roboppi.exe
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: 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