-
-
Notifications
You must be signed in to change notification settings - Fork 0
114 lines (102 loc) · 3.84 KB
/
release.yml
File metadata and controls
114 lines (102 loc) · 3.84 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
# SPDX-License-Identifier: MPL-2.0
#
# Release (ADR-019 / #260 S2). On a `v*` tag: build the AffineScript
# compiler for each supported platform, attach the raw per-platform
# binaries plus a single `SHA256SUMS` manifest to the GitHub Release.
# Releases are the CANONICAL distribution artifact; the thin Deno/JSR
# shim `@hyperpolymath/affinescript` (#260 S3) downloads + checksum-
# verifies the binary named for its host triple against SHA256SUMS.
#
# Asset contract (ADR-019; do not rename without amending the ADR + the
# shim): `affinescript-<target>` raw executables + `SHA256SUMS`
# (sha256sum format: "<hex> affinescript-<target>"). Targets:
# linux-x64, macos-x64, macos-arm64. windows-x64 is a tracked
# follow-up (native OCaml Windows CI is flaky; #260 S2 is bounded to
# the three POSIX targets).
#
# Asset handling uses the runner-native `gh` CLI (GITHUB_TOKEN), so no
# third-party action needs SHA-pinning beyond checkout + setup-ocaml.
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
prepare:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Create the release (idempotent)
env:
GH_TOKEN: ${{ github.token }}
run: |
tag="${GITHUB_REF_NAME}"
if gh release view "$tag" >/dev/null 2>&1; then
echo "release $tag already exists; reusing"
else
gh release create "$tag" --generate-notes --verify-tag --title "$tag"
fi
build:
needs: prepare
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: linux-x64
- os: macos-15-intel
target: macos-x64
- os: macos-14
target: macos-arm64
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up OCaml
uses: ocaml/setup-ocaml@e32b06a3e831ff2fbc6f08cf35be2085e3918014 # v3
with:
ocaml-compiler: "5.1"
- name: Install dependencies
run: opam install . --deps-only --yes
- name: Bake release version into source (#297)
# Single source of truth for the compiler version string lives
# in `lib/version.ml`; `dune-project` mirrors it for opam. The
# release workflow rewrites both from the tag so every emitted
# binary self-reports the right number (--version, REPL banner,
# LSP serverInfo, ONNX producer_version).
run: |
v="${GITHUB_REF_NAME#v}"
sed -i "s/^let value = .*/let value = \"$v\"/" lib/version.ml
sed -i "s/^(version .*)/(version $v)/" .build/dune-project
echo "Baked version: $v"
grep '^let value' lib/version.ml
grep '^(version' .build/dune-project
- name: Build release
run: opam exec -- dune build --release
- name: Stage the binary
run: |
install -m 0755 _build/default/bin/main.exe \
"affinescript-${{ matrix.target }}"
- name: Upload the binary to the release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release upload "${GITHUB_REF_NAME}" \
"affinescript-${{ matrix.target }}" --clobber
checksums:
needs: build
runs-on: ubuntu-latest
steps:
- name: Collect binaries and publish SHA256SUMS
env:
GH_TOKEN: ${{ github.token }}
run: |
tag="${GITHUB_REF_NAME}"
mkdir -p dl
gh release download "$tag" --repo "$GITHUB_REPOSITORY" --dir dl --pattern 'affinescript-*'
( cd dl && sha256sum affinescript-* | sort -k2 > SHA256SUMS )
cat dl/SHA256SUMS
gh release upload "$tag" --repo "$GITHUB_REPOSITORY" dl/SHA256SUMS --clobber