Files
2026-08-19 21:35:27 +03:00

150 lines
4.2 KiB
YAML

name: Package desktop app
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: "Release tag to attach the installers to (leave empty for workflow_dispatch only build)"
required: false
permissions:
contents: write
jobs:
bump-version:
name: Sync desktop version to tag
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Bump desktop package version
working-directory: desktop
run: |
VERSION="${GITHUB_REF_NAME#v}"
npm pkg set version="$VERSION"
npm install --package-lock-only
echo "bumped desktop version to $VERSION"
- name: Commit and push version bump
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add desktop/package.json desktop/package-lock.json
if git diff --cached --quiet; then
echo "no version change to commit"
else
git commit -m "bump desktop version to ${GITHUB_REF_NAME#v} [ci skip]"
git push origin HEAD:main
fi
build:
name: Build ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
script: dist:win
env: { CSC_IDENTITY_AUTO_DISCOVERY: "true" }
- os: macos-latest
script: dist:mac
env: { CSC_IDENTITY_AUTO_DISCOVERY: "false" }
- os: ubuntu-latest
script: dist:linux
env: { CSC_IDENTITY_AUTO_DISCOVERY: "true" }
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
cache-dependency-path: desktop/package-lock.json
- name: Cache Electron binaries
uses: actions/cache@v4
with:
path: |
~/.cache/electron
~/.cache/electron-builder
key: ${{ runner.os }}-electron-${{ hashFiles('desktop/package-lock.json') }}
- name: Install dependencies
run: npm ci
working-directory: desktop
- name: Set version from release tag
env:
TAG: ${{ inputs.tag != '' && inputs.tag || github.ref_name }}
working-directory: desktop
shell: bash
run: |
VERSION="${TAG#v}"
if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+ ]]; then
npm pkg set version="$VERSION"
echo "Packaging version $VERSION"
else
echo "No semver tag ($TAG) - keeping package.json version"
fi
- name: Build installers
run: npm run ${{ matrix.script }}
working-directory: desktop
env:
CSC_IDENTITY_AUTO_DISCOVERY: ${{ matrix.env.CSC_IDENTITY_AUTO_DISCOVERY }}
- name: List release artifacts
shell: bash
working-directory: desktop
run: ls -la release
- name: Upload installers
uses: actions/upload-artifact@v4
with:
name: installers-${{ matrix.os }}
path: |
desktop/release/*.exe
desktop/release/*.dmg
desktop/release/*.zip
desktop/release/*.AppImage
desktop/release/*.deb
if-no-files-found: error
release:
name: Publish release
needs: build
if: startsWith(github.ref, 'refs/tags/') || inputs.tag != ''
runs-on: ubuntu-latest
steps:
- name: Download installers
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Publish GitHub release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.event_name == 'push' && github.ref_name || inputs.tag }}
files: |
artifacts/*.exe
artifacts/*.dmg
artifacts/*.zip
artifacts/*.AppImage
artifacts/*.deb
generate_release_notes: true