Skip to content

Commit fff472d

Browse files
authored
Add release workflow automation to check version strings (#220)
This ensures that `README.md` and `CLI.swift` hardcoded versions don't go out of sync with actual release versions.
1 parent 595c4f5 commit fff472d

File tree

3 files changed

+34
-4
lines changed

3 files changed

+34
-4
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ jobs:
239239

240240
build-android:
241241
runs-on: ubuntu-24.04
242+
timeout-minutes: 10
242243
strategy:
243244
matrix:
244245
include:

.github/workflows/release.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ jobs:
1313
runs-on: macos-15
1414
steps:
1515
- 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
16+
- run: |
17+
VERSION=$(echo ${{ github.ref_name }} | sed 's/^v//')
18+
echo "{WASMKIT_VERSION}={$VERSION}" >> "$GITHUB_ENV"
19+
- run: ./Utilities/build-release.py -o wasmkit-x86_64-apple-macos.tar.gz -s $WASMKIT_VERSION -- --triple x86_64-apple-macos
20+
- run: ./Utilities/build-release.py -o wasmkit-arm64-apple-macos.tar.gz -s $WASMKIT_VERSION -- --triple arm64-apple-macos
1821
- uses: actions/upload-artifact@v5
1922
with:
2023
name: release-wasmkit-x86_64-apple-macos
@@ -41,8 +44,11 @@ jobs:
4144
./build-exec apt-get install -y llvm-15
4245
./build-exec ln -s /usr/bin/llvm-strip-15 /usr/bin/llvm-strip
4346
44-
- run: ./build-exec ./Utilities/build-release.py -o wasmkit-x86_64-swift-linux-musl.tar.gz -- --swift-sdk x86_64-swift-linux-musl
45-
- run: ./build-exec ./Utilities/build-release.py -o wasmkit-aarch64-swift-linux-musl.tar.gz -- --swift-sdk aarch64-swift-linux-musl
47+
- run: |
48+
VERSION=$(echo ${{ github.ref_name }} | sed 's/^v//')
49+
echo "{WASMKIT_VERSION}={$VERSION}" >> "$GITHUB_ENV"
50+
- run: ./build-exec ./Utilities/build-release.py -o wasmkit-x86_64-swift-linux-musl.tar.gz -s $WASMKIT_VERSION -- --swift-sdk x86_64-swift-linux-musl
51+
- run: ./build-exec ./Utilities/build-release.py -o wasmkit-aarch64-swift-linux-musl.tar.gz -s $WASMKIT_VERSION -- --swift-sdk aarch64-swift-linux-musl
4652
- uses: actions/upload-artifact@v5
4753
with:
4854
name: release-wasmkit-x86_64-swift-linux-musl

Utilities/build-release.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,33 @@ def main():
2626
import argparse
2727
parser = argparse.ArgumentParser()
2828
parser.add_argument("-o", "--output", required=True)
29+
parser.add_argument("-s", "--semantic-version", required=True)
2930
parser.add_argument("extra_build_args", nargs="*")
3031

3132
args = parser.parse_args()
3233

34+
# Check that `README.md` has been updated with the latest version.
35+
version_ok = False
36+
with open(os.path.join(SOURCE_ROOT, 'README.md')) as file:
37+
for line in file:
38+
if f'from: "{args.semantic_version}"' in line:
39+
version_ok = True
40+
41+
if not version_ok:
42+
print("Expected README.md to contain a reference to the newly released version in Package.swift sample.", file=sys.stderr)
43+
sys.exit(1)
44+
45+
# Check that `CLI.swift` has been updated with the latest version.
46+
version_ok = False
47+
with open(os.path.join(SOURCE_ROOT, 'Sources', 'CLI', 'CLI.swift')) as file:
48+
for line in file:
49+
if f'version: "{args.semantic_version}"' in line:
50+
version_ok = True
51+
52+
if not version_ok:
53+
print("Expected `Sources/CLI/CLI.swift` to specify the newly released version.", file=sys.stderr)
54+
sys.exit(1)
55+
3356
build_args = ["swift", "build", "-c", "release", "--product", "wasmkit-cli", "--package-path", SOURCE_ROOT] + args.extra_build_args
3457
bin_path = subprocess.check_output(build_args + ["--show-bin-path"], text=True).strip()
3558

0 commit comments

Comments
 (0)