name: Dev Channel Windows Publish on: workflow_call: inputs: wait_for_mac_job: description: Prefetch artifacts, then wait for this run's macOS job to succeed type: string default: '' channel: description: Dev channel whose live release receives the staged artifacts required: true type: string tag: description: Release tag used when staging the Windows artifacts required: true type: string permissions: contents: read actions: read concurrency: group: dev-channel-win-publish-${{ inputs.tag }} cancel-in-progress: false jobs: publish-win: if: github.repository == 'stablyai/orca' environment: adhoc-mac-build runs-on: ubuntu-latest timeout-minutes: 165 env: CHANNEL: ${{ inputs.channel }} TAG: ${{ inputs.tag }} steps: - name: Vet the requested inputs shell: bash run: | set -euo pipefail case "$CHANNEL" in hourly|daily|adhoc) ;; *) echo "::error::Unknown dev channel '$CHANNEL'."; exit 1 ;; esac if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+-${CHANNEL}\.[0-9]+$ ]]; then echo "::error::Tag '$TAG' is not a $CHANNEL release tag." exit 1 fi # No run-id: artifacts must belong to this run, never another dispatch. - name: Download the staged Windows artifacts uses: actions/download-artifact@v8 with: name: dev-channel-windows-${{ inputs.tag }} path: staged-windows - name: Validate staged Windows artifacts shell: bash run: | set -euo pipefail for required in orca-windows-setup.exe orca-windows-setup.exe.blockmap latest.yml; do if [[ ! -s "staged-windows/$required" ]]; then echo "::error::Missing or empty staged Windows artifact: $required" exit 1 fi done - name: Wait for successful macOS publication if: inputs.wait_for_mac_job != '' uses: actions/github-script@v8 env: MAC_JOB: ${{ inputs.wait_for_mac_job }} with: script: | const deadline = Date.now() + 150 * 60_000 while (Date.now() < deadline) { const jobs = await github.paginate(github.rest.actions.listJobsForWorkflowRun, { ...context.repo, run_id: context.runId, filter: 'latest', per_page: 100 }) const mac = jobs.find(job => job.name === process.env.MAC_JOB) if (mac?.status === 'completed') { if (mac.conclusion !== 'success') throw new Error('macOS publication did not succeed') return } await new Promise(resolve => setTimeout(resolve, 15_000)) } throw new Error('Timed out waiting for macOS publication') - name: Mint dev channel repo token id: app_token uses: actions/create-github-app-token@v2 with: app-id: ${{ secrets.HOURLY_RELEASE_APP_ID }} private-key: ${{ secrets.HOURLY_RELEASE_APP_PRIVATE_KEY }} owner: stablyai repositories: orca-${{ inputs.channel }} - name: Confirm the target release is live shell: bash env: GH_TOKEN: ${{ steps.app_token.outputs.token }} run: | set -euo pipefail draft="$(gh release view "$TAG" --repo "stablyai/orca-$CHANNEL" --json isDraft --jq '.isDraft')" if [[ "$draft" != false ]]; then echo "::error::Release $TAG is not live; refusing to publish Windows artifacts." exit 1 fi - name: Publish Windows artifacts uses: nick-fields/retry@v4 with: timeout_minutes: 5 max_attempts: 2 retry_wait_seconds: 10 command: gh release upload "$TAG" staged-windows/orca-windows-setup.exe staged-windows/orca-windows-setup.exe.blockmap staged-windows/latest.yml --clobber --repo "stablyai/orca-$CHANNEL" env: GH_TOKEN: ${{ steps.app_token.outputs.token }} - name: Verify Windows update manifest published shell: bash env: GH_TOKEN: ${{ steps.app_token.outputs.token }} run: | set -euo pipefail assets="$(gh release view "$TAG" --repo "stablyai/orca-$CHANNEL" --json assets --jq '.assets[].name')" for required in latest.yml orca-windows-setup.exe orca-windows-setup.exe.blockmap; do if ! grep -qx "$required" <<<"$assets"; then echo "::error::$TAG is missing $required; Windows could not install this build." exit 1 fi done