Files
tern-web/.gitea/workflows/release.yml
T
Mateusz PstruchaandClaude Opus 5.5 e6ce5e26c7
CI / build (push) Successful in 21s
Deploy each release to tern.mtps.pl
After the release is published, a deploy job checks out the deployment
definition from tern-server at the same tag, confirms the server image
for that version exists, and runs it through ygg/actions/deploy. It
runs here because tags go out server-first and the single runner works
through them in order, so both artifacts exist by now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 20:47:33 +02:00

98 lines
3.0 KiB
YAML

name: Release
on:
push:
tags: ['v*']
jobs:
release:
runs-on: rocky-10
steps:
- name: Check out source
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- name: Install dependencies
run: npm ci
- name: Type check
run: npm run check
- name: Build
run: npm run build
- name: Create release archive
run: |
VERSION="${GITHUB_REF_NAME#v}"
# Archive the *contents* of dist/ rather than dist/ itself, so it
# untars straight into an nginx web root.
tar -czf "tern-web-${VERSION}.tgz" -C dist .
sha256sum "tern-web-${VERSION}.tgz" > "tern-web-${VERSION}.tgz.sha256"
- name: Create release
uses: akkuman/gitea-release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
server_url: ${{ gitea.server_url }}
tag_name: ${{ gitea.ref_name }}
name: ${{ gitea.ref_name }}
files: |-
tern-web-*.tgz
tern-web-*.tgz.sha256
# Deploys the release to tern.mtps.pl (kara, deploy/compose). It lives
# here rather than in tern-server because tags are pushed server-first and
# the single runner works through them in order, so by the time this runs
# both the server image and this webapp release exist. A deploy job in
# tern-server would have to wait for this repo's release while holding
# the only runner.
deploy:
needs: release
runs-on: rocky-10
steps:
# The deployment definition is versioned with the server it deploys.
- name: Check out deployment definition
uses: actions/checkout@v4
with:
repository: mtps/tern-server
ref: ${{ gitea.ref_name }}
- name: Check the server image exists
env:
IMAGE: git.app.ygg/mtps/tern-server
TAG: ${{ gitea.ref_name }}
run: |
# Fails fast with a clear message if the server release didn't
# publish this version (failed, or still running on another
# runner), instead of a deploy that can't pull its image.
VERSION="${TAG#v}"
for i in $(seq 1 20); do
docker manifest inspect "$IMAGE:$VERSION" >/dev/null 2>&1 && exit 0
echo "waiting for $IMAGE:$VERSION ($i/20)"
sleep 30
done
echo "::error::$IMAGE:$VERSION not found in the registry — did the tern-server release succeed?"
exit 1
- name: Derive version
id: version
env:
TAG: ${{ gitea.ref_name }}
run: echo "version=${TAG#v}" >> "$GITHUB_OUTPUT"
- name: Deploy
uses: https://git.app.ygg/ygg/actions/deploy@v2
with:
type: compose
dist-path: deploy/tern.yml
extra-vars: |
version=${{ steps.version.outputs.version }}
ssh-key: ${{ secrets.DEPLOY_SSH_KEY }}
known-hosts: ${{ secrets.DEPLOY_KNOWN_HOSTS }}