Files
SideRelay/.github/workflows/docker-release.yml
2026-11-19 01:50:07 +01:00

171 lines
7.6 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: Publish Docker release
on:
workflow_dispatch:
inputs:
version:
description: Docker release version (for example, 1.28.4)
required: true
type: string
permissions:
contents: read
concurrency:
group: docker-release
cancel-in-progress: false
jobs:
build:
name: Build and test ${{ matrix.arch }}
strategy:
fail-fast: false
matrix:
include:
- arch: amd64
runner: ubuntu-24.04
- arch: arm64
runner: ubuntu-24.04-arm
runs-on: ${{ matrix.runner }}
env:
ARCH: ${{ matrix.arch }}
VERSION: ${{ inputs.version }}
COMPOSE_PROJECT_NAME: siderelay-release-test
steps:
- uses: actions/checkout@v4
- name: Build Linux image
run: |
[[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]
test "$VERSION" = "$(python3 -c 'import plistlib; print(plistlib.load(open("Interface/Info.plist", "rb"))["CFBundleShortVersionString"])')"
docker build --platform "linux/$ARCH" --tag siderelay:local .
test "$(docker image inspect siderelay:local --format '{{.Os}}/{{.Architecture}}')" = "linux/$ARCH"
- name: Test a fresh installation
run: |
docker compose up -d --no-build --wait --wait-timeout 60
python3 - <<'PY'
from contextlib import closing
from http.client import HTTPConnection
from io import BytesIO
import json
import os
import plistlib
import subprocess
from urllib.parse import urlencode
from zipfile import ZIP_DEFLATED, ZipFile
def request(method, path, data=None, headers=None):
with closing(HTTPConnection("127.0.0.1", 18785, timeout=5)) as client:
client.request(method, path, data, headers or {})
response = client.getresponse()
return response.status, response.headers, response.read()
status, _, body = request("GET", "/_siderelay/health")
assert status == 200 and json.loads(body)["ready"]
subprocess.run([
"docker", "compose", "exec", "-T", "siderelay", "python3", "-B", "-c",
"from http.client import HTTPConnection; "
"c = HTTPConnection('127.0.0.1', 18784, timeout=5); "
"c.request('GET', '/accounts'); assert c.getresponse().status == 403",
], check=True)
status, headers, _ = request("GET", "/accounts")
assert status == 303 and headers["Location"] == "/_siderelay/login"
password = subprocess.check_output([
"docker", "compose", "exec", "-T", "siderelay", "cat",
"/var/lib/siderelay-secrets/portal-password",
], text=True)
status, headers, _ = request("POST", "/_siderelay/login", urlencode({"key": password}), {
"Origin": "http://127.0.0.1:18785", "Content-Type": "application/x-www-form-urlencoded",
})
assert status == 303 and "HttpOnly" in headers["Set-Cookie"]
cookie = headers["Set-Cookie"].split(";", 1)[0]
status, _, body = request("GET", "/accounts", headers={"Cookie": cookie})
assert status == 200 and b"/_siderelay/assets/Web.js" in body
bridge_headers = {"Cookie": cookie, "Origin": "http://127.0.0.1:18785", "X-SideRelay-Web": "1",
"Content-Type": "application/json"}
status, _, body = request("POST", "/_siderelay/bridge", json.dumps({"action": "portal"}), bridge_headers)
assert status == 200 and json.loads(body)["version"] == os.environ["VERSION"]
ipa = BytesIO()
with ZipFile(ipa, "w", compression=ZIP_DEFLATED) as archive:
archive.writestr("Payload/Smoke.app/Info.plist", plistlib.dumps({
"CFBundleIdentifier": "org.example.siderelay.smoke", "CFBundleVersion": "1",
"CFBundleSupportedPlatforms": ["iPhoneOS"],
}))
status, _, body = request("POST", "/api/siderelay/ipa/import", ipa.getvalue(), {
"Cookie": cookie, "Origin": "http://127.0.0.1:18785",
"Content-Type": "application/octet-stream", "X-SideRelay-Action": "catalogue",
})
assert status == 200 and b"org.example.siderelay.smoke" in body
status, _, body = request("GET", "/_siderelay/assets/Web.js", headers={"Cookie": cookie})
assert status == 200 and b"Update Available" in body and b"dockerUpdate" in body
PY
- name: Export image
run: |
mkdir -p release
docker save siderelay:local | gzip -1 > "release/SideRelay-Docker-$VERSION-linux-$ARCH.tar.gz"
- name: Stop the test containers
if: always()
run: docker compose down --volumes
- uses: actions/upload-artifact@v4
with:
name: siderelay-docker-${{ matrix.arch }}
path: release/*.tar.gz
compression-level: 0
publish:
name: Publish GitHub release
needs: build
runs-on: ubuntu-24.04
permissions:
contents: write
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
VERSION: ${{ inputs.version }}
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
pattern: siderelay-docker-*
path: release
merge-multiple: true
- name: Publish verified archives
run: |
[[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]
tag="docker-v$VERSION"
cp compose.yaml release/
(
cd release
sha256sum "SideRelay-Docker-$VERSION-linux-amd64.tar.gz" "SideRelay-Docker-$VERSION-linux-arm64.tar.gz" compose.yaml > SHA256SUMS
)
cat > release-notes.md <<'EOF'
Run the SideRelay browser portal and signature renewal on a Linux Docker host.
- Use the **amd64** archive on 64-bit Intel or AMD hosts, or **arm64** on ARM64 hosts.
- Both images passed the fresh-install checks for container health, portal sign-in and access control.
- Download the matching archive and `compose.yaml`, then follow the [Docker quick start](https://github.com/arkemys-consulting/SideRelay#docker).
- For iPhone and iPad, import a compatible Remote Pairing file from the **Devices** screen. Apple TV installs and renewals use the optional Mac helper with Xcode.
EOF
python3 - <<'PY'
import os
import re
from pathlib import Path
version = re.escape(os.environ["VERSION"])
changelog = Path("CHANGELOG.md").read_text()
release = re.search(rf"^## {version} · [^\n]+\n(.*?)(?=^## |\Z)", changelog, re.M | re.S)
if release:
sections = re.findall(r"^### (Store|Apple Account sign-in|macOS and Docker|Docker)\n(.*?)(?=^### |\Z)", release[1], re.M | re.S)
notes = Path("release-notes.md")
changes = "\n\n".join(body.strip() for _, body in sections if body.strip())
if changes:
notes.write_text("## What’s new\n\n" + changes + "\n\n" + notes.read_text())
PY
if gh release view "$tag" --json isDraft --jq .isDraft > draft-status; then
test "$(cat draft-status)" = true
else
gh release create "$tag" --target "$GITHUB_SHA" --draft --latest=false \
--title "SideRelay $VERSION for Docker" --notes-file release-notes.md
fi
gh release upload "$tag" release/*.tar.gz release/compose.yaml release/SHA256SUMS --clobber
gh release edit "$tag" --draft=false --latest=false