-
Notifications
You must be signed in to change notification settings - Fork 2
80 lines (64 loc) · 2.85 KB
/
publish.yml
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
name: Publish Workflow
on:
push:
branches:
- main
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Check if version has been updated
id: version_check
uses: EndBug/version-check@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js
if: steps.version_check.outputs.changed == 'true'
uses: actions/setup-node@v4
with:
node-version: '18.16.1'
- name: Install pnpm
if: steps.version_check.outputs.changed == 'true'
run: npm install -g pnpm
- name: Install Dependencies
if: steps.version_check.outputs.changed == 'true'
run: pnpm install --frozen-lockfile
- name: Build and Move Files
if: steps.version_check.outputs.changed == 'true'
run: |
VERSION=v${{steps.version_check.outputs.version}} pnpm build
mkdir -p "$GITHUB_WORKSPACE/v${{ steps.version_check.outputs.version }}"
mv schemas/* "$GITHUB_WORKSPACE/v${{ steps.version_check.outputs.version }}"
mkdir -p "$GITHUB_WORKSPACE/v${{ steps.version_check.outputs.version }}/types"
mv types/* "$GITHUB_WORKSPACE/v${{ steps.version_check.outputs.version }}/types"
mkdir -p "$GITHUB_WORKSPACE/v${{ steps.version_check.outputs.version }}/examples"
# Copy JSON files, preserving directory structure
rsync -a --prune-empty-dirs --include '*/' --include '*.json' --exclude '*' examples/ "$GITHUB_WORKSPACE/v${{ steps.version_check.outputs.version }}/examples/"
# Remove JSON files from source destination
find examples -type f -name "*.json" -delete
# Copy across new version to maintain a stable reference URL at /latest
mkdir -p "$GITHUB_WORKSPACE/latest"
cp -r "$GITHUB_WORKSPACE/v${{ steps.version_check.outputs.version }} "$GITHUB_WORKSPACE/latest"
- name: Checkout Dist Branch
if: steps.version_check.outputs.changed == 'true'
run: |
git fetch origin dist
git checkout -b dist origin/dist
- name: Commit and Push Changes
if: steps.version_check.outputs.changed == 'true'
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git add .
git commit -m "Add build files for v${{ steps.version_check.outputs.version }}"
git push origin dist
- name: Create Release and Tag
if: steps.version_check.outputs.changed == 'true'
uses: actions/create-release@v1
with:
tag_name: v${{ steps.version_check.outputs.version }}
release_name: v${{ steps.version_check.outputs.version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}