diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 73d0f64..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: publish - -on: - release: - types: [published] - -permissions: - contents: read - id-token: write - -jobs: - publish: - runs-on: ubuntu-latest - environment: npm-publish - steps: - - name: Identify package from release tag - id: pkg - run: | - TAG="${{ github.event.release.tag_name }}" - case "$TAG" in - "@userlike/messenger-internal@"*) - echo "tgz=packages/messenger-internal/package.tgz" >> "$GITHUB_OUTPUT" - echo "name=@userlike/messenger-internal" >> "$GITHUB_OUTPUT" - ;; - "@userlike/messenger@"*) - echo "tgz=packages/messenger/package.tgz" >> "$GITHUB_OUTPUT" - echo "name=@userlike/messenger" >> "$GITHUB_OUTPUT" - ;; - *) - echo "::error::Unknown release tag '$TAG'" - exit 1 - ;; - esac - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 - with: - node-version: "24" - cache: yarn - registry-url: https://registry.npmjs.org - - run: corepack enable - - run: npm install -g npm@^11.15.0 - - run: yarn install --immutable - - name: Build all packages (topological) - run: yarn workspaces foreach -At --no-private run build - - name: Pack all packages (substitutes workspace:* to concrete version) - run: yarn workspaces foreach -At --no-private pack - - name: Stage-publish ${{ steps.pkg.outputs.name }} - run: npm stage publish ${{ steps.pkg.outputs.tgz }} - - name: Summary - run: | - echo "Staged ${{ steps.pkg.outputs.name }} on npm. Approve via npmjs.com or 'npm stage promote'." >> "$GITHUB_STEP_SUMMARY" - echo "" >> "$GITHUB_STEP_SUMMARY" - echo "If both packages are released together: promote messenger-internal *before* messenger, since messenger's package.json pins a specific internal version." >> "$GITHUB_STEP_SUMMARY" diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 603bf92..181d068 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -7,12 +7,60 @@ on: permissions: contents: write pull-requests: write + id-token: write jobs: release-please: runs-on: ubuntu-latest + environment: npm-publish steps: - uses: googleapis/release-please-action@45996ed1f6d02564a971a2fa1b5860e934307cf7 # v5.0.0 + id: release with: config-file: release-please-config.json manifest-file: .release-please-manifest.json + + # Publish steps run only when release-please created releases. + # This avoids the "GITHUB_TOKEN cannot trigger workflows" gotcha that + # made the standalone publish.yml fail to fire after Release PR merges. + - if: ${{ steps.release.outputs.releases_created == 'true' }} + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + + - if: ${{ steps.release.outputs.releases_created == 'true' }} + uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 + with: + node-version: "24" + cache: yarn + registry-url: https://registry.npmjs.org + + - if: ${{ steps.release.outputs.releases_created == 'true' }} + run: corepack enable + + - if: ${{ steps.release.outputs.releases_created == 'true' }} + run: npm install -g npm@^11.15.0 + + - if: ${{ steps.release.outputs.releases_created == 'true' }} + run: yarn install --immutable + + - if: ${{ steps.release.outputs.releases_created == 'true' }} + name: Build all packages (topological) + run: yarn workspaces foreach -At --no-private run build + + - if: ${{ steps.release.outputs.releases_created == 'true' }} + name: Pack all packages (substitutes workspace:* to concrete version) + run: yarn workspaces foreach -At --no-private pack + + - if: ${{ steps.release.outputs['packages/messenger-internal--release_created'] == 'true' }} + name: Stage-publish @userlike/messenger-internal (must go first - messenger depends on it) + run: npm stage publish packages/messenger-internal/package.tgz + + - if: ${{ steps.release.outputs['packages/messenger--release_created'] == 'true' }} + name: Stage-publish @userlike/messenger + run: npm stage publish packages/messenger/package.tgz + + - if: ${{ steps.release.outputs.releases_created == 'true' }} + name: Summary + run: | + echo "Packages staged on npm. Approve via npmjs.com or 'npm stage promote'." >> "$GITHUB_STEP_SUMMARY" + echo "" >> "$GITHUB_STEP_SUMMARY" + echo "If both packages are released together: promote messenger-internal *before* messenger, since messenger's package.json pins a specific internal version." >> "$GITHUB_STEP_SUMMARY"