From 2527e2a821c02e012bde4b82e443f1b77aac3237 Mon Sep 17 00:00:00 2001 From: Zane <75694352+zanesq@users.noreply.github.com> Date: Fri, 16 May 2025 15:23:37 -0700 Subject: [PATCH] Attempt to fix .bundle workflow checkout (#2566) --- .github/workflows/bundle-desktop.yml | 97 +++++++++++++++++++------ .github/workflows/pr-comment-bundle.yml | 65 ++++++++++++++++- 2 files changed, 135 insertions(+), 27 deletions(-) diff --git a/.github/workflows/bundle-desktop.yml b/.github/workflows/bundle-desktop.yml index 38798cc7..5eb13d10 100644 --- a/.github/workflows/bundle-desktop.yml +++ b/.github/workflows/bundle-desktop.yml @@ -21,6 +21,11 @@ on: required: false default: true type: boolean + ref: + description: 'Git ref to checkout (branch, tag, or SHA). Defaults to main branch if not specified.' + required: false + type: string + default: '' secrets: CERTIFICATE_OSX_APPLICATION: description: 'Certificate for macOS application signing' @@ -45,6 +50,30 @@ jobs: runs-on: macos-latest name: Bundle Desktop App on macOS steps: + # Debug information about the workflow and inputs + - name: Debug workflow info + env: + WORKFLOW_NAME: ${{ github.workflow }} + WORKFLOW_REF: ${{ github.ref }} + EVENT_NAME: ${{ github.event_name }} + REPOSITORY: ${{ github.repository }} + INPUT_REF: ${{ inputs.ref }} + INPUT_VERSION: ${{ inputs.version }} + INPUT_SIGNING: ${{ inputs.signing }} + INPUT_QUICK_TEST: ${{ inputs.quick_test }} + run: | + echo "=== Workflow Information ===" + echo "Workflow: ${WORKFLOW_NAME}" + echo "Ref: ${WORKFLOW_REF}" + echo "Event: ${EVENT_NAME}" + echo "Repo: ${REPOSITORY}" + echo "" + echo "=== Input Parameters ===" + echo "Build ref: ${INPUT_REF:-}" + echo "Version: ${INPUT_VERSION:-not set}" + echo "Signing: ${INPUT_SIGNING:-false}" + echo "Quick test: ${INPUT_QUICK_TEST:-true}" + # Check initial disk space - name: Check initial disk space run: df -h @@ -52,43 +81,63 @@ jobs: # Validate Signing Secrets if signing is enabled - name: Validate Signing Secrets if: ${{ inputs.signing }} + env: + HAS_CERT: ${{ secrets.CERTIFICATE_OSX_APPLICATION != '' }} + HAS_CERT_PASS: ${{ secrets.CERTIFICATE_PASSWORD != '' }} + HAS_APPLE_ID: ${{ secrets.APPLE_ID != '' }} + HAS_APPLE_PASS: ${{ secrets.APPLE_ID_PASSWORD != '' }} + HAS_TEAM_ID: ${{ secrets.APPLE_TEAM_ID != '' }} run: | - if [[ -z "${{ secrets.CERTIFICATE_OSX_APPLICATION }}" ]]; then - echo "Error: CERTIFICATE_OSX_APPLICATION secret is required for signing." - exit 1 - fi - if [[ -z "${{ secrets.CERTIFICATE_PASSWORD }}" ]]; then - echo "Error: CERTIFICATE_PASSWORD secret is required for signing." - exit 1 - fi - if [[ -z "${{ secrets.APPLE_ID }}" ]]; then - echo "Error: APPLE_ID secret is required for signing." - exit 1 - fi - if [[ -z "${{ secrets.APPLE_ID_PASSWORD }}" ]]; then - echo "Error: APPLE_ID_PASSWORD secret is required for signing." - exit 1 - fi - if [[ -z "${{ secrets.APPLE_TEAM_ID }}" ]]; then - echo "Error: APPLE_TEAM_ID secret is required for signing." + missing=() + [[ "${HAS_CERT}" != "true" ]] && missing+=("CERTIFICATE_OSX_APPLICATION") + [[ "${HAS_CERT_PASS}" != "true" ]] && missing+=("CERTIFICATE_PASSWORD") + [[ "${HAS_APPLE_ID}" != "true" ]] && missing+=("APPLE_ID") + [[ "${HAS_APPLE_PASS}" != "true" ]] && missing+=("APPLE_ID_PASSWORD") + [[ "${HAS_TEAM_ID}" != "true" ]] && missing+=("APPLE_TEAM_ID") + + if (( ${#missing[@]} > 0 )); then + echo "Error: Missing required signing secrets:" + printf '%s\n' "${missing[@]}" exit 1 fi + echo "All required signing secrets are present." - name: Checkout code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + with: + # Only pass ref if it's explicitly set, otherwise let checkout action use its default behavior + ref: ${{ inputs.ref != '' && inputs.ref || '' }} + fetch-depth: 0 + + - name: Debug git status + run: | + echo "=== Git Status ===" + git status + echo "" + echo "=== Current Commit ===" + git rev-parse HEAD + git rev-parse --abbrev-ref HEAD + echo "" + echo "=== Recent Commits ===" + git log --oneline -n 5 + echo "" + echo "=== Remote Branches ===" + git branch -r # Update versions before build - name: Update versions if: ${{ inputs.version != '' }} + env: + VERSION: ${{ inputs.version }} run: | # Update version in Cargo.toml - sed -i.bak 's/^version = ".*"/version = "'${{ inputs.version }}'"/' Cargo.toml + sed -i.bak "s/^version = \".*\"/version = \"${VERSION}\"/" Cargo.toml rm -f Cargo.toml.bak # Update version in package.json cd ui/desktop - npm version ${{ inputs.version }} --no-git-tag-version --allow-same-version + npm version "${VERSION}" --no-git-tag-version --allow-same-version # Pre-build cleanup to ensure enough disk space - name: Pre-build cleanup @@ -194,6 +243,10 @@ jobs: - name: Make Signed App if: ${{ inputs.signing }} + env: + APPLE_ID: ${{ secrets.APPLE_ID }} + APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }} + APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} run: | attempt=0 max_attempts=2 @@ -208,10 +261,6 @@ jobs: exit 1 fi working-directory: ui/desktop - env: - APPLE_ID: ${{ secrets.APPLE_ID }} - APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }} - APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} - name: Final cleanup before artifact upload run: | diff --git a/.github/workflows/pr-comment-bundle.yml b/.github/workflows/pr-comment-bundle.yml index 3e772e16..7fff647f 100644 --- a/.github/workflows/pr-comment-bundle.yml +++ b/.github/workflows/pr-comment-bundle.yml @@ -28,9 +28,26 @@ jobs: runs-on: ubuntu-latest outputs: continue: ${{ steps.command.outputs.continue || github.event_name == 'workflow_dispatch' }} - # Cannot use github.event.pull_request.number since the trigger is 'issue_comment' pr_number: ${{ steps.command.outputs.issue_number || github.event.inputs.pr_number }} + pr_sha: ${{ steps.get_pr_info.outputs.sha }} steps: + - name: Debug workflow trigger + env: + WORKFLOW_NAME: ${{ github.workflow }} + WORKFLOW_REF: ${{ github.ref }} + EVENT_NAME: ${{ github.event_name }} + EVENT_ACTION: ${{ github.event.action }} + ACTOR: ${{ github.actor }} + REPOSITORY: ${{ github.repository }} + run: | + echo "=== Workflow Trigger Info ===" + echo "Workflow: ${WORKFLOW_NAME}" + echo "Ref: ${WORKFLOW_REF}" + echo "Event: ${EVENT_NAME}" + echo "Action: ${EVENT_ACTION}" + echo "Actor: ${ACTOR}" + echo "Repository: ${REPOSITORY}" + - if: ${{ github.event_name == 'issue_comment' }} uses: github/command@319d5236cc34ed2cb72a47c058a363db0b628ebe # pin@v1.3.0 id: command @@ -40,13 +57,51 @@ jobs: reaction: "eyes" allowed_contexts: pull_request + # Get the PR's SHA + - name: Get PR info + id: get_pr_info + if: ${{ steps.command.outputs.continue == 'true' || github.event_name == 'workflow_dispatch' }} + uses: actions/github-script@v7 + with: + script: | + const prNumber = context.payload.inputs?.pr_number || core.getInput('command_issue_number'); + if (!prNumber) { + throw new Error('No PR number found'); + } + + const { data: pr } = await github.rest.pulls.get({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: parseInt(prNumber, 10) + }); + + console.log('PR Details:', { + number: pr.number, + head: { + ref: pr.head.ref, + sha: pr.head.sha, + label: pr.head.label + }, + base: { + ref: pr.base.ref, + sha: pr.base.sha, + label: pr.base.label + } + }); + + core.setOutput('sha', pr.head.sha); + inputs: | + { + "command_issue_number": "${{ steps.command.outputs.issue_number }}" + } + bundle-desktop: - # Only run this if ".bundle" command is detected. needs: [trigger-on-command] if: ${{ needs.trigger-on-command.outputs.continue == 'true' }} uses: ./.github/workflows/bundle-desktop.yml with: signing: true + ref: ${{ needs.trigger-on-command.outputs.pr_sha }} secrets: CERTIFICATE_OSX_APPLICATION: ${{ secrets.CERTIFICATE_OSX_APPLICATION }} CERTIFICATE_PASSWORD: ${{ secrets.CERTIFICATE_PASSWORD }} @@ -69,13 +124,17 @@ jobs: path: arm64-dist - name: Comment on PR with ARM64 download link + env: + REPOSITORY: ${{ github.repository }} + RUN_ID: ${{ github.run_id }} + PR_NUMBER: ${{ needs.trigger-on-command.outputs.pr_number }} uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # pin@v4 with: issue-number: ${{ needs.trigger-on-command.outputs.pr_number }} body: | ### macOS ARM64 Desktop App (Apple Silicon) - [📱 Download macOS Desktop App (arm64, signed)](https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }}/Goose-darwin-arm64.zip) + [📱 Download macOS Desktop App (arm64, signed)](https://nightly.link/${REPOSITORY}/actions/runs/${RUN_ID}/Goose-darwin-arm64.zip) **Instructions:** After downloading, unzip the file and drag the Goose.app to your Applications folder. The app is signed and notarized for macOS.