Skip to content

Commit a769597

Browse files
committed
Update release script and CI process for Pages deployment for new Astro site
1 parent ce109f3 commit a769597

12 files changed

Lines changed: 282 additions & 1689 deletions

File tree

.githooks/pre-commit

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ if git diff --cached --name-only | grep -q '^src/'; then
77
git add hdi
88
fi
99

10-
# Format staged site/ files with Prettier
11-
SITE_FILES=$(git diff --cached --name-only --diff-filter=ACMR | grep '^site/')
10+
# Format staged website/ files with Prettier
11+
SITE_FILES=$(git diff --cached --name-only --diff-filter=ACMR | grep '^website/')
1212
if [ -n "$SITE_FILES" ]; then
13-
npx --prefix site prettier --write $SITE_FILES
13+
npx --prefix website prettier --write $SITE_FILES
1414
echo "$SITE_FILES" | xargs git add
1515
fi

.github/workflows/ci.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,22 +65,25 @@ jobs:
6565
with:
6666
node-version: 24
6767

68+
- name: Build hdi from source
69+
run: ./build
70+
6871
- name: Install dependencies
69-
working-directory: site
72+
working-directory: website
7073
run: npm ci
7174

7275
- name: Install Playwright browsers
73-
working-directory: site
76+
working-directory: website
7477
run: npx playwright install chromium --with-deps
7578

7679
- name: Run Playwright tests
77-
working-directory: site
80+
working-directory: website
7881
run: npx playwright test
7982

8083
- name: Upload test report
8184
if: ${{ !cancelled() }}
8285
uses: actions/upload-artifact@v7
8386
with:
8487
name: playwright-report
85-
path: site/playwright-report/
88+
path: website/playwright-report/
8689
retention-days: 7

.github/workflows/pages.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,25 @@ jobs:
2121
url: ${{ steps.deployment.outputs.page_url }}
2222
steps:
2323
- uses: actions/checkout@v6
24+
25+
- uses: actions/setup-node@v6
26+
with:
27+
node-version: 24
28+
29+
- name: Build hdi from source
30+
run: ./build
31+
32+
- name: Install website dependencies
33+
working-directory: website
34+
run: npm ci
35+
36+
- name: Build Astro site
37+
working-directory: website
38+
run: npm run build
39+
2440
- uses: actions/configure-pages@v6
2541
- uses: actions/upload-pages-artifact@v4
2642
with:
27-
path: site
43+
path: website/dist
2844
- id: deployment
2945
uses: actions/deploy-pages@v5

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ playwright/.auth/
2626
# build output
2727
dist/
2828

29+
# auto-generated website data (produced by website/generate-data.sh)
30+
website/src/data/data.js
31+
2932
# generated types
3033
.astro/
3134

.prettierignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ bench/results.csv
88
bench/results.svg
99

1010
# Generated test files
11-
site/playwright-temp/
11+
website/playwright-temp/

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,10 @@ vhs ./demo/demo.tape
172172

173173
This outputs `demo.gif` from the tape file.
174174

175+
## Website
176+
177+
See `website/README.md` for instructions on running the demo website at https://hdi.md
178+
175179
## Benchmarking
176180

177181
Static benchmark READMEs in `bench/` (small, medium, large, stress) exercise parsing path at different scales. Run benchmarks with:
@@ -186,7 +190,7 @@ Benchmarks run automatically during `./release` and are recorded in `bench/resul
186190

187191
## Publishing a new release
188192

189-
The `release` script bumps the version in `src/header.sh`, rebuilds `hdi`, regenerates `site/data.js`, commits, tags and pushes. The `release` Actions workflow will automatically build and publish a GitHub release when the tag is pushed, and the demo site is redeployed. The script then prints the `url` and `sha256` values to update in the [homebrew-tap](https://github.com/grega/homebrew-tap) repo (`Formula/hdi.rb`).
193+
The `release` script bumps the version in `src/header.sh`, rebuilds `hdi`, commits, tags and pushes. The `release` Actions workflow will automatically build and publish a GitHub release when the tag is pushed, and the demo site is built and deployed via the `pages` workflow. The script then prints the `url` and `sha256` values to update in the [homebrew-tap](https://github.com/grega/homebrew-tap) repo (`Formula/hdi.rb`).
190194

191195
```bash
192196
./release patch # 0.1.0 → 0.1.1

release

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,24 +63,17 @@ echo "Releasing: $current → $new ($tag)"
6363

6464
sed -i.bak "s/^VERSION=\"$current\"/VERSION=\"$new\"/" "$SRC_HEADER" && rm -f "$SRC_HEADER.bak"
6565

66-
# Update site version references
67-
sed -i.bak "s/v$current/v$new/" "$SCRIPT_DIR/site/index.html" && rm -f "$SCRIPT_DIR/site/index.html.bak"
68-
sed -i.bak "s/v$current/v$new/" "$SCRIPT_DIR/site/demo.html" && rm -f "$SCRIPT_DIR/site/demo.html.bak"
69-
7066
# Rebuild hdi from source
7167
"$SCRIPT_DIR/build"
7268

73-
# Regenerate site data from fixtures
74-
bash "$SCRIPT_DIR/website/generate-data.sh"
75-
7669
# Run benchmarks against the new version
7770
if [[ -x "$SCRIPT_DIR/bench/run" ]]; then
7871
echo ""
7972
"$SCRIPT_DIR/bench/run" --log
8073
"$SCRIPT_DIR/bench/chart"
8174
fi
8275

83-
git add src/header.sh hdi bench/results.csv bench/results.svg site/index.html site/data.js
76+
git add src/header.sh hdi bench/results.csv bench/results.svg
8477
git commit -m "Bump version to $new"
8578
git tag "$tag"
8679
git push origin HEAD --tags

website/README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
Information page and interactive demo of the `hdi` CLI, built with [Astro](https://astro.build).
44

5+
## Prerequisites
6+
7+
The website depends on demo data generated from the `hdi` CLI. Before running the dev server or building, make sure `hdi` is built from the project root:
8+
9+
```bash
10+
./build
11+
```
12+
13+
Data generation happens automatically via `predev` and `prebuild` npm scripts, so you don't need to run `generate-data.sh` manually.
14+
515
## Local development
616

717
Install Node via [asdf](https://asdf-vm.com/) (see `.tool-versions`):
@@ -86,7 +96,7 @@ npm run astro -- --help
8696

8797
## Regenerating data
8898

89-
`src/data/data.js` is auto-generated from the fixture READMEs using `hdi --json`. To regenerate after changing fixtures or the parser locally, run from the `website/` directory:
99+
`src/data/data.js` is auto-generated from the fixture READMEs using `hdi --json` and is not committed to git. It is regenerated automatically when running `npm run dev` or `npm run build`. To regenerate manually, run from the `website/` directory:
90100

91101
```bash
92102
./generate-data.sh

website/generate-data.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
# generate-data.sh - Generate site/data.js from fixture READMEs using `hdi --json`
2+
# generate-data.sh - Generate src/data/data.js from fixture READMEs using `hdi --json`
33
set -euo pipefail
44

55
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
@@ -21,7 +21,7 @@ VERSION=$("$HDI" --version | awk '{print $2}')
2121

2222
# Start output
2323
{
24-
printf '// Auto-generated by site/generate-data.sh - do not edit manually\n\n'
24+
printf '// Auto-generated by website/generate-data.sh - do not edit manually\n\n'
2525
printf 'export const PROJECTS = [\n'
2626

2727
first_project=true

website/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
"node": ">=22.12.0"
77
},
88
"scripts": {
9+
"predev": "bash ./generate-data.sh",
910
"dev": "astro dev",
11+
"prebuild": "bash ./generate-data.sh",
1012
"build": "astro build",
1113
"preview": "astro preview",
1214
"astro": "astro",

0 commit comments

Comments
 (0)