Skip to content

Nightly Build

Nightly Build #91

Workflow file for this run

name: Nightly Build
on:
schedule:
# Runs daily at 00:00 UTC
- cron: '0 0 * * *'
workflow_dispatch: # Allow manual trigger
permissions:
contents: write
jobs:
nightly-build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check for new commits
id: check
run: |
# Count commits in the last 24 hours
COMMITS_TODAY="$(git log --since="24 hours ago" --oneline | wc -l | tr -d ' ')"
echo "commits_count=$COMMITS_TODAY" >> "$GITHUB_OUTPUT"
if [ "$COMMITS_TODAY" -eq 0 ]; then
echo "No commits in the last 24 hours; skipping build."
echo "should_build=false" >> "$GITHUB_OUTPUT"
else
echo "Found $COMMITS_TODAY commits in the last 24 hours; starting build."
echo "should_build=true" >> "$GITHUB_OUTPUT"
fi
- name: Setup Node.js
if: steps.check.outputs.should_build == 'true'
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
if: steps.check.outputs.should_build == 'true'
run: npm install
- name: Collect version and commit info
if: steps.check.outputs.should_build == 'true'
id: info
run: |
echo "version=$(node -p 'require(\"./package.json\").version')" >> "$GITHUB_OUTPUT"
echo "short_sha=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
echo "date=$(date -u +'%Y-%m-%d')" >> "$GITHUB_OUTPUT"
echo "date_compact=$(date -u +'%Y%m%d')" >> "$GITHUB_OUTPUT"
# Generate different tag/title by trigger type
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
TIME_SUFFIX="-$(date -u +'%H%M%S')"
echo "tag_suffix=$TIME_SUFFIX" >> "$GITHUB_OUTPUT"
echo "build_type=Manual Build" >> "$GITHUB_OUTPUT"
echo "datetime=$(date -u +'%Y-%m-%d %H:%M:%S UTC')" >> "$GITHUB_OUTPUT"
else
echo "tag_suffix=" >> "$GITHUB_OUTPUT"
echo "build_type=Nightly Build" >> "$GITHUB_OUTPUT"
echo "datetime=$(date -u +'%Y-%m-%d UTC')" >> "$GITHUB_OUTPUT"
fi
# Capture commit messages from the last 24 hours
echo "commits<<EOF" >> "$GITHUB_OUTPUT"
git log --since="24 hours ago" --pretty=format:"- %s (%h)" >> "$GITHUB_OUTPUT"
echo "" >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
- name: Build release artifacts
if: steps.check.outputs.should_build == 'true'
run: |
chmod +x scripts/package.sh
./scripts/package.sh --browser chrome --output "Sapling-nightly-chrome-${{ steps.info.outputs.date_compact }}${{ steps.info.outputs.tag_suffix }}.zip"
./scripts/package.sh --browser firefox --output "Sapling-nightly-firefox-${{ steps.info.outputs.date_compact }}${{ steps.info.outputs.tag_suffix }}.zip"
./scripts/package.sh --browser edge --output "Sapling-nightly-edge-${{ steps.info.outputs.date_compact }}${{ steps.info.outputs.tag_suffix }}.zip"
- name: Create nightly release
if: steps.check.outputs.should_build == 'true'
uses: softprops/action-gh-release@v1
with:
tag_name: nightly-${{ steps.info.outputs.date_compact }}${{ steps.info.outputs.tag_suffix }}
name: ${{ steps.info.outputs.build_type }} ${{ steps.info.outputs.date }}
body: |
**${{ steps.info.outputs.build_type }}** - ${{ steps.info.outputs.datetime }}
**Version:** ${{ steps.info.outputs.version }}
**Latest commit:** ${{ steps.info.outputs.short_sha }}
## Changes in the last 24 hours
${{ steps.info.outputs.commits }}
## Installation (Developer Mode)
- Chrome: Download `Sapling-nightly-chrome-${{ steps.info.outputs.date_compact }}${{ steps.info.outputs.tag_suffix }}.zip`, unzip, then load unpacked at `chrome://extensions/`
- Edge: Download `Sapling-nightly-edge-${{ steps.info.outputs.date_compact }}${{ steps.info.outputs.tag_suffix }}.zip`, unzip, then load unpacked at `edge://extensions/`
- Firefox: Download `Sapling-nightly-firefox-${{ steps.info.outputs.date_compact }}${{ steps.info.outputs.tag_suffix }}.zip`, unzip, then temporarily load `manifest.json` at `about:debugging#/runtime/this-firefox`
---
WARNING: Automated nightly build; may be unstable.
files: release/*.zip
prerelease: true
draft: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}