Skip to content

Commit 521c940

Browse files
microbit-robertmicrobit-matt-hillsdonmicrobit-carlos
authored
Add GitHub action for header-gen build & publish (#6)
* Fix paths in package.json * Add GitHub action for build workflow This will publish the ml-header-generator package. * Add cache dependency path The setup-node action expects this to be at the root. * Re-run action if build.yml is modified * Use non-action package-versioner This may fail if this repo doesn't have permissions to use this package * Try using updated GHA to change version * Actually set working-directory * Remove old way * Working dir change has now been released as 1.1.0 * Review feedback and merge into header-gen.yml * Add permissions * Don't update version on PR * Only publish on GH release Co-authored-by: Carlos Pereira Atencio <[email protected]> --------- Co-authored-by: Matt Hillsdon <[email protected]> Co-authored-by: Carlos Pereira Atencio <[email protected]>
1 parent ffd7174 commit 521c940

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed

.github/workflows/header-gen.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
11
name: Header Generator Tests
22

33
on:
4+
release:
5+
types: [created]
46
push:
57
branches: '*'
8+
paths:
9+
- "header-gen/**"
10+
- "**/header-gen.yml"
611
pull_request:
712
branches: '*'
13+
paths:
14+
- "header-gen/**"
15+
- "**/header-gen.yml"
816

917
jobs:
1018
build-and-test:
1119
name: Build & Test TS lib
1220
runs-on: ubuntu-latest
21+
permissions:
22+
contents: read
23+
packages: write
1324

1425
steps:
1526
- uses: actions/checkout@v4
@@ -18,15 +29,30 @@ jobs:
1829
uses: actions/setup-node@v4
1930
with:
2031
node-version: '20'
32+
registry-url: "https://npm.pkg.github.com"
33+
cache: npm
34+
cache-dependency-path: header-gen/package-lock.json
2135

2236
- name: Install Dependencies
2337
run: npm ci
2438
working-directory: ./header-gen
2539

40+
- name: Update version
41+
if: github.event_name != 'pull_request'
42+
uses: microbit-foundation/npm-package-versioner-action@v1
43+
with:
44+
working-directory: ./header-gen
45+
2646
- name: Build
2747
run: npm run build
2848
working-directory: ./header-gen
2949

3050
- name: Run Jest Tests
3151
run: npm test
3252
working-directory: ./header-gen
53+
54+
- name: Publish
55+
run: npm publish
56+
if: github.event_name == 'release' && github.event.action == 'created'
57+
env:
58+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

header-gen/.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@microbit-foundation:registry=https://npm.pkg.github.com/microbit-foundation

header-gen/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
"description": "A simple TS script to generate a header blob for the ML runner",
55
"author": "Micro:bit Educational Foundation <[email protected]>",
66
"license": "MIT",
7-
"module": "./dist/main.js",
8-
"typings": "./dist/main.d.ts",
7+
"module": "./built/main.js",
8+
"typings": "./built/main.d.ts",
99
"files": [
10-
"./dist/*.js",
11-
"./dist/*.d.ts"
10+
"./built/*.js",
11+
"./built/*.d.ts"
1212
],
1313
"scripts": {
1414
"start": "ts-node --project tsconfig.cli.json src/cli.ts",

0 commit comments

Comments
 (0)