Skip to content

Commit d89ac87

Browse files
lcandy2cursoragent
andcommitted
fix: use latest release for tag resolution, skip if binaries exist
target_commitish stores the branch name ("main"), not the commit SHA, so the head_sha matching approach never finds a release. Revert to gh release view (returns latest) with an idempotency guard: skip the build if the release already has >=4 binary assets. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 7774080 commit d89ac87

1 file changed

Lines changed: 16 additions & 16 deletions

File tree

.github/workflows/release-binaries.yaml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,39 +54,44 @@ jobs:
5454
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
5555
echo "tag=${{ github.event.inputs.tag }}" >> "$GITHUB_OUTPUT"
5656
else
57-
SHA="${{ github.event.workflow_run.head_sha }}"
58-
TAG=$(gh api "repos/${{ github.repository }}/releases" --paginate \
59-
--jq ".[] | select(.target_commitish == \"$SHA\") | .tag_name" | head -n1)
60-
if [ -z "$TAG" ]; then
61-
echo "::error::No release found for commit $SHA"
62-
exit 1
57+
TAG=$(gh release view --repo "${{ github.repository }}" --json tagName -q .tagName)
58+
EXISTING=$(gh release view "$TAG" --repo "${{ github.repository }}" \
59+
--json assets --jq '[.assets[] | select(.name | startswith("photon-"))] | length')
60+
if [ "$EXISTING" -ge 4 ]; then
61+
echo "::notice::Release $TAG already has binaries, skipping"
62+
echo "skip=true" >> "$GITHUB_OUTPUT"
6363
fi
6464
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
6565
fi
6666
67-
- uses: actions/checkout@v5
67+
- if: steps.tag.outputs.skip != 'true'
68+
uses: actions/checkout@v5
6869
with:
6970
ref: ${{ steps.tag.outputs.tag }}
7071

71-
- uses: oven-sh/setup-bun@v2
72+
- if: steps.tag.outputs.skip != 'true'
73+
uses: oven-sh/setup-bun@v2
7274
with:
7375
bun-version: "1.3.13"
7476

7577
- name: Install
78+
if: steps.tag.outputs.skip != 'true'
7679
run: bun install --frozen-lockfile
7780

7881
- name: Compile binary
82+
if: steps.tag.outputs.skip != 'true'
7983
run: |
8084
bun build ./src/index.ts \
8185
--compile \
8286
--target=${{ matrix.target }} \
8387
--outfile dist/${{ matrix.asset }}
8488
8589
- name: Smoke test (native targets only)
86-
if: matrix.target == 'bun-darwin-arm64' || matrix.target == 'bun-linux-x64'
90+
if: steps.tag.outputs.skip != 'true' && (matrix.target == 'bun-darwin-arm64' || matrix.target == 'bun-linux-x64')
8791
run: ./dist/${{ matrix.asset }} --version
8892

8993
- name: Compute SHA256
94+
if: steps.tag.outputs.skip != 'true'
9095
run: |
9196
if command -v shasum >/dev/null 2>&1; then
9297
shasum -a 256 dist/${{ matrix.asset }} > dist/${{ matrix.asset }}.sha256
@@ -95,6 +100,7 @@ jobs:
95100
fi
96101
97102
- name: Upload to release
103+
if: steps.tag.outputs.skip != 'true'
98104
env:
99105
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
100106
run: |
@@ -115,13 +121,7 @@ jobs:
115121
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
116122
echo "tag=${{ github.event.inputs.tag }}" >> "$GITHUB_OUTPUT"
117123
else
118-
SHA="${{ github.event.workflow_run.head_sha }}"
119-
TAG=$(gh api "repos/${{ github.repository }}/releases" --paginate \
120-
--jq ".[] | select(.target_commitish == \"$SHA\") | .tag_name" | head -n1)
121-
if [ -z "$TAG" ]; then
122-
echo "::error::No release found for commit $SHA"
123-
exit 1
124-
fi
124+
TAG=$(gh release view --repo "${{ github.repository }}" --json tagName -q .tagName)
125125
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
126126
fi
127127

0 commit comments

Comments
 (0)