Repository navigation
126 lines (115 loc) · 4.15 KB
/
Copy pathrelease.yml
File metadata and controls
126 lines (115 loc) · 4.15 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
name: Release binaries
on:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
build:
name: Build ${{ matrix.platform }}
runs-on: ${{ matrix.os }}
env:
# Tree-sitter and its curated grammars are compiled into the executable.
CGO_ENABLED: "1"
MACOSX_DEPLOYMENT_TARGET: "14.0"
strategy:
matrix:
include:
- os: macos-15
platform: darwin_arm64
# macos-13 (Intel) runners are retired; macos-15-intel is the
# supported Intel label through 2027.
- os: macos-15-intel
platform: darwin_amd64
- os: ubuntu-24.04-arm
platform: linux_arm64
- os: ubuntu-24.04
platform: linux_amd64
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v7
with:
go-version-file: apps/cli/go.mod
cache: true
cache-dependency-path: |
go.sum
apps/cli/go.sum
# The released `kit` is the Ard + Cooper client in apps/cli.
- uses: ./.github/actions/setup-ard
- name: Build release binary
shell: bash
run: |
set -euo pipefail
if [[ ! "$GITHUB_REF_NAME" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?$ ]]; then
echo "Expected a release tag of the form vX.Y.Z or vX.Y.Z-rc.N" >&2
exit 1
fi
test -s "docs/releases/${GITHUB_REF_NAME}.md"
mkdir -p dist
cd apps/cli
# Build values replace -ldflags -X stamping; with Go 1.22 and newer,
# -s also implies -w. A release names no channel, so it resolves the
# user's Kit home as it always has.
GOFLAGS="${GOFLAGS:+$GOFLAGS }-trimpath -ldflags=-s" \
ard build main.ard --release \
--define version="${GITHUB_REF_NAME#v}" --define commit="$GITHUB_SHA" \
--out "$GITHUB_WORKSPACE/dist/kit"
- name: Smoke test packaged executable
shell: bash
run: |
set -euo pipefail
tar -czf "kit_${GITHUB_REF_NAME}_${{ matrix.platform }}.tar.gz" -C dist kit
smoke_dir=$(mktemp -d)
trap 'rm -rf "$smoke_dir"' EXIT
tar -xzf "kit_${GITHUB_REF_NAME}_${{ matrix.platform }}.tar.gz" -C "$smoke_dir"
export KIT_HOME="$smoke_dir/home"
actual=$("$smoke_dir/kit" version | head -n 1)
expected="kit ${GITHUB_REF_NAME#v} ($GITHUB_SHA)"
if [[ "$actual" != "$expected" ]]; then
printf 'Expected %s; got %s\n' "$expected" "$actual" >&2
exit 1
fi
# A release names no channel, so the home it resolves must be the one
# KIT_HOME explicitly points at. Any other home means this build is
# not behaving as the shared one.
reported=$("$smoke_dir/kit" version | sed -n 's/^home: //p')
if [[ -n "$reported" && "$reported" != "$KIT_HOME" ]]; then
echo "A release build reported an isolated Kit home: $reported" >&2
exit 1
fi
"$smoke_dir/kit" --help
- uses: actions/upload-artifact@v7
with:
name: kit-${{ matrix.platform }}
path: kit_*.tar.gz
if-no-files-found: error
release:
name: Create GitHub release
needs: [build]
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
- uses: actions/download-artifact@v8
with:
path: artifacts
merge-multiple: true
- name: Create release and upload assets
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
# Release candidates are prereleases: they never become the latest
# release, which in-app release history and the OpenAPI
# compatibility gate read.
prerelease=()
if [[ "$GITHUB_REF_NAME" == *-rc.* ]]; then
prerelease=(--prerelease)
fi
gh release create "$GITHUB_REF_NAME" \
--repo "$GITHUB_REPOSITORY" \
--title "$GITHUB_REF_NAME" \
--notes-file "docs/releases/${GITHUB_REF_NAME}.md" \
"${prerelease[@]}" \
artifacts/*.tar.gz