Skip to content

Commit d589697

Browse files
committed
release: Add workflow to build a new release
1 parent 84e6b5e commit d589697

1 file changed

Lines changed: 262 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 262 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,262 @@
1+
name: Release YAMLScript
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version to release (e.g., 1.2.3)'
8+
required: true
9+
type: string
10+
11+
defaults:
12+
run:
13+
shell: bash
14+
15+
env:
16+
VERSION: ${{ inputs.version }}
17+
GRAALVM_VERSION: '22.3.0'
18+
JAVA_VERSION: '17'
19+
20+
jobs:
21+
verify-release:
22+
name: Verify Release Prerequisites
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 0
29+
30+
- name: Check tag exists
31+
run: |
32+
if ! git rev-parse "$VERSION" >/dev/null 2>&1; then
33+
echo "ERROR: Tag $VERSION does not exist"
34+
echo "Please run 'make release o=OLD n=$VERSION' locally first"
35+
exit 1
36+
fi
37+
echo "✓ Tag $VERSION exists"
38+
39+
- name: Check tag points to current commit
40+
run: |
41+
TAG_COMMIT=$(git rev-parse "$VERSION^{commit}")
42+
HEAD_COMMIT=$(git rev-parse HEAD)
43+
if [[ $TAG_COMMIT != $HEAD_COMMIT ]]; then
44+
echo "ERROR: Tag $VERSION does not point to HEAD"
45+
echo "Tag commit: $TAG_COMMIT"
46+
echo "HEAD commit: $HEAD_COMMIT"
47+
exit 1
48+
fi
49+
echo "✓ Tag $VERSION points to HEAD"
50+
51+
- name: Check no existing release with assets
52+
env:
53+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54+
run: |
55+
if gh release view "$VERSION" --json assets --jq '.assets | length' \
56+
2>/dev/null | grep -q '^[1-9]'; then
57+
echo "ERROR: Release $VERSION already has assets"
58+
echo "Delete the release first if you want to rebuild"
59+
exit 1
60+
fi
61+
echo "✓ No existing release assets found"
62+
63+
create-release:
64+
name: Create GitHub Release
65+
needs: verify-release
66+
runs-on: ubuntu-latest
67+
permissions:
68+
contents: write
69+
outputs:
70+
upload_url: ${{ steps.create_release.outputs.upload_url }}
71+
steps:
72+
- name: Checkout code
73+
uses: actions/checkout@v4
74+
with:
75+
ref: ${{ inputs.version }}
76+
77+
- name: Extract release notes from Changes file
78+
id: extract_notes
79+
run: |
80+
if [[ -f Changes ]]; then
81+
# Extract changes for this version from Changes file
82+
awk '/^- version: '"$VERSION"'$/,/^- version:/ {
83+
if (/^- version: '"$VERSION"'$/) next;
84+
if (/^- version:/) exit;
85+
if (/^ changes:/) next;
86+
if (/^ date:/) next;
87+
print
88+
}' Changes | sed 's/^ //' > release-notes.txt
89+
90+
if [[ ! -s release-notes.txt ]]; then
91+
echo "Release $VERSION" > release-notes.txt
92+
fi
93+
else
94+
echo "Release $VERSION" > release-notes.txt
95+
fi
96+
97+
echo "Release notes:"
98+
cat release-notes.txt
99+
100+
- name: Create GitHub Release
101+
id: create_release
102+
env:
103+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
104+
run: |
105+
gh release create "$VERSION" \
106+
--title "YAMLScript $VERSION" \
107+
--notes-file release-notes.txt \
108+
--draft=false \
109+
--prerelease=false
110+
111+
build-linux-x64:
112+
name: Build Linux x64
113+
needs: create-release
114+
runs-on: ubuntu-20.04
115+
steps:
116+
- name: Checkout code
117+
uses: actions/checkout@v4
118+
with:
119+
ref: ${{ inputs.version }}
120+
121+
- name: Set up GraalVM
122+
uses: graalvm/setup-graalvm@v1
123+
with:
124+
java-version: ${{ env.JAVA_VERSION }}
125+
distribution: 'graalvm'
126+
github-token: ${{ secrets.GITHUB_TOKEN }}
127+
native-image-job-reports: 'true'
128+
129+
- name: Install build dependencies
130+
run: |
131+
sudo apt-get update
132+
sudo apt-get install -y build-essential zlib1g-dev
133+
134+
- name: Build and create release archives
135+
run: |
136+
make -C ys build
137+
make -C libys build
138+
make release-build
139+
140+
- name: List created archives
141+
run: ls -lh ys-*.tar.xz libys-*.tar.xz
142+
143+
- name: Upload artifact
144+
uses: actions/upload-artifact@v4
145+
with:
146+
name: linux-x64
147+
path: |
148+
ys-*.tar.xz
149+
libys-*.tar.xz
150+
retention-days: 7
151+
152+
# TODO: Add Linux ARM64 build
153+
# Requires cross-compilation setup or native ARM64 runner
154+
# build-linux-arm64:
155+
# name: Build Linux ARM64
156+
# needs: create-release
157+
# runs-on: ubuntu-latest
158+
# ...
159+
160+
build-macos-x64:
161+
name: Build macOS x64 (Intel)
162+
needs: create-release
163+
runs-on: macos-13
164+
steps:
165+
- name: Checkout code
166+
uses: actions/checkout@v4
167+
with:
168+
ref: ${{ inputs.version }}
169+
170+
- name: Set up GraalVM
171+
uses: graalvm/setup-graalvm@v1
172+
with:
173+
java-version: ${{ env.JAVA_VERSION }}
174+
distribution: 'graalvm'
175+
github-token: ${{ secrets.GITHUB_TOKEN }}
176+
native-image-job-reports: 'true'
177+
178+
- name: Build and create release archives
179+
run: |
180+
make -C ys build
181+
make -C libys build
182+
make release-build
183+
184+
- name: List created archives
185+
run: ls -lh ys-*.tar.xz libys-*.tar.xz
186+
187+
- name: Upload artifact
188+
uses: actions/upload-artifact@v4
189+
with:
190+
name: macos-x64
191+
path: |
192+
ys-*.tar.xz
193+
libys-*.tar.xz
194+
retention-days: 7
195+
196+
build-macos-arm64:
197+
name: Build macOS ARM64 (Apple Silicon)
198+
needs: create-release
199+
runs-on: macos-latest
200+
steps:
201+
- name: Checkout code
202+
uses: actions/checkout@v4
203+
with:
204+
ref: ${{ inputs.version }}
205+
206+
- name: Set up GraalVM
207+
uses: graalvm/setup-graalvm@v1
208+
with:
209+
java-version: ${{ env.JAVA_VERSION }}
210+
distribution: 'graalvm'
211+
github-token: ${{ secrets.GITHUB_TOKEN }}
212+
native-image-job-reports: 'true'
213+
214+
- name: Build and create release archives
215+
run: |
216+
make -C ys build
217+
make -C libys build
218+
make release-build
219+
220+
- name: List created archives
221+
run: ls -lh ys-*.tar.xz libys-*.tar.xz
222+
223+
- name: Upload artifact
224+
uses: actions/upload-artifact@v4
225+
with:
226+
name: macos-arm64
227+
path: |
228+
ys-*.tar.xz
229+
libys-*.tar.xz
230+
retention-days: 7
231+
232+
upload-assets:
233+
name: Upload Release Assets
234+
needs:
235+
- build-linux-x64
236+
# - build-linux-arm64 # TODO: Add when ARM64 build is implemented
237+
- build-macos-x64
238+
- build-macos-arm64
239+
runs-on: ubuntu-latest
240+
permissions:
241+
contents: write
242+
steps:
243+
- name: Checkout code
244+
uses: actions/checkout@v4
245+
with:
246+
ref: ${{ inputs.version }}
247+
248+
- name: Download all artifacts
249+
uses: actions/download-artifact@v4
250+
251+
- name: Prepare release assets
252+
run: |
253+
find . -type f -name "*.tar.xz" -exec mv {} . \;
254+
ls -lh *.tar.xz
255+
256+
- name: Upload assets to GitHub Release
257+
env:
258+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
259+
run: |
260+
gh release upload "$VERSION" ys-*.tar.xz libys-*.tar.xz --clobber
261+
echo "Release $VERSION complete!"
262+
gh release view "$VERSION"

0 commit comments

Comments
 (0)