Skip to content

Commit 39a972f

Browse files
committed
ci(cli): build preview artifacts without smoke matrix
1 parent bf20cce commit 39a972f

5 files changed

Lines changed: 163 additions & 162 deletions

File tree

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Build CLI Artifacts
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
version:
7+
description: CLI package version to build
8+
required: true
9+
type: string
10+
shell:
11+
description: CLI shell to package as the shipped supabase binary
12+
required: true
13+
type: string
14+
secrets:
15+
SENTRY_DSN:
16+
required: false
17+
POSTHOG_API_KEY:
18+
required: false
19+
POSTHOG_ENDPOINT:
20+
required: false
21+
22+
permissions:
23+
contents: read
24+
25+
jobs:
26+
build:
27+
name: Build CLI artifacts
28+
runs-on: blacksmith-32vcpu-ubuntu-2404
29+
env:
30+
BUN_SHELL: ${{ inputs.shell }}
31+
VERSION: ${{ inputs.version }}
32+
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
33+
POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }}
34+
POSTHOG_ENDPOINT: ${{ secrets.POSTHOG_ENDPOINT }}
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
38+
with:
39+
persist-credentials: false
40+
41+
- name: Setup
42+
uses: ./.github/actions/setup
43+
44+
- name: Setup Go
45+
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
46+
with:
47+
go-version-file: apps/cli-go/go.mod
48+
cache: true
49+
cache-dependency-path: apps/cli-go/go.sum
50+
51+
- name: Pre-download Go modules
52+
working-directory: apps/cli-go
53+
run: go mod download -x
54+
55+
- name: Install nfpm
56+
run: |
57+
echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' | sudo tee /etc/apt/sources.list.d/goreleaser.list
58+
sudo apt-get update
59+
sudo apt-get install -y nfpm
60+
61+
- name: Sync versions
62+
run: pnpm exec bun apps/cli/scripts/sync-versions.ts --version "${VERSION}"
63+
64+
- name: Build selected shell
65+
run: pnpm exec bun apps/cli/scripts/build.ts --version "${VERSION}" --shell "${BUN_SHELL}"
66+
67+
- name: Verify build artifacts
68+
run: |
69+
for pkg in cli-darwin-arm64 cli-darwin-x64 cli-linux-arm64 cli-linux-arm64-musl cli-linux-x64 cli-linux-x64-musl cli-windows-arm64 cli-windows-x64; do
70+
echo "Checking packages/$pkg/bin/..."
71+
ls -la "packages/$pkg/bin/"
72+
done
73+
echo "Checking dist/..."
74+
ls -la dist/
75+
76+
- name: Upload build artifacts
77+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
78+
with:
79+
name: cli-build-${{ inputs.shell }}-${{ inputs.version }}
80+
path: |
81+
packages/cli-*/bin/
82+
dist/
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Build Preview CLI Packages
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- synchronize
8+
- reopened
9+
- ready_for_review
10+
branches:
11+
- develop
12+
13+
permissions:
14+
contents: read
15+
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.head_ref }}
18+
cancel-in-progress: true
19+
20+
jobs:
21+
build:
22+
if: github.event.pull_request.draft == false
23+
name: Build preview CLI packages
24+
uses: ./.github/workflows/build-cli-artifacts.yml
25+
with:
26+
version: 0.0.0-pr.${{ github.event.pull_request.number }}
27+
shell: legacy

.github/workflows/pkg-pr-new.yml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_run:
55
workflows:
66
- Test
7-
- Smoke Test (PR)
7+
- Build Preview CLI Packages
88
types:
99
- completed
1010

@@ -39,7 +39,7 @@ jobs:
3939
should_publish=false
4040
pr_number=""
4141
pr_head_sha=""
42-
smoke_run_id=""
42+
preview_build_run_id=""
4343
test_run_id=""
4444
4545
pr_number="$(jq -r '.workflow_run.pull_requests[0].number // ""' "$GITHUB_EVENT_PATH")"
@@ -70,8 +70,8 @@ jobs:
7070
exit 0
7171
fi
7272
73-
if [[ "${triggering_workflow}" == "Smoke Test (PR)" ]]; then
74-
smoke_run_id="$(jq -r '.workflow_run.id' "$GITHUB_EVENT_PATH")"
73+
if [[ "${triggering_workflow}" == "Build Preview CLI Packages" ]]; then
74+
preview_build_run_id="$(jq -r '.workflow_run.id' "$GITHUB_EVENT_PATH")"
7575
elif [[ "${triggering_workflow}" == "Test" ]]; then
7676
test_run_id="$(jq -r '.workflow_run.id' "$GITHUB_EVENT_PATH")"
7777
else
@@ -111,10 +111,10 @@ jobs:
111111
exit 0
112112
fi
113113
114-
if [[ -z "${smoke_run_id}" ]]; then
115-
smoke_run_id="$(
114+
if [[ -z "${preview_build_run_id}" ]]; then
115+
preview_build_run_id="$(
116116
gh run list \
117-
--workflow smoke-test-pr.yml \
117+
--workflow build-preview-cli-packages.yml \
118118
--event pull_request \
119119
--commit "${pr_head_sha}" \
120120
--status success \
@@ -135,8 +135,8 @@ jobs:
135135
)"
136136
fi
137137
138-
if [[ -z "${smoke_run_id}" ]]; then
139-
echo "No successful Smoke Test (PR) run found for ${pr_head_sha}; skipping."
138+
if [[ -z "${preview_build_run_id}" ]]; then
139+
echo "No successful Build Preview CLI Packages run found for ${pr_head_sha}; skipping."
140140
echo "should_publish=false" >> "$GITHUB_OUTPUT"
141141
exit 0
142142
fi
@@ -148,14 +148,14 @@ jobs:
148148
fi
149149
150150
artifact_name="$(
151-
gh api "repos/${REPOSITORY}/actions/runs/${smoke_run_id}/artifacts" \
151+
gh api "repos/${REPOSITORY}/actions/runs/${preview_build_run_id}/artifacts" \
152152
--paginate \
153153
--jq '.artifacts[] | select(.name | startswith("cli-build-legacy-")) | .name' \
154154
| head -n 1
155155
)"
156156
157157
if [[ -z "${artifact_name}" ]]; then
158-
echo "No legacy CLI build artifact found on Smoke Test (PR) run ${smoke_run_id}; skipping."
158+
echo "No legacy CLI build artifact found on Build Preview CLI Packages run ${preview_build_run_id}; skipping."
159159
echo "should_publish=false" >> "$GITHUB_OUTPUT"
160160
exit 0
161161
fi
@@ -169,7 +169,7 @@ jobs:
169169
echo "pr_head_sha=${pr_head_sha}"
170170
echo "preview_version=${preview_version}"
171171
echo "artifact_name=${artifact_name}"
172-
echo "smoke_run_id=${smoke_run_id}"
172+
echo "preview_build_run_id=${preview_build_run_id}"
173173
} >> "$GITHUB_OUTPUT"
174174
175175
- name: Checkout
@@ -183,12 +183,12 @@ jobs:
183183
if: steps.context.outputs.should_publish == 'true'
184184
uses: ./.github/actions/setup
185185

186-
- name: Download smoke artifacts
186+
- name: Download preview build artifacts
187187
if: steps.context.outputs.should_publish == 'true'
188-
run: gh run download "${SMOKE_RUN_ID}" --name "${ARTIFACT_NAME}"
188+
run: gh run download "${PREVIEW_BUILD_RUN_ID}" --name "${ARTIFACT_NAME}"
189189
env:
190190
ARTIFACT_NAME: ${{ steps.context.outputs.artifact_name }}
191-
SMOKE_RUN_ID: ${{ steps.context.outputs.smoke_run_id }}
191+
PREVIEW_BUILD_RUN_ID: ${{ steps.context.outputs.preview_build_run_id }}
192192

193193
- name: Prepare package files
194194
if: steps.context.outputs.should_publish == 'true'
@@ -245,7 +245,7 @@ jobs:
245245
${marker}
246246
## pkg.pr.new preview
247247
248-
Published version \`${PREVIEW_VERSION}\` from commit [\`${short_sha}\`](https://github.com/${REPOSITORY}/commit/${PR_HEAD_SHA}) after the PR test and release smoke workflows passed.
248+
Published version \`${PREVIEW_VERSION}\` from commit [\`${short_sha}\`](https://github.com/${REPOSITORY}/commit/${PR_HEAD_SHA}) after the PR test and preview build workflows passed.
249249
250250
\`\`\`sh
251251
npx ${preview_url}

.github/workflows/release-shared.yml

Lines changed: 6 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -53,61 +53,15 @@ on:
5353
required: false
5454
jobs:
5555
build:
56-
runs-on: blacksmith-32vcpu-ubuntu-2404
57-
env:
58-
BUN_SHELL: ${{ inputs.shell }}
59-
VERSION: ${{ inputs.version }}
56+
name: Build CLI artifacts
57+
uses: ./.github/workflows/build-cli-artifacts.yml
58+
with:
59+
version: ${{ inputs.version }}
60+
shell: ${{ inputs.shell }}
61+
secrets:
6062
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
6163
POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }}
6264
POSTHOG_ENDPOINT: ${{ secrets.POSTHOG_ENDPOINT }}
63-
steps:
64-
- name: Checkout
65-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
66-
with:
67-
persist-credentials: false
68-
69-
- name: Setup
70-
uses: ./.github/actions/setup
71-
72-
- name: Setup Go
73-
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
74-
with:
75-
go-version-file: apps/cli-go/go.mod
76-
cache: true
77-
cache-dependency-path: apps/cli-go/go.sum
78-
79-
- name: Pre-download Go modules
80-
working-directory: apps/cli-go
81-
run: go mod download -x
82-
83-
- name: Install nfpm
84-
run: |
85-
echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' | sudo tee /etc/apt/sources.list.d/goreleaser.list
86-
sudo apt-get update
87-
sudo apt-get install -y nfpm
88-
89-
- name: Sync versions
90-
run: pnpm exec bun apps/cli/scripts/sync-versions.ts --version "${VERSION}"
91-
92-
- name: Build selected shell
93-
run: pnpm exec bun apps/cli/scripts/build.ts --version "${VERSION}" --shell "${BUN_SHELL}"
94-
95-
- name: Verify build artifacts
96-
run: |
97-
for pkg in cli-darwin-arm64 cli-darwin-x64 cli-linux-arm64 cli-linux-arm64-musl cli-linux-x64 cli-linux-x64-musl cli-windows-arm64 cli-windows-x64; do
98-
echo "Checking packages/$pkg/bin/..."
99-
ls -la "packages/$pkg/bin/"
100-
done
101-
echo "Checking dist/..."
102-
ls -la dist/
103-
104-
- name: Upload build artifacts
105-
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
106-
with:
107-
name: cli-build-${{ inputs.shell }}-${{ inputs.version }}
108-
path: |
109-
packages/cli-*/bin/
110-
dist/
11165

11266
smoke-test:
11367
needs: build

0 commit comments

Comments
 (0)