diff --git a/.github/workflows/header-gen.yml b/.github/workflows/header-gen.yml index 712892f..c161de5 100644 --- a/.github/workflows/header-gen.yml +++ b/.github/workflows/header-gen.yml @@ -1,15 +1,26 @@ name: Header Generator Tests on: + release: + types: [created] push: branches: '*' + paths: + - "header-gen/**" + - "**/header-gen.yml" pull_request: branches: '*' + paths: + - "header-gen/**" + - "**/header-gen.yml" jobs: build-and-test: name: Build & Test TS lib runs-on: ubuntu-latest + permissions: + contents: read + packages: write steps: - uses: actions/checkout@v4 @@ -18,11 +29,20 @@ jobs: uses: actions/setup-node@v4 with: node-version: '20' + registry-url: "https://npm.pkg.github.com" + cache: npm + cache-dependency-path: header-gen/package-lock.json - name: Install Dependencies run: npm ci working-directory: ./header-gen + - name: Update version + if: github.event_name != 'pull_request' + uses: microbit-foundation/npm-package-versioner-action@v1 + with: + working-directory: ./header-gen + - name: Build run: npm run build working-directory: ./header-gen @@ -30,3 +50,9 @@ jobs: - name: Run Jest Tests run: npm test working-directory: ./header-gen + + - name: Publish + run: npm publish + if: github.event_name == 'release' && github.event.action == 'created' + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/header-gen/.npmrc b/header-gen/.npmrc new file mode 100644 index 0000000..d617cf0 --- /dev/null +++ b/header-gen/.npmrc @@ -0,0 +1 @@ +@microbit-foundation:registry=https://npm.pkg.github.com/microbit-foundation diff --git a/header-gen/package.json b/header-gen/package.json index 3e842e1..30cc7a8 100644 --- a/header-gen/package.json +++ b/header-gen/package.json @@ -4,11 +4,11 @@ "description": "A simple TS script to generate a header blob for the ML runner", "author": "Micro:bit Educational Foundation ", "license": "MIT", - "module": "./dist/main.js", - "typings": "./dist/main.d.ts", + "module": "./built/main.js", + "typings": "./built/main.d.ts", "files": [ - "./dist/*.js", - "./dist/*.d.ts" + "./built/*.js", + "./built/*.d.ts" ], "scripts": { "start": "ts-node --project tsconfig.cli.json src/cli.ts",