- Added a GitHub Actions workflow for building and releasing the web application on version tag pushes. - Introduced Python and JavaScript scripts for release metadata generation, validation, and smoke testing of the web release image. - Updated .gitignore to include new artifacts and Python cache directories. - Created Docker Compose configuration for deploying the web application with environment variable management. - Enhanced documentation for deployment instructions and usage of the official web release image.
237 lines
7.6 KiB
YAML
237 lines
7.6 KiB
YAML
name: Build and Release Web
|
|
|
|
on:
|
|
push:
|
|
tags: ["v*"]
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: web-release-${{ github.ref }}
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
prepare:
|
|
name: Validate Web release
|
|
runs-on: ubuntu-24.04
|
|
timeout-minutes: 10
|
|
outputs:
|
|
version: ${{ steps.metadata.outputs.version }}
|
|
image_tag: ${{ steps.metadata.outputs.image_tag }}
|
|
image: ${{ steps.metadata.outputs.image }}
|
|
stable: ${{ steps.metadata.outputs.stable }}
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
with:
|
|
fetch-depth: 0
|
|
- name: Test release policy
|
|
run: python3 -m unittest discover -s .github/scripts -p 'test_web_release.py'
|
|
- name: Validate version tag
|
|
id: metadata
|
|
run: python3 .github/scripts/web-release.py metadata
|
|
- name: Verify tag commit belongs to main
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
git fetch origin main:refs/remotes/origin/main
|
|
tag_commit=$(git rev-parse "${GITHUB_REF}^{commit}")
|
|
if [ "$tag_commit" != "$(git rev-parse HEAD)" ] || ! git merge-base --is-ancestor "$tag_commit" origin/main; then
|
|
echo "::error::The checked-out tag commit must belong to origin/main."
|
|
exit 1
|
|
fi
|
|
|
|
acceptance:
|
|
name: Web deployment acceptance
|
|
needs: prepare
|
|
runs-on: ubuntu-24.04
|
|
timeout-minutes: 60
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
- uses: pnpm/action-setup@v5
|
|
with:
|
|
version: 11.10.0
|
|
- uses: actions/setup-node@v6
|
|
with:
|
|
node-version: 24
|
|
cache: pnpm
|
|
- uses: docker/setup-buildx-action@v3
|
|
- run: pnpm install --frozen-lockfile
|
|
- run: pnpm exec playwright install --with-deps chromium
|
|
- run: pnpm test:web:e2e
|
|
- uses: actions/upload-artifact@v4
|
|
if: failure()
|
|
with:
|
|
name: web-release-acceptance-failure
|
|
path: artifacts/web-e2e/
|
|
retention-days: 7
|
|
|
|
build:
|
|
name: Build and smoke test ${{ matrix.arch }}
|
|
needs: [prepare, acceptance]
|
|
runs-on: ${{ matrix.runner }}
|
|
timeout-minutes: 60
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- { arch: amd64, runner: ubuntu-24.04 }
|
|
- { arch: arm64, runner: ubuntu-24.04-arm }
|
|
env:
|
|
IMAGE: ${{ needs.prepare.outputs.image }}
|
|
VERSION: ${{ needs.prepare.outputs.version }}
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
- uses: actions/setup-node@v6
|
|
with:
|
|
node-version: 24
|
|
- uses: docker/setup-buildx-action@v3
|
|
- name: Build local image
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: deploy/web/Dockerfile
|
|
platforms: linux/${{ matrix.arch }}
|
|
build-args: NYATERM_WEB_BASE_PATH=/
|
|
load: true
|
|
tags: nyaterm-web:smoke
|
|
provenance: false
|
|
sbom: false
|
|
labels: |
|
|
org.opencontainers.image.version=${{ env.VERSION }}
|
|
org.opencontainers.image.source=https://github.com/${{ github.repository }}
|
|
org.opencontainers.image.revision=${{ github.sha }}
|
|
cache-from: type=gha,scope=web-release-${{ matrix.arch }}
|
|
cache-to: type=gha,scope=web-release-${{ matrix.arch }},mode=max
|
|
- name: Smoke test the release image
|
|
env:
|
|
NYATERM_SMOKE_IMAGE: nyaterm-web:smoke
|
|
run: node .github/scripts/web-release-smoke.mjs
|
|
- uses: actions/setup-go@v6
|
|
with:
|
|
go-version: stable
|
|
cache: false
|
|
- name: Install crane
|
|
env:
|
|
GOBIN: ${{ runner.temp }}/web-tools
|
|
run: |
|
|
go install github.com/google/go-containerregistry/cmd/crane@v0.20.3
|
|
echo "$GOBIN" >> "$GITHUB_PATH"
|
|
- uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
- name: Push tested image by digest
|
|
env:
|
|
ARCH: ${{ matrix.arch }}
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
archive="$RUNNER_TEMP/nyaterm-web.tar"
|
|
docker save nyaterm-web:smoke --output "$archive"
|
|
digest=$(crane digest --tarball "$archive")
|
|
crane push "$archive" "$IMAGE@$digest"
|
|
mkdir -p digests
|
|
printf '%s' "$digest" > "digests/$ARCH"
|
|
{
|
|
echo "### Web image: linux/$ARCH"
|
|
echo "Version: $VERSION"
|
|
echo "Image: $IMAGE@$digest"
|
|
} >> "$GITHUB_STEP_SUMMARY"
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: web-release-digest-${{ matrix.arch }}
|
|
path: digests/
|
|
if-no-files-found: error
|
|
retention-days: 7
|
|
- uses: actions/upload-artifact@v4
|
|
if: failure()
|
|
with:
|
|
name: web-release-smoke-failure-${{ matrix.arch }}
|
|
path: artifacts/web-release-smoke/
|
|
retention-days: 7
|
|
|
|
publish:
|
|
name: Publish multi-architecture version
|
|
needs: [prepare, build]
|
|
runs-on: ubuntu-24.04
|
|
timeout-minutes: 10
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
outputs:
|
|
digest: ${{ steps.manifest.outputs.digest }}
|
|
env:
|
|
IMAGE: ${{ needs.prepare.outputs.image }}
|
|
IMAGE_TAG: ${{ needs.prepare.outputs.image_tag }}
|
|
VERSION: ${{ needs.prepare.outputs.version }}
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
- uses: docker/setup-buildx-action@v3
|
|
- uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
- uses: actions/download-artifact@v4
|
|
with:
|
|
pattern: web-release-digest-*
|
|
path: digests
|
|
merge-multiple: true
|
|
- name: Create and verify the version manifest
|
|
id: manifest
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
DIGEST_AMD64=$(cat digests/amd64)
|
|
DIGEST_ARM64=$(cat digests/arm64)
|
|
export DIGEST_AMD64 DIGEST_ARM64
|
|
docker buildx imagetools create --tag "$IMAGE:$IMAGE_TAG" \
|
|
"$IMAGE@$DIGEST_AMD64" "$IMAGE@$DIGEST_ARM64"
|
|
docker buildx imagetools inspect --raw "$IMAGE:$IMAGE_TAG" > manifest.json
|
|
python3 .github/scripts/web-release.py check-manifest
|
|
{
|
|
echo "### Published Web release $VERSION"
|
|
echo "Image: $IMAGE:$IMAGE_TAG"
|
|
echo "Platforms: linux/amd64, linux/arm64"
|
|
} >> "$GITHUB_STEP_SUMMARY"
|
|
- name: Record manifest digest
|
|
env:
|
|
DIGEST: ${{ steps.manifest.outputs.digest }}
|
|
run: |
|
|
echo "Manifest digest (pin for deployment): $IMAGE@$DIGEST" >> "$GITHUB_STEP_SUMMARY"
|
|
|
|
latest:
|
|
name: Promote newer stable version to latest
|
|
needs: [prepare, publish]
|
|
if: needs.prepare.outputs.stable == 'true'
|
|
runs-on: ubuntu-24.04
|
|
timeout-minutes: 10
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
concurrency:
|
|
group: web-release-latest-${{ github.repository }}
|
|
cancel-in-progress: false
|
|
env:
|
|
IMAGE: ${{ needs.prepare.outputs.image }}
|
|
VERSION: ${{ needs.prepare.outputs.version }}
|
|
DIGEST: ${{ needs.publish.outputs.digest }}
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
- uses: docker/setup-buildx-action@v3
|
|
- uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
- name: Compare registry version and promote latest
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: python3 .github/scripts/web-release.py promote-latest
|