Publish to npm and trigger docker builds #457
This file contains hidden or 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
| name: Publish to npm and trigger docker builds | |
| on: | |
| release: | |
| types: [created] | |
| schedule: | |
| - cron: '0 0 * * *' # daily at 00:00 UTC | |
| workflow_dispatch: | |
| # Cancel previous runs when a new one is triggered (same branch/PR) | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| id-token: write # needed for npm trusted publishing (OIDC) | |
| actions: read | |
| jobs: | |
| publish-release: | |
| name: Publish release to npm and trigger docker build latest, ubuntu, alpine and s6-rc | |
| if: github.event_name == 'release' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v7 | |
| with: | |
| ref: main | |
| - name: Setup Node.js 24.x | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: '24.x' | |
| cache: npm | |
| - name: Verify Node.js version | |
| run: node -v | |
| - name: Verify Npm version | |
| run: npm -v | |
| - name: Install matterbridge dependencies | |
| run: npm ci --no-fund --no-audit | |
| - name: Build matterbridge | |
| run: npm run build | |
| - name: Install matterbridge globally | |
| run: npm install --no-fund --no-audit --global . | |
| - name: Test matterbridge cli | |
| run: matterbridge --version | |
| - name: Lint matterbridge | |
| run: npm run lint | |
| - name: Install frontend dependencies | |
| run: npm ci --no-fund --no-audit | |
| working-directory: apps/frontend | |
| - name: Lint frontend | |
| run: npm run lint | |
| working-directory: apps/frontend | |
| - name: Build frontend | |
| run: npm run build | |
| working-directory: apps/frontend | |
| - name: Test frontend | |
| run: npm run test | |
| working-directory: apps/frontend | |
| - name: Publish frontend to npm under tag latest with trusted publishing / OIDC | |
| run: npm publish --tag latest --access public || true | |
| working-directory: apps/frontend | |
| - name: Test matterbridge | |
| run: npm run test -- --testTimeout=30000 | |
| - name: Stamp build metadata into package.json | |
| run: | | |
| VERSION=$(node -p "require('./package.json').version") | |
| npm pkg set build.version="$VERSION" | |
| npm pkg set build.sha="${GITHUB_SHA}" | |
| npm pkg set build.sha7="${GITHUB_SHA::7}" | |
| npm pkg set build.event="${GITHUB_EVENT_NAME}" | |
| npm pkg set build.workflow="${GITHUB_WORKFLOW}" | |
| npm pkg set build.type="branch" | |
| npm pkg set build.name="main" | |
| npm pkg set build.dev="false" | |
| - name: Publish to npm under tag latest with trusted publishing / OIDC | |
| run: | | |
| node scripts/publish-workspaces.mjs --scope @matterbridge --tag latest | |
| - name: Wait for npm registry propagation | |
| run: sleep 60 | |
| - name: Trigger Matterbridge Docker Build Latest | |
| uses: actions/github-script@v9 | |
| with: | |
| github-token: ${{ secrets.PAT_TOKEN }} | |
| script: | | |
| await github.rest.actions.createWorkflowDispatch({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| workflow_id: 'docker-buildx-latest.yml', | |
| ref: 'main' | |
| }) | |
| - name: Trigger Matterbridge Docker Build Dev | |
| uses: actions/github-script@v9 | |
| with: | |
| github-token: ${{ secrets.PAT_TOKEN }} | |
| script: | | |
| await github.rest.actions.createWorkflowDispatch({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| workflow_id: 'docker-buildx-dev.yml', | |
| ref: 'main' | |
| }) | |
| - name: Trigger Matterbridge Docker Build Bundev | |
| uses: actions/github-script@v9 | |
| with: | |
| github-token: ${{ secrets.PAT_TOKEN }} | |
| script: | | |
| await github.rest.actions.createWorkflowDispatch({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| workflow_id: 'docker-buildx-bundev.yml', | |
| ref: 'main' | |
| }) | |
| - name: Trigger Matterbridge Docker Build 24-ubuntu-slim | |
| uses: actions/github-script@v9 | |
| with: | |
| github-token: ${{ secrets.PAT_TOKEN }} | |
| script: | | |
| await github.rest.actions.createWorkflowDispatch({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| workflow_id: 'docker-buildx-24-ubuntu-slim.yml', | |
| ref: 'main' | |
| }) | |
| - name: Trigger Matterbridge Docker Build bun-ubuntu-slim | |
| uses: actions/github-script@v9 | |
| with: | |
| github-token: ${{ secrets.PAT_TOKEN }} | |
| script: | | |
| await github.rest.actions.createWorkflowDispatch({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| workflow_id: 'docker-buildx-bun-ubuntu-slim.yml', | |
| ref: 'main' | |
| }) | |
| - name: Trigger Matterbridge Docker Build Alpine | |
| uses: actions/github-script@v9 | |
| with: | |
| github-token: ${{ secrets.PAT_TOKEN }} | |
| script: | | |
| await github.rest.actions.createWorkflowDispatch({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| workflow_id: 'docker-buildx-alpine.yml', | |
| ref: 'main' | |
| }) | |
| - name: Trigger Matterbridge Docker Build Bun | |
| uses: actions/github-script@v9 | |
| with: | |
| github-token: ${{ secrets.PAT_TOKEN }} | |
| script: | | |
| await github.rest.actions.createWorkflowDispatch({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| workflow_id: 'docker-buildx-bun.yml', | |
| ref: 'main' | |
| }) | |
| - name: Trigger Matterbridge Docker Build s6-rc | |
| uses: actions/github-script@v9 | |
| with: | |
| github-token: ${{ secrets.PAT_TOKEN }} | |
| script: | | |
| await github.rest.actions.createWorkflowDispatch({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| workflow_id: 'docker-buildx-s6-rc.yml', | |
| ref: 'main' | |
| }) | |
| - name: Trigger Matterbridge Docker Build s6-rc-legacy | |
| uses: actions/github-script@v9 | |
| with: | |
| github-token: ${{ secrets.PAT_TOKEN }} | |
| script: | | |
| await github.rest.actions.createWorkflowDispatch({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| workflow_id: 'docker-buildx-s6-rc-legacy.yml', | |
| ref: 'main' | |
| }) | |
| publish-dev: | |
| name: Publish daily dev to npm and trigger docker builds dev and bundev | |
| if: github.event_name != 'release' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout dev | |
| uses: actions/checkout@v7 | |
| with: | |
| ref: dev | |
| - name: Setup Node.js 24.x | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: '24.x' | |
| cache: npm | |
| - name: Verify Node.js version | |
| run: node -v | |
| - name: Verify Npm version | |
| run: npm -v | |
| - name: Install matterbridge dependencies | |
| run: npm ci --no-fund --no-audit | |
| - name: Build matterbridge | |
| run: npm run build | |
| - name: Install matterbridge globally | |
| run: npm install --no-fund --no-audit --global . | |
| - name: Test matterbridge cli | |
| run: matterbridge --version | |
| - name: Lint matterbridge | |
| run: npm run lint | |
| - name: Install frontend dependencies | |
| run: npm ci --no-fund --no-audit | |
| working-directory: apps/frontend | |
| - name: Lint frontend | |
| run: npm run lint | |
| working-directory: apps/frontend | |
| - name: Build frontend | |
| run: npm run build | |
| working-directory: apps/frontend | |
| - name: Test frontend | |
| run: npm run test | |
| working-directory: apps/frontend | |
| - name: Test matterbridge | |
| run: npm run test -- --testTimeout=30000 | |
| - name: Stamp build metadata into package.json | |
| run: | | |
| VERSION=$(node -p "require('./package.json').version") | |
| npm pkg set build.version="$VERSION" | |
| npm pkg set build.sha="${GITHUB_SHA}" | |
| npm pkg set build.sha7="${GITHUB_SHA::7}" | |
| npm pkg set build.event="${GITHUB_EVENT_NAME}" | |
| npm pkg set build.workflow="${GITHUB_WORKFLOW}" | |
| npm pkg set build.type="branch" | |
| npm pkg set build.name="dev" | |
| npm pkg set build.dev="true" | |
| - name: Extract version and set tag | |
| id: meta | |
| run: | | |
| BASE=$(jq -r '.version' package.json) | |
| DATE=$(date -u +'%Y%m%d') | |
| SHA=$(git rev-parse --short=7 HEAD) | |
| DEV_TAG="${BASE}-dev-${DATE}-${SHA}" | |
| echo "DEV_TAG=$DEV_TAG" >> $GITHUB_OUTPUT | |
| echo "ORIG_SHA=$SHA" >> $GITHUB_OUTPUT | |
| echo "ORIG_BASE=$BASE" >> $GITHUB_OUTPUT | |
| - name: Bump to version-dev-date-commit --no-git-tag-version --ignore-scripts tag ${{ steps.meta.outputs.DEV_TAG }} | |
| run: npm version "${{ steps.meta.outputs.DEV_TAG }}" --no-git-tag-version --ignore-scripts | |
| - name: Check if a new dev-publish is needed | |
| id: check_new | |
| run: | | |
| PKG=$(node -p "require('./package.json').name") | |
| PUBLISHED=$(npm view "$PKG" dist-tags.dev 2>/dev/null || echo "") | |
| PUBLISHED_SHA=${PUBLISHED##*-} | |
| CURRENT_SHA="${{ steps.meta.outputs.ORIG_SHA }}" | |
| echo "Published dev tag: $PUBLISHED" | |
| echo "Published SHA: $PUBLISHED_SHA" | |
| echo "Current SHA: $CURRENT_SHA" | |
| if [ "$PUBLISHED_SHA" = "$CURRENT_SHA" ]; then | |
| echo "✅ No new commits since last dev publish - skipping" | |
| echo "should_publish=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "🚀 New commits detected - proceeding with dev publish" | |
| echo "should_publish=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Publish frontend to npm under tag dev with trusted publishing / OIDC | |
| if: steps.check_new.outputs.should_publish == 'true' | |
| working-directory: apps/frontend | |
| run: | | |
| BASE=$(jq -r '.version' package.json) | |
| DATE=$(date -u +'%Y%m%d') | |
| SHA=$(git rev-parse --short=7 HEAD) | |
| DEV_TAG="${BASE}-dev-${DATE}-${SHA}" | |
| echo "Publishing frontend with tag ${DEV_TAG}" | |
| npm version "${DEV_TAG}" --no-git-tag-version --ignore-scripts | |
| npm publish --tag dev --access public || true | |
| npm version "${BASE}" --no-git-tag-version --ignore-scripts | |
| - name: Publish matterbridge to npm under tag dev with trusted publishing / OIDC | |
| if: steps.check_new.outputs.should_publish == 'true' | |
| run: | | |
| npm version "${{ steps.meta.outputs.ORIG_BASE }}" --no-git-tag-version --ignore-scripts | |
| node scripts/publish-workspaces.mjs --scope @matterbridge --tag dev | |
| - name: Wait for npm registry propagation | |
| if: steps.check_new.outputs.should_publish == 'true' | |
| run: sleep 60 | |
| - name: Trigger Matterbridge Docker Build Dev | |
| if: steps.check_new.outputs.should_publish == 'true' | |
| uses: actions/github-script@v9 | |
| with: | |
| github-token: ${{ secrets.PAT_TOKEN }} | |
| script: | | |
| await github.rest.actions.createWorkflowDispatch({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| workflow_id: 'docker-buildx-dev.yml', | |
| ref: 'dev' | |
| }) | |
| - name: Trigger Matterbridge Docker Build Bundev | |
| if: steps.check_new.outputs.should_publish == 'true' | |
| uses: actions/github-script@v9 | |
| with: | |
| github-token: ${{ secrets.PAT_TOKEN }} | |
| script: | | |
| await github.rest.actions.createWorkflowDispatch({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| workflow_id: 'docker-buildx-bundev.yml', | |
| ref: 'dev' | |
| }) |