Skip to content

Snapshot Build

Snapshot Build #76

Workflow file for this run

name: Snapshot Build
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
permissions:
contents: write
jobs:
check-commits:
name: Check for new commits
runs-on: ubuntu-latest
outputs:
has_commits: ${{ steps.check.outputs.has_commits }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Check if new commits exist since last nightly
id: check
run: |
LAST_NIGHTLY=$(git tag -l "nightly-*" --sort=-creatordate | head -n1)
if [ -z "$LAST_NIGHTLY" ]; then
echo "has_commits=true" >> "$GITHUB_OUTPUT"
exit 0
fi
COMMIT_COUNT=$(git rev-list "${LAST_NIGHTLY}..HEAD" --count 2>/dev/null || echo "0")
if [ "$COMMIT_COUNT" -gt 0 ]; then
echo "has_commits=true" >> "$GITHUB_OUTPUT"
else
echo "has_commits=false" >> "$GITHUB_OUTPUT"
fi
build-snapshot:
name: Build Snapshot (${{ matrix.os }})
needs: check-commits
if: needs.check-commits.outputs.has_commits == 'true' || github.event_name == 'workflow_dispatch'
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
cache-dependency-path: package-lock.json
- name: Install dependencies
run: npm install
- name: Build application
run: npm run build
env:
CI: true
- name: Generate nightly version
id: nightly
shell: bash
run: |
DATE=$(date -u +"%Y%m%d")
PKG_VERSION=$(node -p "require('./package.json').version")
NIGHTLY_VERSION="${PKG_VERSION}-nightly.${DATE}"
NIGHTLY_TAG="nightly-${DATE}"
echo "version=${NIGHTLY_VERSION}" >> "$GITHUB_OUTPUT"
echo "tag=${NIGHTLY_TAG}" >> "$GITHUB_OUTPUT"
echo "date=${DATE}" >> "$GITHUB_OUTPUT"
node -e "
const pkg = require('./package.json');
pkg.version = '${NIGHTLY_VERSION}';
require('fs').writeFileSync('package.json', JSON.stringify(pkg, null, 2));
"
- name: Build Electron (macOS)
if: runner.os == 'macOS'
run: npm run electron:build -- --mac --config.mac.identity=null
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CSC_IDENTITY_AUTO_DISCOVERY: false
- name: Build Electron (Windows)
if: runner.os == 'Windows'
run: npm run electron:build -- --win
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build Electron (Linux)
if: runner.os == 'Linux'
run: npm run electron:build -- --linux
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload macOS snapshot artifacts
if: runner.os == 'macOS'
uses: actions/upload-artifact@v4
with:
name: snapshot-macos-${{ steps.nightly.outputs.date }}
path: |
release/*.dmg
release/*.zip
retention-days: 14
- name: Upload Windows snapshot artifacts
if: runner.os == 'Windows'
uses: actions/upload-artifact@v4
with:
name: snapshot-windows-${{ steps.nightly.outputs.date }}
path: |
release/*.exe
release/*.msi
retention-days: 14
- name: Upload Linux snapshot artifacts
if: runner.os == 'Linux'
uses: actions/upload-artifact@v4
with:
name: snapshot-linux-${{ steps.nightly.outputs.date }}
path: |
release/*.AppImage
release/*.deb
release/*.tar.gz
retention-days: 14
create-snapshot-release:
name: Create Snapshot Release
needs: build-snapshot
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Generate nightly tag
id: nightly
run: |
DATE=$(date -u +"%Y%m%d")
NIGHTLY_TAG="nightly-${DATE}"
echo "tag=${NIGHTLY_TAG}" >> "$GITHUB_OUTPUT"
echo "date=${DATE}" >> "$GITHUB_OUTPUT"
- name: Download macOS artifacts
uses: actions/download-artifact@v4
with:
name: snapshot-macos-${{ steps.nightly.outputs.date }}
path: artifacts/macos/
- name: Download Windows artifacts
uses: actions/download-artifact@v4
with:
name: snapshot-windows-${{ steps.nightly.outputs.date }}
path: artifacts/windows/
- name: Download Linux artifacts
uses: actions/download-artifact@v4
with:
name: snapshot-linux-${{ steps.nightly.outputs.date }}
path: artifacts/linux/
- name: Delete previous nightly release
continue-on-error: true
run: |
gh release delete nightly --yes || true
git push origin :refs/tags/nightly || true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create snapshot release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.nightly.outputs.tag }}
name: Nightly Build ${{ steps.nightly.outputs.date }}
body: |
## Nightly Build ${{ steps.nightly.outputs.date }}
This is an automated nightly build from the `main` branch.
**Warning**: Nightly builds may be unstable. Use at your own risk.
### Installation
- **macOS**: Download the `.dmg` file, open it, and drag to Applications.
- **Windows**: Download the `.exe` installer or `.msi` and run it.
- **Linux**: Download the `.AppImage` (make executable with `chmod +x`), `.deb` for Debian/Ubuntu, or `.tar.gz` for manual extraction.
prerelease: true
files: |
artifacts/macos/*.dmg
artifacts/macos/*.zip
artifacts/windows/*.exe
artifacts/windows/*.msi
artifacts/linux/*.AppImage
artifacts/linux/*.deb
artifacts/linux/*.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}