name: Schedule RC Release on: workflow_dispatch: inputs: dry_run: description: Validate the workflow without creating an RC version or tag required: false default: false type: boolean schedule: # Why: GitHub scheduled workflows are not guaranteed to start exactly on # time and can be delayed or dropped around high-load periods. We retry # across the full target hour and dedupe per PT slot. - cron: '*/5 3,15 * * *' timezone: 'America/Los_Angeles' permissions: contents: write concurrency: group: release-rc cancel-in-progress: false jobs: create-rc-tag: runs-on: ubuntu-latest timeout-minutes: 15 outputs: tag: ${{ steps.version.outputs.tag }} should_release: ${{ steps.existing.outputs.already_ran != 'true' && !(github.event_name == 'workflow_dispatch' && inputs.dry_run) }} steps: - name: Checkout uses: actions/checkout@v4 with: ref: main fetch-depth: 0 - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: 24 - name: Configure git author run: | git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - name: Sync with latest main run: | git fetch origin main --tags git checkout main git reset --hard origin/main - name: Compute RC slot id: slot run: | slot=$(TZ=America/Los_Angeles date '+%Y-%m-%d-%H') echo "value=$slot" >>"$GITHUB_OUTPUT" - name: Skip if this PT release window already ran id: existing run: | # Why: GitHub can delay or drop schedule events, especially near the # start of the hour. We schedule multiple attempts inside each target # PT hour and make the release idempotent per hour by embedding a # slot marker in the release commit message. if git log origin/main --grep="\\[rc-slot:${{ steps.slot.outputs.value }}\\]" -n 1 --format=%H | grep -q .; then echo "already_ran=true" >>"$GITHUB_OUTPUT" exit 0 fi # Why: the first scheduled run today used the earlier workflow before # slot markers existed. Keep a tag-time fallback so retries in the # same PT hour still skip if an RC tag was already created. latest_rc_tag="$(git for-each-ref --sort=-creatordate --format='%(refname:short) %(creatordate:iso-strict)' 'refs/tags/v*-rc.*' | head -n 1)" if [[ -n "$latest_rc_tag" ]]; then latest_rc_tag_name="${latest_rc_tag%% *}" latest_rc_tag_date="${latest_rc_tag#* }" latest_rc_slot="$(TZ=America/Los_Angeles date -d "$latest_rc_tag_date" '+%Y-%m-%d-%H')" if [[ "$latest_rc_slot" == "${{ steps.slot.outputs.value }}" ]]; then echo "already_ran=true" >>"$GITHUB_OUTPUT" echo "reason=latest_rc_tag:$latest_rc_tag_name" >>"$GITHUB_OUTPUT" exit 0 fi fi echo "already_ran=false" >>"$GITHUB_OUTPUT" - name: Dry run summary if: github.event_name == 'workflow_dispatch' && inputs.dry_run run: | echo "Dry run only." echo "Current PT slot: ${{ steps.slot.outputs.value }}" echo "Already ran this slot: ${{ steps.existing.outputs.already_ran }}" echo "Reason: ${{ steps.existing.outputs.reason }}" - name: Create and push RC tag id: version if: steps.existing.outputs.already_ran != 'true' && !(github.event_name == 'workflow_dispatch' && inputs.dry_run) env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | # Why: pushes made with GITHUB_TOKEN do not reliably trigger other # workflows via push events. The RC workflow invokes release.yml # directly after creating the tag, so the actual Electron release # runs inside this scheduled flow instead of depending on push. new_tag="$(npm version prerelease --preid=rc -m "release: %s [rc-slot:${{ steps.slot.outputs.value }}]")" git push origin main --follow-tags echo "tag=$new_tag" >>"$GITHUB_OUTPUT" release-rc: needs: create-rc-tag if: needs.create-rc-tag.outputs.should_release == 'true' uses: ./.github/workflows/release.yml with: tag: ${{ needs.create-rc-tag.outputs.tag }} secrets: inherit