Skip to content

Nightly Build

Nightly Build #223

Workflow file for this run

name: Nightly Build
on:
schedule:
# Run at 2:00 AM UTC every day
- cron: '0 2 * * *'
jobs:
check-changes:
# Only check for changes on scheduled runs
if: github.event_name == 'schedule'
runs-on: ubuntu-latest
outputs:
should_build: ${{ steps.check.outputs.should_build }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Check for changes in last 24 hours
id: check
run: |
LATEST_COMMIT=$(git log -1 --format=%ct)
YESTERDAY=$(date -d '24 hours ago' +%s)
if [ "$LATEST_COMMIT" -gt "$YESTERDAY" ]; then
echo "should_build=true" >> $GITHUB_OUTPUT
else
echo "should_build=false" >> $GITHUB_OUTPUT
fi
build:
needs: check-changes
# Build on schedule when there are recent changes
if: needs.check-changes.outputs.should_build == 'true'
strategy:
matrix:
include:
- os: ubuntu-latest
platform: linux
- os: windows-latest
platform: win
- os: macos-latest
platform: mac
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Set nightly version
shell: bash
run: |
TIMESTAMP=$(date +'%Y%m%d%H%M')
VERSION=$(node -p "require('./package.json').version")
NIGHTLY_VERSION="${VERSION}-nightly.${TIMESTAMP}"
npm version $NIGHTLY_VERSION --no-git-tag-version
echo "Building nightly version: $NIGHTLY_VERSION"
- name: Build application
run: npm run build
# macOS: Import certificates for signing
- name: Import macOS certificates
if: matrix.platform == 'mac'
env:
MAC_CERTS: ${{ secrets.MAC_CERTS }}
MAC_CERTS_PASSWORD: ${{ secrets.MAC_CERTS_PASSWORD }}
run: |
if [ -n "$MAC_CERTS" ]; then
echo "$MAC_CERTS" | base64 --decode > certificate.p12
security create-keychain -p actions build.keychain
security default-keychain -s build.keychain
security unlock-keychain -p actions build.keychain
security import certificate.p12 -k build.keychain -P "$MAC_CERTS_PASSWORD" -T /usr/bin/codesign
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k actions build.keychain
rm certificate.p12
fi
- name: Build for ${{ matrix.platform }}
run: npm run build:${{ matrix.platform }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# macOS signing
CSC_LINK: ${{ matrix.platform == 'mac' && secrets.MAC_CERTS || '' }}
CSC_KEY_PASSWORD: ${{ matrix.platform == 'mac' && secrets.MAC_CERTS_PASSWORD || '' }}
# macOS notarization (optional)
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
- name: Rename yml files for nightly channel
run: |
cd dist
for f in latest*.yml; do
[ -f "$f" ] && mv "$f" "nightly${f#latest}"
done
shell: bash
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: wavespeed-desktop-nightly-${{ matrix.platform }}
path: |
dist/*.exe
dist/*.dmg
dist/*.zip
dist/*.AppImage
dist/*.deb
dist/nightly*.yml
dist/*.blockmap
if-no-files-found: ignore
retention-days: 7
create-nightly-release:
needs: build
# Run if build succeeded (handles skipped check-changes job)
if: always() && needs.build.result == 'success'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Get current date
id: date
run: echo "date=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
- name: Delete existing nightly release
uses: dev-drprasad/delete-tag-and-release@v1.0
with:
tag_name: nightly
github_token: ${{ secrets.GITHUB_TOKEN }}
delete_release: true
continue-on-error: true
- name: Create Nightly Release
uses: softprops/action-gh-release@v1
with:
tag_name: nightly
name: Nightly Build (${{ steps.date.outputs.date }})
body: |
## Nightly Build
Automated nightly build from `main` branch.
**Build Date:** ${{ steps.date.outputs.date }}
**Commit:** ${{ github.sha }}
> This is a pre-release build and may be unstable.
### Downloads
- **Windows:** `.exe` (installer) or `.zip`
- **macOS:** `.dmg` or `.zip`
- **Linux:** `.AppImage` or `.deb`
files: artifacts/**/*
prerelease: true
draft: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
deploy-to-server:
needs: create-nightly-release
if: always() && needs.create-nightly-release.result == 'success'
runs-on: namespace-profile-default
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Add SSH Private Key
uses: webfactory/ssh-agent@v0.7.0
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY_PROD }}
- name: Deploy to Server
run: |
ssh -o StrictHostKeyChecking=no ubuntu@43.153.9.233 '
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" &&
cd /home/ubuntu/service/wavespeed-desktop &&
git checkout main &&
git fetch origin &&
git reset --hard origin/main &&
npm install &&
npm run build:web
'