-
Notifications
You must be signed in to change notification settings - Fork 1
150 lines (143 loc) · 4.91 KB
/
ci.yml
File metadata and controls
150 lines (143 loc) · 4.91 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
name: CI
on:
push:
branches: [main] # Run tests/lint/build on pushes to main
pull_request: # Run tests/lint/build on PRs
types: [opened, reopened, synchronize]
branches-ignore:
- "**/graphite-base/**"
release:
types: [published] # Trigger publish job when a GitHub release is published
workflow_dispatch: # Allow manual runs
permissions:
contents: read
# Required for npm OICD (https://docs.npmjs.com/trusted-publishers)
id-token: write
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v6
with:
node-version: 22
registry-url: "https://registry.npmjs.org/"
- run: pnpm install
- run: pnpm lint
- run: pnpm test
- run: pnpm build
publish-npm:
needs: build-and-test
runs-on: ubuntu-latest
if: github.event_name == 'release'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v6
with:
node-version: 22
registry-url: "https://registry.npmjs.org/"
- uses: pnpm/action-setup@v4
- name: Re-install npm
# TODO: OIDC requires npm >=11.5.1.
# Until Node.js v24 is LTS (with npm 11 as the default), we need to bump.
run: npm install -g npm@11
- run: pnpm install
- run: pnpm build
- name: Publish to npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
# Extract version from package.json
VERSION=$(node -p "require('./package.json').version")
# Check if it's a prerelease version (contains a hyphen, e.g., 3.0.0-alpha.0)
if [[ "$VERSION" == *-* ]]; then
# Extract the prerelease tag (e.g., "alpha" from "3.0.0-alpha.0")
PRERELEASE_TAG=$(echo "$VERSION" | sed 's/.*-\([a-zA-Z]*\).*/\1/')
echo "Publishing prerelease version $VERSION with tag: $PRERELEASE_TAG"
pnpm publish --access public --tag "$PRERELEASE_TAG" --no-git-checks
else
echo "Publishing stable version $VERSION"
pnpm publish --access public --no-git-checks
fi
deploy-docs:
needs: build-and-test
runs-on: ubuntu-latest
if: github.event_name == 'release'
steps:
- uses: actions/checkout@v4
with:
ref: main
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v6
with:
node-version: 22
cache: "pnpm"
- name: Install dependencies (main branch)
run: pnpm install
- name: Build v2 docs from main branch
run: pnpm docs:build
- name: Move v2 docs to combined folder
run: |
mkdir -p combined/v2
mv docs/.vitepress/dist/* combined/v2/
- name: Checkout release tag
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
clean: false
- name: Install dependencies (release tag)
run: pnpm install
- name: Build and move v3 docs if v3 release
run: |
TAG_NAME="${{ github.ref_name }}"
if [[ "$TAG_NAME" == v3* ]]; then
pnpm docs:build
mkdir -p combined/v3
mv docs/.vitepress/dist/* combined/v3/
fi
- name: Copy v2 docs to root for default access
run: cp -r combined/v2/* combined/
- name: Deploy docs to production server
uses: easingthemes/ssh-deploy@main
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
REMOTE_HOST: ${{ secrets.SSH_HOST }}
REMOTE_USER: ${{ secrets.SSH_USER }}
REMOTE_PORT: ${{ secrets.SSH_PORT }}
SOURCE: "combined/."
TARGET: ${{ secrets.TARGET_DIR_DOCS }}
deploy-playground:
needs: build-and-test
runs-on: ubuntu-latest
if: (github.event_name == 'release' || github.event_name == 'workflow_dispatch') && github.ref != 'refs/heads/main'
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v6
with:
node-version: 22
cache: "pnpm"
- name: Install and build parent package
run: |
pnpm install
pnpm build
- name: Install playground dependencies
working-directory: playground
run: pnpm install
- name: Build playground in static mode
working-directory: playground
env:
NUXT_APP_BASE_URL: ${{ secrets.PLAYGROUND_BASE_URL }}
run: pnpm generate
- name: Deploy playground to production server
uses: easingthemes/ssh-deploy@main
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
REMOTE_HOST: ${{ secrets.SSH_HOST }}
REMOTE_USER: ${{ secrets.SSH_USER }}
REMOTE_PORT: ${{ secrets.SSH_PORT }}
SOURCE: "playground/.output/public/."
TARGET: ${{ secrets.TARGET_DIR_PLAYGROUND }}