Builds the Linux AppImage on a v* tag, runs the test suite first, and attaches the artifact to a Gitea release via the API (no third-party action, so nothing needs to be fetched from github.com at runtime). Guards that the tag matches package.json version: electron-builder names the artifact from package.json, so tagging v1.0.1 without bumping the manifest would otherwise publish an AppImage named 1.0.0. Requires a RELEASE_TOKEN secret and a registered act_runner; neither is set up yet, so this is inert until both exist. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
73 lines
2.5 KiB
YAML
73 lines
2.5 KiB
YAML
name: Build AppImage
|
|
|
|
# Builds the Linux AppImage on a version tag and attaches it to a Gitea release.
|
|
# Tag must match the version in desktop-client/package.json, since electron-builder
|
|
# names the artifact from package.json (not from the tag).
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
appimage:
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: desktop-client
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '22'
|
|
|
|
- name: Verify tag matches package.json version
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
run: |
|
|
pkg_version=$(node -p "require('./package.json').version")
|
|
tag_version="${GITHUB_REF_NAME#v}"
|
|
if [ "$pkg_version" != "$tag_version" ]; then
|
|
echo "Tag $GITHUB_REF_NAME does not match package.json version $pkg_version." >&2
|
|
echo "Bump package.json before tagging, or the AppImage will be misnamed." >&2
|
|
exit 1
|
|
fi
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Run tests
|
|
run: npm test
|
|
|
|
- name: Build AppImage
|
|
run: npx electron-builder --linux AppImage --publish never
|
|
|
|
- name: Attach AppImage to release
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
env:
|
|
TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
|
API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }}
|
|
run: |
|
|
set -euo pipefail
|
|
artifact=$(ls dist/*.AppImage | head -1)
|
|
echo "Publishing $artifact for $GITHUB_REF_NAME"
|
|
|
|
# Reuse the release if the tag already has one, otherwise create it.
|
|
release_id=$(curl -sf -H "Authorization: token $TOKEN" \
|
|
"$API/releases/tags/$GITHUB_REF_NAME" | node -p \
|
|
"JSON.parse(require('fs').readFileSync(0,'utf8')).id" 2>/dev/null || true)
|
|
|
|
if [ -z "${release_id:-}" ]; then
|
|
release_id=$(curl -sf -X POST -H "Authorization: token $TOKEN" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"tag_name\":\"$GITHUB_REF_NAME\",\"name\":\"$GITHUB_REF_NAME\"}" \
|
|
"$API/releases" | node -p \
|
|
"JSON.parse(require('fs').readFileSync(0,'utf8')).id")
|
|
fi
|
|
|
|
curl -sf -X POST -H "Authorization: token $TOKEN" \
|
|
-F "attachment=@$artifact" \
|
|
"$API/releases/$release_id/assets?name=$(basename "$artifact")" \
|
|
-o /dev/null
|
|
echo "Attached $(basename "$artifact") to release $release_id"
|