Skip to content

Commit 9e46c81

Browse files
author
ComputelessComputer
committed
ci: add GitHub release workflow
1 parent 7bc17c4 commit 9e46c81

3 files changed

Lines changed: 132 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
workflow_dispatch:
8+
inputs:
9+
tag:
10+
description: "Release tag, for example v0.1.0"
11+
required: true
12+
type: string
13+
14+
concurrency:
15+
group: release-${{ github.workflow }}-${{ github.ref || inputs.tag }}
16+
cancel-in-progress: false
17+
18+
jobs:
19+
release:
20+
runs-on: macos-15
21+
permissions:
22+
contents: write
23+
timeout-minutes: 30
24+
env:
25+
GH_TOKEN: ${{ github.token }}
26+
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 0
32+
33+
- name: Resolve tag
34+
id: meta
35+
shell: bash
36+
run: |
37+
if [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]]; then
38+
TAG="${{ inputs.tag }}"
39+
else
40+
TAG="${GITHUB_REF_NAME}"
41+
fi
42+
43+
if [[ -z "${TAG}" ]]; then
44+
echo "Tag is required" >&2
45+
exit 1
46+
fi
47+
48+
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
49+
50+
- name: Show toolchain
51+
run: |
52+
swift --version
53+
xcodebuild -version
54+
55+
- name: Build release binaries
56+
run: swift build -c release
57+
58+
- name: Package release artifacts
59+
run: |
60+
chmod +x scripts/package-release.sh
61+
scripts/package-release.sh "${{ steps.meta.outputs.tag }}" dist
62+
63+
- name: Publish GitHub release
64+
shell: bash
65+
run: |
66+
TAG="${{ steps.meta.outputs.tag }}"
67+
ARCHIVE="dist/openbird-${TAG}-macos-arm64.tar.gz"
68+
CHECKSUM="dist/openbird-${TAG}-macos-arm64.sha256"
69+
70+
if gh release view "${TAG}" --repo "${GITHUB_REPOSITORY}" >/dev/null 2>&1; then
71+
gh release upload "${TAG}" "$ARCHIVE" "$CHECKSUM" --clobber --repo "${GITHUB_REPOSITORY}"
72+
else
73+
gh release create "${TAG}" \
74+
"$ARCHIVE" \
75+
"$CHECKSUM" \
76+
--target "${GITHUB_SHA}" \
77+
--title "${TAG}" \
78+
--generate-notes \
79+
--repo "${GITHUB_REPOSITORY}"
80+
fi

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,17 @@ GitHub Actions runs the package build and test workflow on:
4747
- pushes to `main`
4848
- pull requests
4949
- manual runs from the Actions tab via `workflow_dispatch`
50+
51+
## Releases
52+
53+
GitHub Actions also publishes release artifacts from `.github/workflows/release.yml`.
54+
55+
- push a tag like `v0.1.0`, or
56+
- run the `Release` workflow manually and provide a tag
57+
58+
Each release uploads:
59+
60+
- `openbird-<tag>-macos-arm64.tar.gz`
61+
- `openbird-<tag>-macos-arm64.sha256`
62+
63+
The release archive currently contains unsigned SwiftPM release binaries for `OpenbirdApp` and `OpenbirdCollector`.

scripts/package-release.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
if [[ $# -ne 2 ]]; then
6+
echo "usage: $0 <tag> <output-dir>" >&2
7+
exit 1
8+
fi
9+
10+
TAG="$1"
11+
OUTPUT_DIR="$2"
12+
BUILD_DIR=".build/arm64-apple-macosx/release"
13+
STAGE_DIR="${OUTPUT_DIR}/openbird-${TAG}-macos-arm64"
14+
ARCHIVE_BASENAME="openbird-${TAG}-macos-arm64"
15+
16+
mkdir -p "$OUTPUT_DIR"
17+
rm -rf "$STAGE_DIR"
18+
mkdir -p "$STAGE_DIR"
19+
20+
cp "$BUILD_DIR/OpenbirdApp" "$STAGE_DIR/"
21+
cp "$BUILD_DIR/OpenbirdCollector" "$STAGE_DIR/"
22+
cp README.md "$STAGE_DIR/"
23+
24+
cat > "$STAGE_DIR/RELEASE.txt" <<EOF
25+
Openbird ${TAG}
26+
27+
Included artifacts:
28+
- OpenbirdApp
29+
- OpenbirdCollector
30+
31+
These are unsigned macOS arm64 release binaries built via SwiftPM.
32+
EOF
33+
34+
(
35+
cd "$OUTPUT_DIR"
36+
tar -czf "${ARCHIVE_BASENAME}.tar.gz" "${ARCHIVE_BASENAME}"
37+
shasum -a 256 "${ARCHIVE_BASENAME}.tar.gz" > "${ARCHIVE_BASENAME}.sha256"
38+
)

0 commit comments

Comments
 (0)