-
Notifications
You must be signed in to change notification settings - Fork 1
184 lines (161 loc) · 5.78 KB
/
Copy pathrelease-loom.yml
File metadata and controls
184 lines (161 loc) · 5.78 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
name: Release Loom
# Loom is EXPERIMENTAL: GitHub-release-only (no crates.io publish) while the
# `loom-0.x` series lasts — see experiment-loom/README.md and plan.md §6.
on:
push:
tags:
- 'loom-*'
workflow_dispatch:
inputs:
tag:
description: 'Release tag (e.g., loom-0.1.0)'
required: true
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
resolve-version:
name: Resolve version
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.resolve.outputs.tag }}
version: ${{ steps.resolve.outputs.version }}
steps:
- name: Resolve tag and version
id: resolve
shell: bash
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
TAG="${{ github.event.inputs.tag }}"
else
TAG="${{ github.ref_name }}"
fi
if [[ "$TAG" != loom-* ]]; then
echo "ERROR: tag '$TAG' is not a Loom release (must start with loom-)"
exit 1
fi
VERSION="${TAG#loom-}"
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "Building Loom $VERSION from tag $TAG"
build-loom:
name: Build Loom (${{ matrix.target }})
needs: [resolve-version]
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
archive: tar.gz
- target: x86_64-apple-darwin
os: macos-latest
archive: tar.gz
- target: aarch64-apple-darwin
os: macos-latest
archive: tar.gz
- target: x86_64-pc-windows-msvc
os: windows-latest
archive: zip
steps:
- uses: actions/checkout@v6
with:
ref: ${{ needs.resolve-version.outputs.tag }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
cache-dependency-path: experiment-loom/web/package-lock.json
- name: Verify Cargo.toml version matches tag
shell: bash
run: |
CARGO_VERSION=$(grep '^version' experiment-loom/Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')
TAG_VERSION="${{ needs.resolve-version.outputs.version }}"
if [ "$CARGO_VERSION" != "$TAG_VERSION" ]; then
echo "ERROR: experiment-loom/Cargo.toml version ($CARGO_VERSION) does not match tag version ($TAG_VERSION)"
exit 1
fi
- name: Build frontend (embedded via rust-embed)
shell: bash
working-directory: experiment-loom/web
run: |
npm ci
npm run build
test -f dist/index.html
- name: Build release binary
run: cargo build --release --manifest-path experiment-loom/Cargo.toml --target ${{ matrix.target }}
- name: Package (Unix)
if: matrix.archive == 'tar.gz'
shell: bash
run: |
BINARY=target/${{ matrix.target }}/release/straymark-loom
ARCHIVE=straymark-loom-v${{ needs.resolve-version.outputs.version }}-${{ matrix.target }}.tar.gz
tar czf "$ARCHIVE" -C "$(dirname "$BINARY")" "$(basename "$BINARY")"
echo "ARCHIVE=$ARCHIVE" >> "$GITHUB_ENV"
- name: Package (Windows)
if: matrix.archive == 'zip'
shell: bash
run: |
BINARY=target/${{ matrix.target }}/release/straymark-loom.exe
ARCHIVE=straymark-loom-v${{ needs.resolve-version.outputs.version }}-${{ matrix.target }}.zip
cp "$BINARY" straymark-loom.exe
7z a "$ARCHIVE" straymark-loom.exe
echo "ARCHIVE=$ARCHIVE" >> "$GITHUB_ENV"
- name: Upload binary artifact
uses: actions/upload-artifact@v7
with:
name: loom-${{ matrix.target }}
path: ${{ env.ARCHIVE }}
upload-to-release:
name: Upload binaries to release
needs: [resolve-version, build-loom]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Download all artifacts
uses: actions/download-artifact@v8
with:
path: release-artifacts
- name: Collect release files
run: |
mkdir -p release
find release-artifacts -type f \( -name "*.zip" -o -name "*.tar.gz" \) -exec cp {} release/ \;
ls -la release/
- name: Create or update GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
TAG="${{ needs.resolve-version.outputs.tag }}"
VERSION="${{ needs.resolve-version.outputs.version }}"
if gh release view "$TAG" > /dev/null 2>&1; then
echo "Release $TAG exists, uploading binaries..."
gh release upload "$TAG" release/* --clobber
else
echo "Creating release $TAG..."
# NOT --latest: Loom is experimental; the CLI release stays the
# repo's "latest" so update flows are unaffected.
gh release create "$TAG" \
--title "StrayMark Loom $VERSION (EXPERIMENTAL)" \
--generate-notes \
--latest=false \
release/*
fi
- name: Delete previous Loom releases
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
CURRENT_TAG="${{ needs.resolve-version.outputs.tag }}"
gh release list --json tagName --jq '.[].tagName' | while read -r tag; do
if [[ "$tag" == loom-* && "$tag" != "$CURRENT_TAG" ]]; then
echo "Deleting old release $tag..."
gh release delete "$tag" --yes --cleanup-tag
fi
done