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"