Skip to content
Open
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
323 changes: 323 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,323 @@
name: Release

# Pushing a tag like v1.2.3 on a commit of main builds the Windows and macOS bundles, tags the
# image that CI already tested for that commit, and drafts a GitHub Release. Nothing is public
# until a software lead publishes the draft. Pull requests that touch the packaging, and manual
# runs, build and test the same bundles without publishing anything. See docs/RELEASING.md.
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*'
pull_request:
paths:
- .github/workflows/release.yml
- packaging/**
- scripts/windows-arm.*
- compose.yaml
workflow_dispatch:
inputs:
version:
description: Build the bundles as this version, without publishing (a dry run)
required: true
default: 0.0.0-test

permissions:
contents: read

env:
IMAGE: ghcr.io/waybionic/waybionic_ground_station

concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false

jobs:
plan:
runs-on: ubuntu-24.04
timeout-minutes: 10
permissions:
contents: read
packages: read
outputs:
version: ${{ steps.plan.outputs.version }}
publish: ${{ steps.plan.outputs.publish }}
image: ${{ steps.plan.outputs.image }}
steps:
- name: Check out the repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false

- name: Decide what this run builds
id: plan
shell: bash
env:
GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
INPUT_VERSION: ${{ inputs.version }}
run: |
set -euo pipefail
pattern='^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.]+)?$'
if [[ "$GITHUB_EVENT_NAME" == push ]]; then
version="${GITHUB_REF_NAME#v}"
if [[ ! "$version" =~ $pattern ]]; then
echo "::error::$GITHUB_REF_NAME is not a version tag like v1.2.3 or v1.2.3-rc1"
exit 1
fi
# Only a commit that went through a pull request into main can be released.
git fetch --no-tags origin main
if ! git merge-base --is-ancestor "$GITHUB_SHA" origin/main; then
echo "::error::$GITHUB_REF_NAME points at a commit that is not on main. Release a commit of main."
exit 1
fi
printf '%s' "$GHCR_TOKEN" | docker login ghcr.io --username "$GITHUB_ACTOR" --password-stdin
# main's CI publishes the image it tested for each commit as :<first 7 of the commit>.
digest=$(docker buildx imagetools inspect "$IMAGE:${GITHUB_SHA::7}" \
--format '{{json .Manifest.Digest}}' 2>/dev/null | tr -d '"' || true)
if [[ ! "$digest" =~ ^sha256:[0-9a-f]{64}$ ]]; then
echo "::error::There is no tested image for ${GITHUB_SHA::7}. Wait for the CI run on main for this commit to finish and pass, then run this workflow again."
exit 1
fi
publish=true
else
# A dry run: the same bundles, with a made-up image digest, and nothing published.
version="${INPUT_VERSION:-0.0.0-pr.$GITHUB_RUN_NUMBER}"
if [[ ! "$version" =~ $pattern ]]; then
echo "::error::$version is not a version like 1.2.3 or 1.2.3-rc1"
exit 1
fi
digest="sha256:$(printf '0%.0s' {1..64})"
publish=false
fi
{
echo "version=$version"
echo "publish=$publish"
echo "image=$IMAGE@$digest"
} >> "$GITHUB_OUTPUT"

bundles:
needs: plan
runs-on: ubuntu-24.04
timeout-minutes: 20
steps:
- name: Check out the repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Fetch the pinned Python and pyserial
shell: bash
run: |
set -euo pipefail
mkdir -p build
url=$(python3 -c "import json; print(json.load(open('packaging/windows/python-embed.json'))['url'])")
sha=$(python3 -c "import json; print(json.load(open('packaging/windows/python-embed.json'))['sha256'])")
curl --fail --silent --show-error --location --output build/python-embed.zip "$url"
echo "$sha build/python-embed.zip" | sha256sum --check
python3 -m pip install --quiet --require-hashes --no-deps --only-binary=:all: \
--target build/site-packages -r packaging/windows/requirements.txt

- name: Build the bundles
shell: bash
env:
VERSION: ${{ needs.plan.outputs.version }}
IMAGE_REF: ${{ needs.plan.outputs.image }}
run: |
set -euo pipefail
SOURCE_DATE_EPOCH=$(git log -1 --format=%ct)
export SOURCE_DATE_EPOCH
python3 packaging/make_bundles.py windows --version "$VERSION" --commit "$GITHUB_SHA" \
--image "$IMAGE_REF" --python-zip build/python-embed.zip \
--site-packages build/site-packages --out dist
mkdir build/source
git archive HEAD | tar -x -C build/source
python3 packaging/make_bundles.py macos --version "$VERSION" --commit "$GITHUB_SHA" \
--source build/source --out dist
ls -l dist

- name: Keep the bundles for the checks and the release
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: bundles
path: dist/*.zip
if-no-files-found: error

compose:
needs: [plan, bundles]
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- name: Fetch the bundles
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: bundles
path: dist

- name: The release compose file is valid, pinned by digest and builds nothing
shell: bash
env:
IMAGE_REF: ${{ needs.plan.outputs.image }}
run: |
set -euo pipefail
unzip -q dist/waybionic-ground-station-windows-*.zip -d unpacked
cd unpacked/*/
docker compose -f compose.release.yaml config > resolved.yaml
cat resolved.yaml
grep -q "image: $IMAGE_REF" resolved.yaml
if grep -q '^ *build:' resolved.yaml; then
echo "::error::compose.release.yaml would build an image"
exit 1
fi

windows:
needs: [plan, bundles]
runs-on: windows-latest
timeout-minutes: 15
steps:
- name: Fetch the bundles
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: bundles
path: dist

- name: Unpack the Windows bundle
shell: pwsh
run: Expand-Archive -Path (Get-ChildItem dist\waybionic-ground-station-windows-*.zip).FullName -DestinationPath unpacked

- name: The launcher script parses in Windows PowerShell 5.1
shell: powershell
run: |
$bundle = (Get-ChildItem unpacked)[0].FullName
Write-Host "Windows PowerShell $($PSVersionTable.PSVersion)"
$errors = $null
[System.Management.Automation.Language.Parser]::ParseFile("$bundle\scripts\windows-arm.ps1", [ref]$null, [ref]$errors) | Out-Null
$errors | ForEach-Object { Write-Host $_.Message }
if ($errors.Count -gt 0) { throw 'windows-arm.ps1 does not parse in Windows PowerShell 5.1' }

- name: The bundled Python is the PSF's and starts with pyserial
shell: powershell
run: |
$bundle = (Get-ChildItem unpacked)[0].FullName
$python = "$bundle\python\python.exe"
$signature = Get-AuthenticodeSignature $python
Write-Host "python.exe: $($signature.Status), $($signature.SignerCertificate.Subject)"
if ($signature.Status -ne 'Valid' -or $signature.SignerCertificate.Subject -notmatch 'Python Software Foundation') {
throw 'python.exe is not signed by the Python Software Foundation'
}
& $python -c "import serial, ctypes, sys; print(sys.version); print('pyserial', serial.__version__)"
if ($LASTEXITCODE -ne 0) { throw 'the bundled Python could not import pyserial' }

- name: The launcher's self-test passes, from the unpacked bundle, in Windows PowerShell 5.1
shell: cmd
run: |
for /d %%d in (unpacked\*) do (
call "%%d\scripts\windows-arm.cmd" -SelfTest
if errorlevel 1 exit /b 1
)

macos:
needs: [plan, bundles]
runs-on: macos-latest
timeout-minutes: 15
steps:
- name: Fetch the bundles
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: bundles
path: dist

- name: The installer and the app are in place and well formed
shell: bash
env:
VERSION: ${{ needs.plan.outputs.version }}
run: |
set -euo pipefail
unzip -q dist/waybionic-ground-station-macos-*.zip -d unpacked
cd unpacked/*/
bash -n "Install WayBionic.command"
bash -n scripts/macos.sh
test -x "Install WayBionic.command"
plutil -lint "packaging/macos/WayBionic Ground Station.app/Contents/Info.plist"
test "$(/usr/libexec/PlistBuddy -c 'Print CFBundleShortVersionString' "packaging/macos/WayBionic Ground Station.app/Contents/Info.plist")" = "$VERSION"
test "$(head -n 1 VERSION)" = "$VERSION"

release:
if: needs.plan.outputs.publish == 'true'
needs: [plan, bundles, compose, windows, macos]
runs-on: ubuntu-24.04
timeout-minutes: 20
permissions:
contents: write # the draft release
packages: write # the version tag on the image
id-token: write # the build attestations
attestations: write
steps:
- name: Fetch the bundles
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: bundles
path: dist

- name: Write the checksums
shell: bash
run: |
set -euo pipefail
cd dist
sha256sum -- *.zip | tee SHA256SUMS

- name: Attest where the bundles came from
uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2
with:
subject-path: |
dist/*.zip
dist/SHA256SUMS

- name: Tag the tested image with the version
shell: bash
env:
GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ needs.plan.outputs.version }}
IMAGE_REF: ${{ needs.plan.outputs.image }}
run: |
set -euo pipefail
printf '%s' "$GHCR_TOKEN" | docker login ghcr.io --username "$GITHUB_ACTOR" --password-stdin
# A released version never moves.
existing=$(docker buildx imagetools inspect "$IMAGE:v$VERSION" \
--format '{{json .Manifest.Digest}}' 2>/dev/null | tr -d '"' || true)
Comment on lines +285 to +286
if [[ -n "$existing" && "$IMAGE@$existing" != "$IMAGE_REF" ]]; then
echo "::error::$IMAGE:v$VERSION already exists with another digest; versions are never moved"
exit 1
fi
docker buildx imagetools create --tag "$IMAGE:v$VERSION" "$IMAGE_REF"
tagged=$(docker buildx imagetools inspect "$IMAGE:v$VERSION" \
--format '{{json .Manifest.Digest}}' | tr -d '"')
test "$IMAGE@$tagged" = "$IMAGE_REF"

- name: Draft the release
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ needs.plan.outputs.version }}
IMAGE_REF: ${{ needs.plan.outputs.image }}
run: |
set -euo pipefail
cat > notes.md <<EOF
## Install
- **Windows 11:** download \`waybionic-ground-station-windows-$VERSION.zip\`, unzip it somewhere permanent, start Docker Desktop, then double-click \`Start WayBionic Arm.cmd\`. Docker Desktop (WSL 2 backend) is the only prerequisite; Python is included. The first start downloads the image.
- **macOS (Apple Silicon):** download \`waybionic-ground-station-macos-$VERSION.zip\`, unzip it, double-click \`Install WayBionic.command\`, then open *WayBionic Ground Station* from \`~/Applications\`. The first start sets up the environment (30 to 60 minutes, once).

## What this release runs
Commit \`$GITHUB_SHA\`, with the image CI tested for it, also tagged \`$IMAGE:v$VERSION\`:
\`$IMAGE_REF\`

## Verify your download
\`sha256sum -c SHA256SUMS\`, and \`gh attestation verify <file> --repo $GITHUB_REPOSITORY\`.

Read \`docs/handover.md\` before first use on the arm.
EOF
flags=(--draft --verify-tag --generate-notes --notes-file notes.md)
if [[ "$VERSION" == *-* ]]; then
flags+=(--prerelease)
fi
gh release create "$GITHUB_REF_NAME" dist/*.zip dist/SHA256SUMS \
--title "WayBionic Ground Station $VERSION" "${flags[@]}"
Comment on lines +322 to +323
25 changes: 23 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,25 @@ This is a student research prototype, not a medical device. Everything runs in
simulation unless you choose the real drives, and powered tests need a lead
present.

## Quick start
## Run the real arm

Download the latest bundle from the
[Releases](https://github.com/Waybionic/waybionic_ground_station/releases) page, unzip it
and double-click the launcher. Plug in the carrier board and the controller first.

| Platform | Download | Then |
| --- | --- | --- |
| Windows 11 | `waybionic-ground-station-windows-<version>.zip` | Start Docker Desktop, then double-click `Start WayBionic Arm.cmd`. Docker Desktop is the only prerequisite; Python is included. |
| macOS (Apple Silicon) | `waybionic-ground-station-macos-<version>.zip` | Double-click `Install WayBionic.command`, then open **WayBionic Ground Station** from Applications. The first start sets up the environment (30 to 60 minutes, once). |

RViz opens with an Arm setup panel that says what to do next: put the arm in its zero
pose, zero it, then press Start on the controller. Check a download against `SHA256SUMS`
or with `gh attestation verify <file> --repo Waybionic/waybionic_ground_station`.
Powered tests need a lead present. [docs/handover.md](docs/handover.md) says what has
been shown to work and what to check before relying on it, and
[docs/RELEASING.md](docs/RELEASING.md) says how to publish a release.

## Build and test (developers)

[Install Docker](BuildInstructions.md#1-install-docker), then build the workspace
and run its tests:
Expand All @@ -36,6 +54,8 @@ Then open the arm in RViz:
| --- | --- |
| [BuildInstructions.md](BuildInstructions.md) | Installing, building, testing and opening RViz on Windows, macOS and Linux |
| [Operator guide](docs/operator_guide.md) | Controllers, the self-running demo, the doctor-view camera and the real arm |
| [Handover](docs/handover.md) | What has been shown to work on the arm, what to check next, and the hardware facts |
| [Releasing](docs/RELEASING.md) | Cutting a release: the bundles, the image, the checks and the one-time setup |
| [Launch options](waybionic_bringup/README.md) | Every argument of `ground_station.launch.py` |
| [Diagnostics](waybionic_rviz_plugins/README.md) | The engineering monitor panel |
| [CAN and the carrier board](waybionic_can/README.md) | The MKS protocol, the carrier firmware and CAN simulation |
Expand All @@ -55,7 +75,8 @@ Then open the arm in RViz:
| `waybionic_control`, `waybionic_diagnostics` | The earlier CAN-FD host and the diagnostics command-line tool |
| `waybionic_hardware`, `waybionic_motion_test` | The old four-servo arm's Arduino bridge and motion tests |
| `firmware/tool_board` | Firmware for the biomedical tool's motor board |
| `scripts` | `macos.sh`, `linux-gui.sh`, `windows-demo.cmd` and the CAD tools |
| `scripts` | `macos.sh`, `linux-gui.sh`, the Windows launchers and the CAD tools |
| `packaging` | The Mac app, and what builds the Windows and macOS release bundles |
| `docker`, `compose.yaml`, `.devcontainer` | The container image, its services and the VS Code Dev Container |

## Contributing
Expand Down
Loading
Loading