Enhance subscription time calculation #1688
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow reacts on a PR that is labeled with "automated pr", will automatically merge it and | |
# create a new release on npm. | |
name: Automatic Labeled Release | |
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 == 'project-chip/matter.js' && contains(github.event.pull_request.labels.*.name, 'automated pr') | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Prepare testing environment | |
uses: ./.github/actions/prepare-env | |
- run: npm run format-verify | |
- run: npm run lint | |
build-non-linux: | |
if: github.repository == 'project-chip/matter.js' && contains(github.event.pull_request.labels.*.name, 'automated pr') | |
needs: [ check-and-lint ] | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
node-version: [ 18.x, 20.x, 22.x ] | |
os: [ macos-latest, windows-2019 ] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
# 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 == 'project-chip/matter.js' && contains(github.event.pull_request.labels.*.name, 'automated pr') | |
needs: [ check-and-lint ] | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [ 18.x, 20.x, 22.x ] | |
steps: | |
- uses: actions/checkout@v4 | |
- 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 == 'project-chip/matter.js' && | |
contains(github.event.pull_request.labels.*.name, 'automated pr') | |
needs: [ test, build-non-linux, check-and-lint ] | |
runs-on: ubuntu-latest | |
steps: | |
- id: automerge | |
name: automerge | |
uses: "pascalgn/automerge-action@v0.16.3" | |
env: | |
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | |
MERGE_LABELS: "automated pr" | |
MERGE_FILTER_AUTHOR: "Automator77" | |
MERGE_FORKS: "false" | |
MERGE_DELETE_BRANCH: "false" | |
UPDATE_LABELS: "automated pr" | |
MERGE_METHOD: "squash" | |
MERGE_RETRIES: "50" | |
MERGE_RETRY_SLEEP: "60000" | |
- name: Checkout repository | |
if: steps.automerge.outputs.mergeResult == 'merged' | |
uses: actions/checkout@v4 | |
- name: Use Node.js 20.x | |
if: steps.automerge.outputs.mergeResult == 'merged' | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.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@v7 | |
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 config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} | |
npm whoami | |
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' || 'Official release, check CHANGELOG.md for details' }}" |