Skip to content

Commit e5f3723

Browse files
committed
feat: add template artifact job to prepare-release pipeline
- Add --version, --tarball-dir, and --output-dir flags to prepare-template-artifact.ts for reuse across CI and release - Add template-artifact job to prepare-release workflow that downloads release tarballs and produces a template zip artifact - Update install-appkit-tarball skill with --template mode for scaffolding new apps from CI template artifacts - Temporarily trigger prepare-release on this branch for testing Signed-off-by: Pawel Kosiec <pawel.kosiec@databricks.com>
1 parent f2ecb44 commit e5f3723

6 files changed

Lines changed: 317 additions & 148 deletions

File tree

Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
---
2+
name: install-appkit-artifact
3+
description: "Install appkit CI artifacts into a project or scaffold a new app from a CI template artifact. Downloads from the prepare-release CI workflow (default) or builds locally. Use when testing appkit release candidates, installing pre-release appkit, scaffolding a new app from template, or when user says 'install appkit tarball', 'install appkit artifact', 'install local appkit', 'use local appkit', 'link appkit tgz', 'install appkit from CI', 'create app from template', 'init app from CI'."
4+
user-invocable: true
5+
allowed-tools: Read, Edit, Bash, Glob
6+
---
7+
8+
# Install AppKit Artifact
9+
10+
Installs AppKit tgz packages into a project from either the CI prepare-release workflow or a local build. Can also scaffold a new app from a CI template artifact.
11+
12+
## Arguments
13+
14+
Parse the user's input to determine mode and options:
15+
16+
- **No args** → CI mode, latest successful prepare-release run, install in CWD
17+
- **GitHub Actions URL** (contains `actions/runs/`) → CI mode, extract run ID from URL
18+
- **Numeric run ID** → CI mode, that specific run
19+
- **`--local <path>`** → Local build mode from the given appkit repo path
20+
- **`--dir <path>`** (combinable with any above) → Override install target directory (default: CWD)
21+
- **`--template`** → Template mode: scaffold a new app from the CI template artifact instead of installing tarballs into an existing project
22+
23+
## Workflow
24+
25+
Follow these steps exactly:
26+
27+
### Step 1: Determine mode
28+
29+
If `--template` was provided, go to **Template Mode** below. Otherwise continue with **Install Mode**.
30+
31+
---
32+
33+
## Install Mode
34+
35+
### Step 2: Determine target directory
36+
37+
If `--dir` was provided, use that path. Otherwise use the current working directory.
38+
Verify `package.json` exists in the target directory.
39+
40+
### Step 3: Get tgz files
41+
42+
#### Option A: CI mode (default)
43+
44+
**3a. Find the workflow run:**
45+
46+
If no run ID was provided, get the latest successful run:
47+
48+
```bash
49+
gh run list --repo databricks/appkit --workflow prepare-release.yml --status success --limit 1 --json databaseId,number
50+
```
51+
52+
If a GitHub Actions URL was provided, extract the run ID from it (the number after `/runs/`).
53+
54+
**3b. Find the artifact name:**
55+
56+
```bash
57+
gh api "repos/databricks/appkit/actions/runs/{RUN_ID}/artifacts" --jq '.artifacts[] | select(.name | test("^appkit-release-[0-9]")) | .name'
58+
```
59+
60+
**3c. Download the artifact:**
61+
62+
```bash
63+
gh run download {RUN_ID} --repo databricks/appkit --name "{ARTIFACT_NAME}" --dir /tmp/appkit-release-artifacts
64+
```
65+
66+
**3d. Verify checksums:**
67+
68+
```bash
69+
cd /tmp/appkit-release-artifacts && shasum -a 256 -c SHA256SUMS
70+
```
71+
72+
Note: Use `shasum -a 256` (macOS) not `sha256sum` (Linux).
73+
74+
**3e. Print the downloaded version:**
75+
76+
```bash
77+
cat /tmp/appkit-release-artifacts/VERSION
78+
```
79+
80+
The tgz files are now at `/tmp/appkit-release-artifacts/databricks-appkit-*.tgz` and `/tmp/appkit-release-artifacts/databricks-appkit-ui-*.tgz`.
81+
82+
#### Option B: Local build mode
83+
84+
**3a. Build tgz files:**
85+
86+
```bash
87+
cd {LOCAL_APPKIT_PATH} && pnpm pack:sdk
88+
```
89+
90+
**3b. Find the tgz files:**
91+
92+
Glob for `*.tgz` in:
93+
- `{LOCAL_APPKIT_PATH}/packages/appkit/tmp/*.tgz`
94+
- `{LOCAL_APPKIT_PATH}/packages/appkit-ui/tmp/*.tgz`
95+
96+
There should be exactly one tgz in each directory.
97+
98+
### Step 4: Copy tgz files to target directory
99+
100+
Copy both `databricks-appkit-*.tgz` and `databricks-appkit-ui-*.tgz` to the target directory.
101+
102+
### Step 5: Update package.json
103+
104+
Read `package.json` in the target directory. Edit `@databricks/appkit` and `@databricks/appkit-ui` dependency values to use `file:./` prefix pointing to the tgz filenames.
105+
106+
For example, if the tgz file is `databricks-appkit-0.22.0.tgz`:
107+
```json
108+
"@databricks/appkit": "file:./databricks-appkit-0.22.0.tgz"
109+
```
110+
111+
Same pattern for `@databricks/appkit-ui`.
112+
113+
### Step 6: Install dependencies
114+
115+
Run in the target directory:
116+
117+
```bash
118+
npm install --force ./databricks-appkit-{VERSION}.tgz ./databricks-appkit-ui-{VERSION}.tgz
119+
```
120+
121+
### Step 7: Clean up
122+
123+
If CI mode was used, remove the temp directory:
124+
125+
```bash
126+
rm -rf /tmp/appkit-release-artifacts
127+
```
128+
129+
### Step 8: Report
130+
131+
Print a summary:
132+
- Source: CI run #{number} or local build from {path}
133+
- Version installed
134+
- Target directory
135+
- Installed packages
136+
137+
---
138+
139+
## Template Mode
140+
141+
Scaffolds a new app by downloading the template artifact from a CI run and using `databricks apps init`.
142+
143+
### Step 2: Find the workflow run
144+
145+
If no run ID was provided, get the latest successful run:
146+
147+
```bash
148+
gh run list --repo databricks/appkit --workflow prepare-release.yml --status success --limit 1 --json databaseId,number
149+
```
150+
151+
If a GitHub Actions URL or numeric run ID was provided, use that instead.
152+
153+
### Step 3: Find the template artifact name
154+
155+
```bash
156+
gh api "repos/databricks/appkit/actions/runs/{RUN_ID}/artifacts" --jq '.artifacts[] | select(.name | test("^appkit-template-")) | .name'
157+
```
158+
159+
### Step 4: Download the template artifact
160+
161+
```bash
162+
gh run download {RUN_ID} --repo databricks/appkit --name "{ARTIFACT_NAME}" --dir /tmp/appkit-template-artifact
163+
```
164+
165+
### Step 5: Unzip the template
166+
167+
```bash
168+
mkdir -p /tmp/appkit-template && unzip -o /tmp/appkit-template-artifact/template.zip -d /tmp/appkit-template
169+
```
170+
171+
Note: The zip is named `template.zip` for release artifacts and `pr-template.zip` for PR artifacts. Check which file exists.
172+
173+
### Step 6: Hand off to the user
174+
175+
**Do NOT run `databricks apps init` yourself** — it is an interactive command that prompts for app name, features, resources, etc.
176+
177+
Print the following for the user to run in their terminal:
178+
179+
```
180+
databricks apps init --template /tmp/appkit-template
181+
```
182+
183+
Then tell them to clean up afterward:
184+
185+
```
186+
rm -rf /tmp/appkit-template-artifact /tmp/appkit-template
187+
```
188+
189+
### Step 7: Report
190+
191+
Print a summary:
192+
- Source: CI run #{number}
193+
- Template extracted to `/tmp/appkit-template`
194+
- Command to run provided above

.claude/skills/install-appkit-tarball.md

Lines changed: 0 additions & 126 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ jobs:
162162
run: pnpm pack:sdk
163163

164164
- name: Prepare template artifact
165-
run: pnpm exec tsx tools/prepare-template-artifact.ts "${{ steps.version.outputs.version }}"
165+
run: pnpm exec tsx tools/prepare-template-artifact.ts --version "${{ steps.version.outputs.version }}"
166166

167167
- name: Install template dependencies
168168
working-directory: pr-template

0 commit comments

Comments
 (0)