Skip to content

Commit c2ac973

Browse files
Add GHA workflow for creating releases with pre-built binaries
1 parent 9fc8aec commit c2ac973

File tree

2 files changed

+112
-0
lines changed

2 files changed

+112
-0
lines changed

.github/workflows/release.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Create Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "*"
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
build-macos:
13+
runs-on: macos-15
14+
steps:
15+
- uses: actions/checkout@v4
16+
- run: ./Utilities/build-release.py -o wasmkit-x86_64-apple-macos.tar.gz -- --triple x86_64-apple-macos
17+
- run: ./Utilities/build-release.py -o wasmkit-arm64-apple-macos.tar.gz -- --triple arm64-apple-macos
18+
- uses: actions/upload-artifact@v4
19+
with:
20+
name: release-wasmkit-x86_64-apple-macos
21+
path: wasmkit-x86_64-apple-macos.tar.gz
22+
- uses: actions/upload-artifact@v4
23+
with:
24+
name: release-wasmkit-arm64-apple-macos
25+
path: wasmkit-arm64-apple-macos.tar.gz
26+
27+
build-musl:
28+
runs-on: ubuntu-24.04
29+
steps:
30+
- uses: actions/checkout@v4
31+
- name: Configure container
32+
run: |
33+
docker run -dit --name build-container -v $PWD:/workspace -w /workspace swift:6.0.1-jammy
34+
echo 'docker exec -i build-container "$@"' > ./build-exec
35+
chmod +x ./build-exec
36+
- name: Install Static Linux SDK
37+
run: ./build-exec swift sdk install "https://download.swift.org/swift-6.0.1-release/static-sdk/swift-6.0.1-RELEASE/swift-6.0.1-RELEASE_static-linux-0.0.1.artifactbundle.tar.gz" --checksum "d4f46ba40e11e697387468e18987ee622908bc350310d8af54eb5e17c2ff5481"
38+
39+
- run: ./build-exec ./Utilities/build-release.py -o wasmkit-x86_64-swift-linux-musl.tar.gz -- --swift-sdk x86_64-swift-linux-musl
40+
- run: ./build-exec ./Utilities/build-release.py -o wasmkit-aarch64-swift-linux-musl.tar.gz -- --swift-sdk aarch64-swift-linux-musl
41+
- uses: actions/upload-artifact@v4
42+
with:
43+
name: release-wasmkit-x86_64-swift-linux-musl
44+
path: wasmkit-x86_64-swift-linux-musl.tar.gz
45+
- uses: actions/upload-artifact@v4
46+
with:
47+
name: release-wasmkit-aarch64-swift-linux-musl
48+
path: wasmkit-aarch64-swift-linux-musl.tar.gz
49+
50+
create-release:
51+
needs:
52+
- build-macos
53+
- build-musl
54+
runs-on: ubuntu-24.04
55+
steps:
56+
- uses: actions/checkout@v4
57+
- uses: actions/download-artifact@v4
58+
with:
59+
pattern: release-wasmkit-*
60+
path: ./release/
61+
- name: Create Release
62+
run: |
63+
VERSION=$(echo ${{ github.ref_name }} | sed 's/^v//')
64+
echo "Creating release $VERSION"
65+
gh release create $VERSION --title $VERSION --notes "Release $VERSION" ./release/wasmkit-*
66+
env:
67+
GH_TOKEN: ${{ github.token }}

Utilities/build-release.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env python3
2+
#
3+
# Builds the release tarball of the wasmkit binary
4+
5+
import os
6+
import sys
7+
import subprocess
8+
import shutil
9+
import tarfile
10+
11+
SOURCE_ROOT = os.path.relpath(os.path.join(os.path.dirname(__file__), ".."))
12+
13+
def run(arguments):
14+
print("Running: " + " ".join(arguments))
15+
subprocess.run(arguments, check=True)
16+
17+
def main():
18+
import argparse
19+
parser = argparse.ArgumentParser()
20+
parser.add_argument("-o", "--output", required=True)
21+
parser.add_argument("extra_build_args", nargs="*")
22+
23+
args = parser.parse_args()
24+
25+
build_args = ["swift", "build", "-c", "release", "--product", "wasmkit-cli", "--package-path", SOURCE_ROOT] + args.extra_build_args
26+
bin_path = subprocess.check_output(build_args + ["--show-bin-path"], text=True).strip()
27+
28+
run(build_args)
29+
30+
if not args.output.endswith(".tar.gz"):
31+
raise ValueError("Output file name must end with .tar.gz")
32+
archive_path = args.output[:-len(".tar.gz")]
33+
shutil.rmtree(archive_path, ignore_errors=True)
34+
os.makedirs(archive_path)
35+
36+
dest_exe_path = os.path.join(archive_path, "wasmkit")
37+
shutil.copy(os.path.join(bin_path, "wasmkit-cli"), dest_exe_path)
38+
39+
with tarfile.open(args.output, "w:gz") as tar:
40+
tar.add(archive_path, arcname=os.path.basename(archive_path))
41+
42+
print(f"Release binary is available at {args.output}")
43+
44+
if __name__ == "__main__":
45+
main()

0 commit comments

Comments
 (0)