diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cc31d1a..0bd91be 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,29 +5,52 @@ on: push: branches: - "**" +env: + # renovate: datasource=npm depName=npm + NPM_VERSION: "11" + jobs: build: runs-on: ubuntu-latest permissions: contents: read - packages: write steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7 with: node-version: "24.x" - registry-url: "https://registry.npmjs.org" cache: npm - - run: npm install -g npm@11 --registry=https://registry.npmjs.org + - run: npm install -g npm@${{ env.NPM_VERSION }} --registry=https://registry.npmjs.org - run: npm ci - env: - NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: npm run format:check - uses: microbit-foundation/npm-package-versioner-action@v3 with: working-directory: packages/microbit-connection - run: npm run ci - - run: npm publish -w @microbit/microbit-connection --allow-directory=all - if: github.event_name == 'release' && github.event.action == 'created' - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + - run: npm pack -w @microbit/microbit-connection + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + if: github.event_name == 'release' + with: + name: npm-tarball + path: "*.tgz" + if-no-files-found: error + retention-days: 1 + + publish: + needs: build + if: github.event_name == 'release' + runs-on: ubuntu-latest + environment: npm-publish + permissions: + contents: read + id-token: write + steps: + - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: npm-tarball + - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7 + with: + node-version: "24.x" + registry-url: "https://registry.npmjs.org" + - run: npm install -g npm@${{ env.NPM_VERSION }} --registry=https://registry.npmjs.org + - run: npm stage publish --allow-file=all ./*.tgz