-
Notifications
You must be signed in to change notification settings - Fork 24
Rework website #130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Rework website #130
Changes from all commits
e0f175b
e8836b7
cbf3e86
3f99f6c
e4c2a2a
064b8d9
0ccff65
58dcc77
ae92051
f32d7cf
0e58518
b5a866e
b77eee2
7ff9c60
196f264
95ffbb6
05b97f2
6c5ea22
64e085f
651fee1
1f7689d
5228d6d
6219c87
10f1377
c533bc5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,40 +41,117 @@ jobs: | |
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Copy artifacts to website folder | ||
| - name: Copy artifacts to website public folder | ||
| run: | | ||
| mkdir -p website | ||
| mkdir -p website/public | ||
|
|
||
| # Copy macOS DMG | ||
| DMG_FILE=$(find /tmp/artifacts -name "*.dmg" | head -1) | ||
| if [ -n "$DMG_FILE" ]; then | ||
| cp "$DMG_FILE" website/astro-editor-latest.dmg | ||
| cp "$DMG_FILE" website/public/astro-editor-latest.dmg | ||
| echo "Copied DMG: $DMG_FILE" | ||
| fi | ||
|
|
||
| # Copy Windows MSI | ||
| MSI_FILE=$(find /tmp/artifacts -name "*.msi" | head -1) | ||
| if [ -n "$MSI_FILE" ]; then | ||
| cp "$MSI_FILE" website/astro-editor-latest.msi | ||
| cp "$MSI_FILE" website/public/astro-editor-latest.msi | ||
| echo "Copied MSI: $MSI_FILE" | ||
| fi | ||
|
|
||
| # Copy Linux AppImage | ||
| APPIMAGE_FILE=$(find /tmp/artifacts -name "*.AppImage" | head -1) | ||
| if [ -n "$APPIMAGE_FILE" ]; then | ||
| cp "$APPIMAGE_FILE" website/astro-editor-latest.AppImage | ||
| cp "$APPIMAGE_FILE" website/public/astro-editor-latest.AppImage | ||
| echo "Copied AppImage: $APPIMAGE_FILE" | ||
| fi | ||
|
|
||
| echo "Website folder contents:" | ||
| ls -la website/*.dmg website/*.msi website/*.AppImage 2>/dev/null || true | ||
| echo "Website public folder contents:" | ||
| ls -la website/public/*.dmg website/public/*.msi website/public/*.AppImage 2>/dev/null || true | ||
|
|
||
| - name: Commit website artifacts | ||
| - name: Generate release page | ||
| run: | | ||
| RELEASE_BODY=$(gh release view "$RELEASE_TAG" --json body -q .body) | ||
| VERSION="${RELEASE_TAG#v}" | ||
| DATE=$(gh release view "$RELEASE_TAG" --json publishedAt -q .publishedAt | cut -dT -f1) | ||
|
|
||
| # Sanitise body for MDX: | ||
| # - Strip leading H2 title | ||
| # - Strip "Installation Instructions" section and everything after | ||
| # - Strip "Full Changelog" links | ||
| # - Escape curly braces outside code spans/blocks | ||
| # | ||
| # NOTE: This logic is duplicated in website/scripts/generate-release-pages.ts | ||
| # (sanitiseBody, escapeCurlyBraces, localiseImages). If you change this, | ||
| # update that script too (and vice versa). | ||
| CLEAN_BODY=$(printf '%s\n' "$RELEASE_BODY" | \ | ||
| sed '/^## *\(🚀 *\)\{0,1\}Astro Editor v[0-9]/d' | \ | ||
| sed '/^### Installation Instructions/,$d' | \ | ||
| sed '/^\*\*Full Changelog\*\*/d' | \ | ||
|
dannysmith marked this conversation as resolved.
|
||
| awk ' | ||
| /^```/ { in_code = !in_code } | ||
| in_code { print; next } | ||
| { | ||
| line = "" | ||
| n = split($0, chars, "") | ||
| in_tick = 0 | ||
| for (i = 1; i <= n; i++) { | ||
| if (chars[i] == "`") in_tick = !in_tick | ||
| if (!in_tick && chars[i] == "{") { line = line "" "{"; continue } | ||
| if (!in_tick && chars[i] == "}") { line = line "" "}"; continue } | ||
| line = line chars[i] | ||
| } | ||
| print line | ||
| } | ||
| ' | \ | ||
| sed -e :a -e '/^[[:space:]]*$/{ $d; N; ba; }') | ||
|
|
||
| # Download GitHub attachment images to local repo | ||
| IMAGES_DIR="website/public/releases" | ||
| mkdir -p "$IMAGES_DIR" | ||
| IMAGE_URLS=$(printf '%s\n' "$CLEAN_BODY" | grep -oE 'https://github\.com/user-attachments/assets/[a-f0-9-]+' | sort -u || true) | ||
| IMG_INDEX=0 | ||
| for URL in $IMAGE_URLS; do | ||
| IMG_INDEX=$((IMG_INDEX + 1)) | ||
| LOCAL_NAME="${VERSION}-${IMG_INDEX}.png" | ||
| curl -sL -o "${IMAGES_DIR}/${LOCAL_NAME}" "$URL" | ||
| CLEAN_BODY=$(printf '%s' "$CLEAN_BODY" | sed "s|${URL}|/releases/${LOCAL_NAME}|g") | ||
| echo "Downloaded image: ${LOCAL_NAME}" | ||
| done | ||
|
Comment on lines
+114
to
+120
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Potential issue with The Consider using a safer approach: Proposed fix using awk or printf escaping for URL in $IMAGE_URLS; do
IMG_INDEX=$((IMG_INDEX + 1))
LOCAL_NAME="${VERSION}-${IMG_INDEX}.png"
curl -sL -o "${IMAGES_DIR}/${LOCAL_NAME}" "$URL"
- CLEAN_BODY=$(printf '%s' "$CLEAN_BODY" | sed "s|${URL}|/releases/${LOCAL_NAME}|g")
+ CLEAN_BODY="${CLEAN_BODY//"$URL"/"/releases/${LOCAL_NAME}"}"
echo "Downloaded image: ${LOCAL_NAME}"
done🤖 Prompt for AI Agents |
||
|
|
||
| # Generate MDX file | ||
| RELEASES_DIR="website/src/content/docs/releases" | ||
| mkdir -p "$RELEASES_DIR" | ||
| OUTPUT_FILE="$RELEASES_DIR/${VERSION}.mdx" | ||
|
|
||
| { | ||
| printf '%s\n' "---" | ||
| printf '%s\n' "title: 'v${VERSION}'" | ||
| printf '%s\n' "description: 'Astro Editor v${VERSION}'" | ||
| printf '%s\n' "date: ${DATE}" | ||
| printf '%s\n' "slug: 'releases/v${VERSION}'" | ||
| printf '%s\n' "---" | ||
|
|
||
| if [ -n "$CLEAN_BODY" ]; then | ||
| printf '\n%s\n\n%s\n' "$CLEAN_BODY" "---" | ||
| fi | ||
|
|
||
| printf '\n%s\n' "[View on GitHub](https://github.com/dannysmith/astro-editor/releases/tag/${RELEASE_TAG})" | ||
| } > "$OUTPUT_FILE" | ||
|
|
||
| echo "Generated release page: $OUTPUT_FILE" | ||
| cat "$OUTPUT_FILE" | ||
|
Comment on lines
+72
to
+143
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplicated sanitization logic diverges from the TypeScript implementation. This inline bash reimplements the release page generation logic that already exists in
Consider invoking the TypeScript script directly instead of maintaining parallel implementations: 🔧 Suggested approach: Use the existing script - name: Generate release page
run: |
- RELEASE_BODY=$(gh release view "$RELEASE_TAG" --json body -q .body)
- # ... 60+ lines of bash sanitization ...
+ cd website
+ npx tsx scripts/generate-release-pages.ts --all
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}This requires setting up Node/Bun in an earlier step, but ensures consistent behavior between manual and automated generation. 🤖 Prompt for AI Agents |
||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Commit website artifacts and release page | ||
| run: | | ||
| git config --local user.email "action@github.com" | ||
| git config --local user.name "GitHub Action" | ||
| git add website/astro-editor-latest.dmg website/astro-editor-latest.msi website/astro-editor-latest.AppImage 2>/dev/null || true | ||
| git commit -m "chore: update installers for $RELEASE_TAG" || echo "No changes to commit" | ||
| git add website/public/astro-editor-latest.dmg website/public/astro-editor-latest.msi website/public/astro-editor-latest.AppImage 2>/dev/null || true | ||
| git add website/public/releases/*.png 2>/dev/null || true | ||
| git add website/src/content/docs/releases/*.mdx 2>/dev/null || true | ||
| git commit -m "chore: update installers and add release page for $RELEASE_TAG" || echo "No changes to commit" | ||
| git pull --rebase origin main | ||
| git push origin main | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |
| "css": "css" | ||
| }, | ||
| "files.associations": { | ||
| "*.css": "tailwindcss" | ||
| "*.css": "tailwindcss", | ||
| "*.mdx": "markdown" | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.