-
Notifications
You must be signed in to change notification settings - Fork 1
205 lines (180 loc) · 7.48 KB
/
Copy pathrelease.yml
File metadata and controls
205 lines (180 loc) · 7.48 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
name: Release
# Build and publish the Xi toolchain (compiler `xc` + REPL `xi`) for several
# targets. Pushing a version tag (e.g. v0.1.0) creates a GitHub Release with a
# tarball per platform. Manual runs (workflow_dispatch) just upload artifacts.
on:
push:
tags: ["v*"]
workflow_dispatch:
permissions:
contents: write
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: ${{ matrix.target }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
# Each target bootstraps by downloading the PREVIOUS release binary for
# the same OS/arch (there is no checked-in C seed). macos-x86_64 has no
# seed and is produced by the separate cross-compile job below instead.
include:
- { runner: ubuntu-latest, target: linux-x86_64 }
- { runner: ubuntu-24.04-arm, target: linux-arm64 }
- { runner: macos-14, target: macos-arm64 }
env:
# fetch-seed.sh uses this to avoid GitHub API rate limits when resolving
# the latest release to bootstrap from.
GH_TOKEN: ${{ github.token }}
steps:
- uses: actions/checkout@v4
- name: Build toolchain (bootstrap from released seed)
run: ./compiler/bootstrap.sh
- name: Verify self-hosting fixpoint
run: ./compiler/selfhost.sh
- name: Package
id: package
run: |
set -euo pipefail
VERSION="${GITHUB_REF_NAME:-dev}"
DIST="xi-${VERSION}-${{ matrix.target }}"
mkdir -p "$DIST/libexec"
cp compiler/xc "$DIST/libexec/xc"
cp bin/xi "$DIST/libexec/xi"
art="$(scripts/package.sh "$DIST" "${{ matrix.target }}" "$VERSION")"
echo "artifact=$art" >> "$GITHUB_OUTPUT"
- name: Smoke-test packaged bundle
run: |
set -euo pipefail
VERSION="${GITHUB_REF_NAME:-dev}"
DIST="xi-${VERSION}-${{ matrix.target }}"
tar -xzf "$DIST.tar.gz" -C "$RUNNER_TEMP"
BUNDLE="$RUNNER_TEMP/$DIST"
# compile-and-run via the wrapper (exercises XC_RUNTIME/XC_STD + cc)
cat > "$RUNNER_TEMP/smoke.xi" <<'EOF'
async entry main(args: String[]) -> Integer {
system.stdout.writeln("smoke ok")
return 0
}
EOF
XC_OUT="$RUNNER_TEMP/out" "$BUNDLE/bin/xc" "$RUNNER_TEMP/smoke.xi"
got="$("$RUNNER_TEMP/out/smoke")"
test "$got" = "smoke ok" || { echo "::error::bundle smoke test failed: '$got'"; exit 1; }
# REPL accepts input and evaluates
repl="$(printf 'system.stdout.writeln("repl ok")\n' | "$BUNDLE/bin/xi")"
echo "$repl" | grep -q "repl ok" || { echo "::error::bundle REPL smoke test failed"; exit 1; }
echo "bundle smoke test passed"
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target }}
path: ${{ steps.package.outputs.artifact }}
- name: Attach to release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
with:
files: ${{ steps.package.outputs.artifact }}
fail_on_unmatched_files: true
generate_release_notes: true
# Intel macOS has no seed binary to bootstrap from, so we build the arm64
# compiler normally, then cross-compile its generated C for x86_64. The
# generated C is platform-independent, so this produces a genuine Intel build.
macos-x86_64:
name: macos-x86_64 (cross)
runs-on: macos-14
env:
GH_TOKEN: ${{ github.token }}
XC_KEEP_C: "1" # keep build/*.gen.c — the cross-compile step needs it
steps:
- uses: actions/checkout@v4
- name: Bootstrap arm64 (emits the compiler's generated C)
run: ./compiler/bootstrap.sh
- name: Cross-compile x86_64 binaries
run: |
set -euo pipefail
VERSION="${GITHUB_REF_NAME:-dev}"
DIST="xi-${VERSION}-macos-x86_64"
mkdir -p "$DIST/libexec"
clang -arch x86_64 -mmacosx-version-min=11.0 -std=c99 -O2 -w \
-Wno-implicit-int -Wno-implicit-function-declaration \
-Wno-int-conversion -Wno-incompatible-pointer-types -I runtime \
build/xc.gen.c runtime/runtime.c -o "$DIST/libexec/xc" -lm
clang -arch x86_64 -mmacosx-version-min=11.0 -std=c99 -O2 -w \
-Wno-implicit-int -Wno-implicit-function-declaration \
-Wno-int-conversion -Wno-incompatible-pointer-types -I runtime \
build/xi.gen.c runtime/runtime.c -o "$DIST/libexec/xi" -lm
file "$DIST/libexec/xc" "$DIST/libexec/xi"
file "$DIST/libexec/xc" | grep -q "x86_64" \
|| { echo "::error::cross build did not produce an x86_64 binary"; exit 1; }
- name: Package
id: package
run: |
set -euo pipefail
VERSION="${GITHUB_REF_NAME:-dev}"
art="$(scripts/package.sh "xi-${VERSION}-macos-x86_64" macos-x86_64 "$VERSION")"
echo "artifact=$art" >> "$GITHUB_OUTPUT"
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: macos-x86_64
path: ${{ steps.package.outputs.artifact }}
- name: Attach to release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
with:
files: ${{ steps.package.outputs.artifact }}
fail_on_unmatched_files: true
generate_release_notes: true
# After all platform tarballs are attached to the release, refresh the
# Homebrew formula (urls + sha256) and push it to the tap repo. Gated on a
# token secret for an immediate bump; without it this is skipped and the tap
# self-syncs instead — code-by-sia/homebrew-xi runs an hourly `sync.yml` that
# regenerates the formula from the latest release (no cross-repo token needed),
# so the tap never lags by more than ~1h. See packaging/homebrew/README.md.
homebrew:
name: bump homebrew tap
needs: [build, macos-x86_64]
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check for tap token
id: gate
env:
TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
run: |
if [ -z "${TOKEN:-}" ]; then
echo "::notice::HOMEBREW_TAP_TOKEN not set — skipping formula bump"
echo "go=false" >> "$GITHUB_OUTPUT"
else
echo "go=true" >> "$GITHUB_OUTPUT"
fi
- name: Regenerate formula from published release assets
if: steps.gate.outputs.go == 'true'
run: |
set -euo pipefail
VERSION="${GITHUB_REF_NAME#v}"
scripts/update-formula.sh "$VERSION"
- name: Push to code-by-sia/homebrew-xi
if: steps.gate.outputs.go == 'true'
env:
TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
run: |
set -euo pipefail
VER="${GITHUB_REF_NAME#v}"
git clone "https://x-access-token:${TOKEN}@github.com/code-by-sia/homebrew-xi.git" tap
mkdir -p tap/Formula
cp packaging/homebrew/xi.rb tap/Formula/xi.rb
cd tap
git config user.name "xi release"
git config user.email "9437465+code-by-sia@users.noreply.github.com"
git add Formula/xi.rb
if git diff --cached --quiet; then
echo "formula already up to date"
else
git commit -m "xi ${VER}"
git push
fi