-
Notifications
You must be signed in to change notification settings - Fork 0
97 lines (83 loc) · 2.8 KB
/
docs.yml
File metadata and controls
97 lines (83 loc) · 2.8 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
name: Docs
on:
push:
branches: [main]
pull_request:
branches: [main]
release:
types: [published]
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: pages
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
cache-dependency-path: docs/package-lock.json
- name: Install docs dependencies
working-directory: docs
run: npm ci
- name: Resolve latest release version
id: resolve_version
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# For deployment builds:
# - On release events, use the event's tag name (source of truth for that deployment).
# - On main pushes, resolve the latest release tag from GitHub.
# For pull requests and workflow_dispatch, fall back to "dev" so preview builds still succeed.
if [[ "${{ github.event_name }}" == "release" ]]; then
VERSION="${{ github.event.release.tag_name }}"
elif [[ "${{ github.event_name }}" == "push" ]]; then
VERSION=$(gh release view --repo "${{ github.repository }}" --json tagName -q '.tagName' 2>/dev/null || true)
else
VERSION="dev"
fi
if [[ "${{ github.event_name }}" == "push" || "${{ github.event_name }}" == "release" ]]; then
if [[ -z "$VERSION" ]]; then
echo "ERROR: Could not resolve docs version." >&2
exit 1
fi
if ! [[ "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "ERROR: Resolved version '$VERSION' does not match expected semver format (vX.Y.Z)." >&2
exit 1
fi
fi
echo "Resolved docs version: $VERSION"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Prepare logo asset
run: cp assets/clockworks-display-resized.png docs/public/logo.png
- name: Build VitePress site
working-directory: docs
env:
DOCS_VERSION: ${{ steps.resolve_version.outputs.version }}
run: npm run docs:build
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: docs/.vitepress/dist
deploy:
needs: build
if: github.ref == 'refs/heads/main' || github.event_name == 'release'
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4