-
Notifications
You must be signed in to change notification settings - Fork 46
170 lines (151 loc) · 4.73 KB
/
build.yml
File metadata and controls
170 lines (151 loc) · 4.73 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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
name: Build
on:
push:
branches: ["main"]
tags: ["*"]
pull_request:
branches: ["main"]
permissions:
id-token: write
contents: write
pages: write
env:
EM_VERSION: 4.0.13
EM_CACHE_FOLDER: "emsdk-cache"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
submodules: true
- name: Setup cache
id: cache-system-libraries
uses: actions/cache@v5
with:
path: ${{env.EM_CACHE_FOLDER}}
key: ${{env.EM_VERSION}}-${{runner.os}}
- name: Setup Emscripten
uses: mymindstorm/setup-emsdk@v16
with:
version: ${{env.EM_VERSION}}
actions-cache-folder: ${{env.EM_CACHE_FOLDER}}
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: "24"
registry-url: "https://registry.npmjs.org"
- name: Build
run: make
- name: Run tests
run: make test
- name: Check docs
run: make doc
- name: Archive artifacts
uses: actions/upload-artifact@v7
with:
name: build
path: |
dist/harfbuzz.js
dist/harfbuzz.wasm
dist/harfbuzz-subset.wasm
dist/index.mjs
docs
if-no-files-found: error
release:
name: Create and populate release
needs: build
runs-on: ubuntu-latest
if: contains(github.ref, 'refs/tags/')
env:
GH_TOKEN: ${{ github.token }}
outputs:
is_prerelease: ${{ steps.prerelease.outputs.is_prerelease }}
steps:
- uses: actions/checkout@v6
with:
submodules: true
- name: Download artifacts
uses: actions/download-artifact@v8
with:
name: build
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: "24.x"
- name: Detect prerelease
id: prerelease
run: |
if [[ "${{ github.ref_name }}" == *-* ]]; then
echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
echo "npm_tag=next" >> "$GITHUB_OUTPUT"
else
echo "is_prerelease=false" >> "$GITHUB_OUTPUT"
echo "npm_tag=latest" >> "$GITHUB_OUTPUT"
fi
- name: Publish on NPM
run: npm publish --provenance --access public --tag ${{ steps.prerelease.outputs.npm_tag }}
- name: Extract release notes from annotated tag message
id: release_notes
run: |
# GH checkout action doesn't preserve tag annotations, we must fetch them
# https://github.com/actions/checkout/issues/290
git fetch --no-recurse-submodules --tags --force
# Dump tag message body to temporary .md file
echo "$(git tag -l --format='%(contents:body)' ${{ github.ref_name }})" > "${{ runner.temp }}/release_body.md"
- name: Create GitHub release
id: create_release
run: |
if gh release view ${{ github.ref_name }}; then
exit 0
fi
notes="--notes-file ${{ runner.temp }}/release_body.md"
# If the notes file is empty, use --generate-notes instead
if ! grep -q "[^[:space:]]" "${{ runner.temp }}/release_body.md"; then
notes="--generate-notes"
fi
prerelease=""
if [ "${{ steps.prerelease.outputs.is_prerelease }}" = true ]; then
prerelease="--prerelease"
fi
gh release create ${{ github.ref_name }} \
--title ${{ github.ref_name }} \
$notes \
$prerelease
- name: Populate release
run: |
gh release upload ${{ github.ref_name }} dist/harfbuzz.js dist/harfbuzz.wasm dist/harfbuzz-subset.wasm --clobber
docs:
name: Deploy documentation
needs: release
runs-on: ubuntu-latest
if: needs.release.outputs.is_prerelease == 'false'
concurrency:
group: "pages"
cancel-in-progress: true
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Download build artifacts
uses: actions/download-artifact@v8
with:
name: build
- name: Build demo
run: |
mkdir -p docs/demo
cp demo/index.html docs/demo/
cp dist/* docs/demo/
cp test/fonts/noto/NotoSans-Regular.ttf docs/demo/
- name: Setup Pages
uses: actions/configure-pages@v6
- name: Upload artifact
uses: actions/upload-pages-artifact@v5
with:
path: docs
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5