Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/actions/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ description: >

inputs:
version:
description: Version to stamp into the binary (without the v)
description: Complete version string to stamp into the binary (for example, v0.0.10)
required: false
default: dev

Expand All @@ -25,6 +25,10 @@ runs:
VERSION: ${{ inputs.version }}
run: |
set -euo pipefail
if [[ "$VERSION" != dev && ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Unsupported version string: $VERSION" >&2
exit 1
fi
mkdir -p dist
# linux/386 and friends excluded on purpose: wazero's compiler backend
# covers amd64/arm64, and everything else falls back to the
Expand Down
55 changes: 55 additions & 0 deletions .github/scripts/verify-release-archive.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env bash
set -euo pipefail

if [[ $# -ne 2 ]]; then
echo "usage: $0 ARCHIVE EXPECTED_OUTPUT" >&2
exit 2
fi

archive=$1
expected=$2
workdir=$(mktemp -d)
cleanup() {
rm -rf -- "$workdir"
}
trap cleanup EXIT

listing="$workdir/listing"
metadata="$workdir/metadata"
actual="$workdir/actual"

tar -tzf "$archive" > "$listing"
if [[ $(wc -l < "$listing") -ne 1 ]] || [[ $(<"$listing") != termcade ]]; then
echo "archive must contain exactly one root entry named termcade" >&2
exit 1
fi

tar -tvzf "$archive" > "$metadata"
if [[ $(wc -l < "$metadata") -ne 1 ]] || [[ $(<"$metadata") != -* ]]; then
echo "archive entry termcade must be a regular file" >&2
exit 1
fi

tar -xzf "$archive" -C "$workdir" --no-same-owner --no-same-permissions
if [[ ! -f "$workdir/termcade" || -L "$workdir/termcade" ]]; then
echo "extracted termcade must be a regular, non-symlink file" >&2
exit 1
fi
chmod u+x "$workdir/termcade"

if timeout 30s "$workdir/termcade" version > "$actual"; then
:
else
status=$?
echo "termcade version command failed with exit $status" >&2
exit "$status"
fi

if ! printf '%s\n' "$expected" | cmp -s - "$actual"; then
echo "released binary version mismatch" >&2
printf 'expected: %q\n' "$expected" >&2
printf 'actual: %q\n' "$(<"$actual")" >&2
exit 1
fi

printf 'verified: %s\n' "$expected"
10 changes: 8 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,17 @@ jobs:
# organisation does.
- name: Build
uses: ./.github/actions/build
with:
version: ${{ steps.release.outputs.tag }}

- name: Test
uses: ./.github/actions/test
with:
version: ${{ steps.release.outputs.version }}

- name: Verify released binary version
env:
ARCHIVE: dist/termcade_Linux_x86_64.tar.gz
EXPECTED: termcade v${{ steps.release.outputs.version }}
run: .github/scripts/verify-release-archive.sh "$ARCHIVE" "$EXPECTED"

# Installed games run sandboxed, but the arcade itself runs with the
# player's full permissions — worth tying the archives to this workflow,
Expand Down