-
-
Notifications
You must be signed in to change notification settings - Fork 39
165 lines (137 loc) · 4.58 KB
/
Copy pathbuild.yaml
File metadata and controls
165 lines (137 loc) · 4.58 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
name: CI Build
on:
# Dry run for main pushes:
workflow_dispatch:
push:
branches: ["main"]
paths-ignore: ["**/*.md"]
# Publish to npm:
tags:
- "v*.*.*"
# Dry run for PRs:
pull_request:
branches: ["main"]
paths-ignore: ["**/*.md"]
env:
NODE_VERSION: "22.17.1"
permissions:
contents: write
jobs:
build:
name: Build
runs-on: "ubuntu-24.04"
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up NodeJS
uses: actions/setup-node@v7
with:
node-version: ${{ env.NODE_VERSION }}
- name: Cache node modules
id: cache
uses: actions/cache@v5
with:
path: node_modules # npm cache files are stored in `~/.npm` on Linux/macOS
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package.json', '**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci
- name: Build
run: npm run build
# this will identify modifications to files under source control during the workflow run;
# untracked files will be included as well!
- name: Verify Changed Files
id: verify-changed-files
run: |
set -o pipefail
changed_files=$(echo -n "$(git diff --name-only HEAD && git ls-files --others --exclude-standard)"|tr '\n' ' ')
echo "changed_files=$changed_files" >> $GITHUB_OUTPUT
- name: Fail on Changed Files
if: steps.verify-changed-files.outputs.changed_files != ''
env:
CHANGED_FILES: ${{ steps.verify-changed-files.outputs.changed_files }}
run: |
echo "::error::Files have changed: $CHANGED_FILES"
exit 1
- name: Upload build artifacts
uses: actions/upload-artifact@v7
with:
name: dist-without-license
path: |
dist
!dist/*.txt
- name: Upload test coverage report
uses: actions/upload-artifact@v7
with:
name: test-coverage
path: |
test/coverage/lcov-report
- name: Create GitHub Release
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "${{ github.ref_name }}" \
dist/openhab.js \
dist/openhab.d.ts \
dist/@openhab-globals.js \
--title "${{ github.ref_name }}" \
--generate-notes
jsdoc:
name: Publish JSDoc
runs-on: "ubuntu-24.04"
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up NodeJS
uses: actions/setup-node@v7
with:
node-version: ${{ env.NODE_VERSION }}
- name: Cache node modules
id: cache
uses: actions/cache@v5
with:
path: node_modules # npm cache files are stored in `~/.npm` on Linux/macOS
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package.json', '**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci
- name: Build JSDoc
run: npm run docs
# pinning to SHA to mitigate possible supply chain attack
- name: Publish to GitHub Pages
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
uses: peaceiris/actions-gh-pages@84c30a85c19949d7eee79c4ff27748b70285e453 # v4.1.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs
publish:
name: Publish to npm
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
runs-on: "ubuntu-24.04"
needs: build
permissions:
id-token: write # Required for OIDC
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: "https://registry.npmjs.org"
# Ensure npm 11.5.1 or later is installed
- name: Update npm
run: npm install -g npm@^11.5.1
- name: Install Dependencies
run: npm ci
- name: Publish npm package
run: npm publish --access=public