Skip to content

Commit d001f38

Browse files
lesbaaLes Moffat
andauthored
Hotfix/add GitHub action for release (#92)
* hotfix: create npm publish github action * remove lint-staged as it is merely an impedement * appease linter * hotfix: add typecheck to pre-commit * Hotfix: run npm i and commit package-lock.json * Hotifx: use internal npm scripts to init publish * Hotfix: add lint and typecheck action and publish-dry-run action against PRs * hotfix: use correct build command in publish dry-run * Hotfix: Ensure build command is run beforehand * Hotfix: use correct naming for workflow job * Hotfix: use new version of Node.js in GH Actions * Hotfix: remove dry run github action --------- Co-authored-by: Les Moffat <[email protected]>
1 parent 7d5f8ec commit d001f38

File tree

5 files changed

+100
-566
lines changed

5 files changed

+100
-566
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Node.js Package
2+
3+
on:
4+
pull_request:
5+
types: [opened]
6+
7+
jobs:
8+
build-and-lint:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout repo
12+
uses: actions/checkout@v4
13+
with:
14+
ref: ${{ github.event.release.target_commitish }}
15+
16+
- uses: actions/setup-node@v4
17+
with:
18+
node-version: 20
19+
registry-url: https://registry.npmjs.org/
20+
21+
- name: Clear NPM cache
22+
run: npm cache clean --force
23+
24+
- name: Install dependencies and build
25+
run: npm ci
26+
27+
- name: Build
28+
run: npm run build
29+
30+
- name: Lint
31+
run: npm run lint

.github/workflows/npm-publish.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2+
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
3+
4+
name: Node.js Package
5+
6+
on:
7+
release:
8+
types: [created]
9+
10+
jobs:
11+
build-and-publish:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout repo
15+
uses: actions/checkout@v4
16+
with:
17+
ref: ${{ github.event.release.target_commitish }}
18+
19+
- uses: actions/setup-node@v4
20+
with:
21+
node-version: 20
22+
registry-url: https://registry.npmjs.org/
23+
24+
- name: Clear NPM cache
25+
run: npm cache clean --force
26+
27+
- name: Install dependencies and build
28+
run: npm ci
29+
30+
- name: Build Release
31+
run: npm run build
32+
id: makeRelease
33+
34+
- name: Fail job if makeRelease failed
35+
if: steps.makeRelease.outcome == 'failure'
36+
run: exit 1
37+
38+
id: check-build-status
39+
- name: Publish NPM package (regular)
40+
if: "!github.event.release.prerelease"
41+
run: |
42+
npm run pub
43+
env:
44+
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
45+
46+
- name: Publish NPM package (pre-release)
47+
if: "github.event.release.prerelease"
48+
run: |
49+
npm run pub-next
50+
env:
51+
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
52+
53+
- name: Send Dispatch Event to CDN Repo
54+
run: |
55+
curl -X POST \
56+
-H "Authorization: token ${{ secrets.CDN_MAPTILER_TOKEN }}" \
57+
-H "Accept: application/vnd.github.v3+json" \
58+
https://api.github.com/repos/maptiler/cdn.maptiler.com/dispatches \
59+
-d '{ \
60+
"event_type": "repo_release", \
61+
"client_payload": { \
62+
"repo": "${{ github.repository }}", \
63+
"tag": "${{ github.event.release.tag_name }}", \
64+
"build_dir": "build" \
65+
}
66+
}'

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
npm exec -- lint-staged
1+
npm run lint

0 commit comments

Comments
 (0)