-
-
Notifications
You must be signed in to change notification settings - Fork 5
116 lines (100 loc) · 4.4 KB
/
Copy pathdeploy-website.yml
File metadata and controls
116 lines (100 loc) · 4.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
name: Deploy Website
on:
push:
branches: [main]
paths:
- 'website/**'
# Allow manual re-deploy without touching website/ (e.g. to republish
# /update/latest.json after fixing a workflow bug).
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: pages
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v5
with:
node-version: 22
cache: pnpm
- run: pnpm install --frozen-lockfile
# Pull the auto-update manifest from the latest stable release so that
# any deploy of `website/` (including blog posts, doc tweaks, roadmap edits)
# republishes /update/latest.json. Strategy:
# 1. Try the GitHub release's latest.json. If valid (darwin-aarch64 +
# windows-x86_64 present), use it.
# 2. If the release manifest is missing or partial (matrix race
# condition, mid-release moment, etc.), fall back to the manifest
# currently served by https://gitwand.app/update/latest.json.
# That guarantees the auto-update keeps pointing at the last known
# good version, even when the website is redeployed for an unrelated
# reason (changelog update, doc tweak…).
# 3. If both are missing, deploy the website without /update/latest.json
# — auto-update will be temporarily unavailable but the site itself
# stays publishable (changelog, docs, README are independent of the
# updater).
- name: Pull auto-update manifest from latest release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
mkdir -p website/public/update
out=website/public/update/latest.json
manifest_is_valid() {
local file="$1"
[ -s "$file" ] || return 1
jq -e '.platforms["darwin-aarch64"].url' "$file" >/dev/null 2>&1 || return 1
jq -e '.platforms["windows-x86_64"].url' "$file" >/dev/null 2>&1 || return 1
}
# ── Step 1 — try the latest release ─────────────────────────────────
LATEST_TAG=$(gh release view --json tagName --jq .tagName --repo ${{ github.repository }} 2>/dev/null || true)
if [ -n "$LATEST_TAG" ]; then
echo "Trying latest.json from release $LATEST_TAG"
if gh release download "$LATEST_TAG" \
--pattern "latest.json" \
--output "$out" \
--clobber \
--repo ${{ github.repository }} 2>/dev/null \
&& manifest_is_valid "$out"; then
echo "::notice::Published $(jq -r .version "$out") auto-update manifest from release $LATEST_TAG"
exit 0
fi
echo "::warning::latest.json on release $LATEST_TAG is missing or incomplete — falling back to currently-deployed manifest"
rm -f "$out"
else
echo "::warning::No release found yet"
fi
# ── Step 2 — fall back to the live site's existing manifest ────────
if curl -fsSL -o "$out" https://gitwand.app/update/latest.json \
&& manifest_is_valid "$out"; then
echo "::notice::Reusing existing auto-update manifest from live site ($(jq -r .version "$out"))"
exit 0
fi
# ── Step 3 — deploy without manifest ────────────────────────────────
rm -f "$out"
echo "::warning::No valid latest.json available (neither on the release nor on the live site). Deploying website without /update/latest.json — in-app updater will be temporarily unavailable."
- name: Build website
run: pnpm --filter gitwand-website build
- uses: actions/configure-pages@v5
- uses: actions/upload-pages-artifact@v3
with:
path: website/.vitepress/dist
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
needs: build
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4