Skip to content

[CHIP BUILD] c6916e0453a24f518c0330e5304931e708be5ab4 #6151

[CHIP BUILD] c6916e0453a24f518c0330e5304931e708be5ab4

[CHIP BUILD] c6916e0453a24f518c0330e5304931e708be5ab4 #6151

Workflow file for this run

# This workflow reacts on a PR that is labeled with "automated-npm-release" will automatically merge it and
# create a new release on npm.
name: Automatic Labeled NPM Release
permissions:
contents: write
pull-requests: write
id-token: write # Required for OIDC
on:
pull_request:
types: [labeled]
# Cancel previous PR/branch runs when a new commit is pushed
concurrency:
group: ${{ github.ref }}-auto-npm-release
cancel-in-progress: true
jobs:
check-and-lint:
if: github.repository == 'matter-js/matter.js' && contains(github.event.pull_request.labels.*.name, 'automated-npm-release')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Prepare testing environment
uses: ./.github/actions/prepare-env
- run: npm run format-verify
- run: npm run lint
build-non-linux:
if: github.repository == 'matter-js/matter.js' && contains(github.event.pull_request.labels.*.name, 'automated-npm-release')
needs: [ check-and-lint ]
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [ 20.x, 22.x, 24.x ]
os: [ macos-latest, windows-latest ]
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
# needed as long as we test Node.js 16 and npm <10.2.2 is used for Node.js 18/20
with:
python-version: '3.11'
- name: Build on ${{ matrix.os }}
uses: ./.github/actions/prepare-env
with:
node-version: ${{ matrix.node-version }}
os: ${{ matrix.os }}
test:
if: github.repository == 'matter-js/matter.js' && contains(github.event.pull_request.labels.*.name, 'automated-npm-release')
needs: [ check-and-lint ]
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 20.x, 22.x, 24.x ]
steps:
- uses: actions/checkout@v6
- name: Prepare testing environment
uses: ./.github/actions/prepare-env
with:
node-version: ${{ matrix.node-version }}
- name: Prepare Webbrowser testing environment
uses: ./.github/actions/prepare-webtests
- name: Execute tests
run: npm run test
auto-merge:
if: |
always() &&
github.event_name == 'pull_request' &&
github.repository == 'matter-js/matter.js' &&
contains(github.event.pull_request.labels.*.name, 'automated-npm-release')
needs: [ test, build-non-linux, check-and-lint ]
runs-on: ubuntu-latest
steps:
- id: automerge
name: automerge
uses: "pascalgn/automerge-action@v0.16.4"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
MERGE_LABELS: "automated-npm-release"
MERGE_FILTER_AUTHOR: "Automator77"
MERGE_FORKS: "false"
MERGE_DELETE_BRANCH: "false"
UPDATE_LABELS: "automated-npm-release"
MERGE_METHOD: "squash"
MERGE_RETRIES: "50"
MERGE_RETRY_SLEEP: "60000"
- name: Checkout repository
if: steps.automerge.outputs.mergeResult == 'merged'
uses: actions/checkout@v6
- name: Use Node.js 24.x
if: steps.automerge.outputs.mergeResult == 'merged'
uses: actions/setup-node@v6
with:
node-version: 24.x
- name: Install dependencies and build
if: steps.automerge.outputs.mergeResult == 'merged'
run: npm ci
- name: Determine version
if: steps.automerge.outputs.mergeResult == 'merged'
id: version
uses: actions/github-script@v9
with:
result-encoding: string
script: |
const fs = require('fs');
return fs.readFileSync(`${process.env.GITHUB_WORKSPACE}/version.txt`, "utf8");
- name: Apply new version to package files
if: steps.automerge.outputs.mergeResult == 'merged'
run: npm run version -- --apply
- name: Publish npm
if: steps.automerge.outputs.mergeResult == 'merged'
env:
PRERELEASE: ${{ contains(steps.version.outputs.result, '-') }}
run: |
npm install -g npm@latest
if [[ "$PRERELEASE" == "true" ]]; then
npm publish --workspaces --tag dev
else
npm publish --workspaces
fi
- name: Create Github Release
if: steps.automerge.outputs.mergeResult == 'merged'
uses: ncipollo/release-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag: v${{ steps.version.outputs.result }}
name: Release v${{ steps.version.outputs.result }}
draft: false
prerelease: ${{ contains(steps.version.outputs.result, '-') }}
body: ${{ contains(steps.version.outputs.result, '-') && 'Nightly release' || format('Official release, check [CHANGELOG.md]({0}) for details', 'https://github.com/matter-js/matter.js/blob/main/CHANGELOG.md') }}