mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
Add a `release` job (main only, contents: write) that builds the archive and publishes it as an immutable GitHub Release tagged site-<date>-<shortsha>, marked --latest, with bitvid-site.zip attached. This gives a stable download URL for the current production archive: https://github.com/PR0M3TH3AN/bitvid/releases/latest/download/bitvid-site.zip Re-runs of the same commit refresh the asset instead of failing. The Release holds only the public compiled dist/ (same as Vercel serves) and no Nostr signing key — publishing to nsite stays a manual, client-signed step. Per-branch artifact upload is unchanged. Docs updated. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01DwbE3uTiFaKRNjx5vP2muV
98 lines
3.3 KiB
YAML
98 lines
3.3 KiB
YAML
# Build a fresh, downloadable site archive on every push (any branch), so a
|
|
# ready-to-upload copy of the compiled app is always available for a MANUAL nsite
|
|
# publish (NIP-5A). This does NOT publish to nsite or touch any Nostr signing key —
|
|
# it just builds `dist/`.
|
|
# - every branch: upload it as a 30-day workflow artifact.
|
|
# - main only: also cut an immutable GitHub Release with the .zip attached,
|
|
# giving a stable download URL:
|
|
# https://github.com/PR0M3TH3AN/bitvid/releases/latest/download/bitvid-site.zip
|
|
# The Release contains only the public compiled app (same as Vercel serves) — no
|
|
# secret. See docs/nsite-mirror-plan.md.
|
|
name: Build site archive
|
|
|
|
on:
|
|
push:
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
# One archive build in flight per branch; a newer push supersedes an older one.
|
|
concurrency:
|
|
group: nsite-archive-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
archive:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 22
|
|
cache: npm
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Build static site
|
|
run: npm run build
|
|
|
|
- name: Short SHA
|
|
id: vars
|
|
run: echo "sha=${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT"
|
|
|
|
# `path: dist` stores the site files at the artifact root (index.html at top),
|
|
# so the downloaded .zip extracts straight to the nsite site directory.
|
|
- name: Upload site archive
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: bitvid-site-${{ github.ref_name }}-${{ steps.vars.outputs.sha }}
|
|
path: dist
|
|
if-no-files-found: error
|
|
retention-days: 30
|
|
|
|
# Production only: publish an immutable GitHub Release with the .zip attached, so
|
|
# the latest prod archive is always at a stable URL:
|
|
# https://github.com/PR0M3TH3AN/bitvid/releases/latest/download/bitvid-site.zip
|
|
# This is purely a download convenience + per-release snapshot — it does NOT
|
|
# publish to nsite and holds no Nostr signing key (that step stays manual).
|
|
release:
|
|
if: github.ref == 'refs/heads/main'
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 22
|
|
cache: npm
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
# `npm run archive` builds dist/ and writes bitvid-site.zip (index.html at root).
|
|
- name: Build site archive
|
|
run: npm run archive
|
|
|
|
- name: Publish site release
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
run: |
|
|
tag="site-$(date -u +%Y%m%d)-${GITHUB_SHA::7}"
|
|
notes="Compiled bitvid static app (\`dist/\`) at ${GITHUB_SHA}.
|
|
Stable latest link: https://github.com/${GITHUB_REPOSITORY}/releases/latest/download/bitvid-site.zip"
|
|
# Re-runs of the same commit reuse the tag: refresh the asset instead of failing.
|
|
if gh release view "$tag" >/dev/null 2>&1; then
|
|
gh release upload "$tag" bitvid-site.zip --clobber
|
|
gh release edit "$tag" --latest
|
|
else
|
|
gh release create "$tag" bitvid-site.zip \
|
|
--title "Site archive $tag" \
|
|
--notes "$notes" \
|
|
--latest
|
|
fi
|