-
Notifications
You must be signed in to change notification settings - Fork 1
200 lines (180 loc) · 6.94 KB
/
Copy pathrelease.yml
File metadata and controls
200 lines (180 loc) · 6.94 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
name: release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: "Tag to release (e.g. v0.1.0)"
required: true
permissions:
contents: write
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- os: macos-latest
bun-target: bun-darwin-arm64
triple: aarch64-apple-darwin
- os: macos-latest
bun-target: bun-darwin-x64
triple: x86_64-apple-darwin
- os: ubuntu-latest
bun-target: bun-linux-x64
triple: x86_64-unknown-linux-gnu
- os: ubuntu-latest
bun-target: bun-linux-arm64
triple: aarch64-unknown-linux-gnu
- os: windows-latest
bun-target: bun-windows-x64
triple: x86_64-pc-windows-msvc
experimental: true
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental == true }}
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
bun-version: "1.2.10"
- name: Install deps
run: bun install --frozen-lockfile
- name: Install rcodesign (darwin signing)
if: startsWith(matrix.bun-target, 'bun-darwin-')
shell: bash
env:
RCODESIGN_VERSION: "0.29.0"
run: |
set -e
case "$(uname -sm)" in
"Darwin arm64") asset="aarch64-apple-darwin" ;;
"Darwin x86_64") asset="x86_64-apple-darwin" ;;
"Linux x86_64") asset="x86_64-unknown-linux-musl" ;;
*) echo "unsupported host for rcodesign"; exit 1 ;;
esac
url="https://github.com/indygreg/apple-platform-rs/releases/download/apple-codesign/${RCODESIGN_VERSION}/apple-codesign-${RCODESIGN_VERSION}-${asset}.tar.gz"
curl -fsSL "$url" | tar -xz
sudo mv "apple-codesign-${RCODESIGN_VERSION}-${asset}/rcodesign" /usr/local/bin/rcodesign
rcodesign --version
- name: Build binary
shell: bash
env:
BUN_TARGET: ${{ matrix.bun-target }}
run: bun run scripts/build-binaries.ts "$BUN_TARGET"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: quoteforge-${{ matrix.triple }}
path: |
dist/quoteforge-${{ matrix.triple }}.tar.gz
dist/quoteforge-${{ matrix.triple }}.tar.gz.sha256
dist/quoteforge-${{ matrix.triple }}.zip
dist/quoteforge-${{ matrix.triple }}.zip.sha256
if-no-files-found: ignore
release:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: List artifacts
run: ls -la dist/
- name: Publish release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.event.inputs.tag || github.ref_name }}
files: |
dist/quoteforge-*.tar.gz
dist/quoteforge-*.tar.gz.sha256
dist/quoteforge-*.zip
dist/quoteforge-*.zip.sha256
generate_release_notes: true
fail_on_unmatched_files: false
bump-homebrew:
needs: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Resolve version
id: meta
env:
INPUT_TAG: ${{ github.event.inputs.tag }}
REF_TAG: ${{ github.ref_name }}
run: |
tag="${INPUT_TAG:-$REF_TAG}"
version="${tag#v}"
echo "tag=$tag" >> "$GITHUB_OUTPUT"
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Download sha256 files from release
id: sha
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ steps.meta.outputs.tag }}
run: |
set -e
tmp=$(mktemp -d)
for triple in aarch64-apple-darwin x86_64-apple-darwin aarch64-unknown-linux-gnu x86_64-unknown-linux-gnu; do
gh release download "$TAG" --repo "$GITHUB_REPOSITORY" \
--pattern "quoteforge-$triple.tar.gz.sha256" --dir "$tmp" || true
done
arm_mac=$(awk '{print $1}' "$tmp/quoteforge-aarch64-apple-darwin.tar.gz.sha256" 2>/dev/null || echo "")
x64_mac=$(awk '{print $1}' "$tmp/quoteforge-x86_64-apple-darwin.tar.gz.sha256" 2>/dev/null || echo "")
arm_linux=$(awk '{print $1}' "$tmp/quoteforge-aarch64-unknown-linux-gnu.tar.gz.sha256" 2>/dev/null || echo "")
x64_linux=$(awk '{print $1}' "$tmp/quoteforge-x86_64-unknown-linux-gnu.tar.gz.sha256" 2>/dev/null || echo "")
echo "arm_mac=$arm_mac" >> "$GITHUB_OUTPUT"
echo "x64_mac=$x64_mac" >> "$GITHUB_OUTPUT"
echo "arm_linux=$arm_linux" >> "$GITHUB_OUTPUT"
echo "x64_linux=$x64_linux" >> "$GITHUB_OUTPUT"
- name: Render formula
env:
VERSION: ${{ steps.meta.outputs.version }}
ARM_MAC: ${{ steps.sha.outputs.arm_mac }}
X64_MAC: ${{ steps.sha.outputs.x64_mac }}
ARM_LINUX: ${{ steps.sha.outputs.arm_linux }}
X64_LINUX: ${{ steps.sha.outputs.x64_linux }}
run: |
set -e
mkdir -p rendered/Formula
cp packaging/homebrew/quoteforge.rb rendered/Formula/quoteforge.rb
sed -i "s/^ version \".*\"/ version \"$VERSION\"/" rendered/Formula/quoteforge.rb
sed -i "s/REPLACE_WITH_AARCH64_DARWIN_SHA/$ARM_MAC/" rendered/Formula/quoteforge.rb
sed -i "s/REPLACE_WITH_X86_64_DARWIN_SHA/$X64_MAC/" rendered/Formula/quoteforge.rb
sed -i "s/REPLACE_WITH_AARCH64_LINUX_SHA/$ARM_LINUX/" rendered/Formula/quoteforge.rb
sed -i "s/REPLACE_WITH_X86_64_LINUX_SHA/$X64_LINUX/" rendered/Formula/quoteforge.rb
cat rendered/Formula/quoteforge.rb
- name: Checkout tap
uses: actions/checkout@v4
with:
repository: lordvins226/homebrew-quoteforge
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
path: tap
- name: Commit and open PR
env:
GH_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
VERSION: ${{ steps.meta.outputs.version }}
run: |
set -e
mkdir -p tap/Formula
cp rendered/Formula/quoteforge.rb tap/Formula/quoteforge.rb
cd tap
branch="bump-quoteforge-$VERSION"
git config user.name "quoteforge-bot"
git config user.email "actions@users.noreply.github.com"
git checkout -b "$branch"
git add Formula/quoteforge.rb
if git diff --cached --quiet; then
echo "No formula changes; skipping PR"
exit 0
fi
git commit -m "quoteforge $VERSION"
git push --set-upstream origin "$branch" --force
gh pr create \
--title "quoteforge $VERSION" \
--body "Auto-generated by quoteforge release workflow." \
--base main || echo "PR already exists"