From 339dae010df4148b4a192dabf4119140bc4b11b3 Mon Sep 17 00:00:00 2001 From: Minggang Wang Date: Tue, 31 Mar 2026 17:45:36 +0800 Subject: [PATCH 1/3] Init commit --- .github/workflows/npm-publish.yml | 66 ++++++++++++++++++++++ .github/workflows/prebuild-linux-arm64.yml | 4 +- .github/workflows/prebuild-linux-x64.yml | 4 +- 3 files changed, 68 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/npm-publish.yml diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml new file mode 100644 index 00000000..7220e85a --- /dev/null +++ b/.github/workflows/npm-publish.yml @@ -0,0 +1,66 @@ +name: NPM Publish + +on: + push: + tags: + - '*' + +# Ensure only one publish runs at a time +concurrency: + group: npm-publish + cancel-in-progress: false + +permissions: + contents: read + +jobs: + prebuild-x64: + uses: ./.github/workflows/prebuild-linux-x64.yml + + prebuild-arm64: + uses: ./.github/workflows/prebuild-linux-arm64.yml + + publish: + needs: [prebuild-x64, prebuild-arm64] + # Only publish from the official repository, not forks + if: github.repository == 'RobotWebTools/rclnodejs' + runs-on: ubuntu-latest + environment: npm-publish + permissions: + contents: read + id-token: write + steps: + - uses: actions/checkout@v5 + + - name: Setup Node.js + uses: actions/setup-node@v6 + with: + node-version: 24.x + registry-url: 'https://registry.npmjs.org' + + - name: Download x64 prebuilds + uses: actions/download-artifact@v4 + with: + pattern: prebuilt-linux-x64-* + path: prebuilds/linux-x64 + merge-multiple: true + + - name: Download arm64 prebuilds + uses: actions/download-artifact@v4 + with: + pattern: prebuilt-linux-arm64-* + path: prebuilds/linux-arm64 + merge-multiple: true + + - name: List prebuilds + run: | + echo "=== x64 prebuilds ===" + ls -la prebuilds/linux-x64/ + echo "=== arm64 prebuilds ===" + ls -la prebuilds/linux-arm64/ + + - name: Pack + run: ./scripts/npm-pack.sh + + - name: Publish + run: npm publish --provenance --access public ./dist/rclnodejs-*.tgz diff --git a/.github/workflows/prebuild-linux-arm64.yml b/.github/workflows/prebuild-linux-arm64.yml index 1b35bd22..b840a512 100644 --- a/.github/workflows/prebuild-linux-arm64.yml +++ b/.github/workflows/prebuild-linux-arm64.yml @@ -2,9 +2,7 @@ name: Prebuild Linux ARM64 on: workflow_dispatch: - push: - tags: - - '*' + workflow_call: jobs: prebuild: diff --git a/.github/workflows/prebuild-linux-x64.yml b/.github/workflows/prebuild-linux-x64.yml index 2603acf1..c24235af 100644 --- a/.github/workflows/prebuild-linux-x64.yml +++ b/.github/workflows/prebuild-linux-x64.yml @@ -2,9 +2,7 @@ name: Prebuild Linux x64 on: workflow_dispatch: - push: - tags: - - '*' + workflow_call: jobs: prebuild: From e83b37c1396fea05ac641af7b9a99fd7d4048134 Mon Sep 17 00:00:00 2001 From: Minggang Wang Date: Wed, 1 Apr 2026 10:38:43 +0800 Subject: [PATCH 2/3] Address comments --- .github/workflows/npm-publish.yml | 21 +++++++++++++++++---- .github/workflows/prebuild-linux-arm64.yml | 4 ++-- .github/workflows/prebuild-linux-x64.yml | 4 ++-- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 7220e85a..f4033105 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -4,6 +4,13 @@ on: push: tags: - '*' + workflow_dispatch: + inputs: + dry_run: + description: 'Perform a dry run (skip actual publish)' + required: true + type: boolean + default: true # Ensure only one publish runs at a time concurrency: @@ -30,7 +37,7 @@ jobs: contents: read id-token: write steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - name: Setup Node.js uses: actions/setup-node@v6 @@ -39,14 +46,14 @@ jobs: registry-url: 'https://registry.npmjs.org' - name: Download x64 prebuilds - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v7 with: pattern: prebuilt-linux-x64-* path: prebuilds/linux-x64 merge-multiple: true - name: Download arm64 prebuilds - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v7 with: pattern: prebuilt-linux-arm64-* path: prebuilds/linux-arm64 @@ -63,4 +70,10 @@ jobs: run: ./scripts/npm-pack.sh - name: Publish - run: npm publish --provenance --access public ./dist/rclnodejs-*.tgz + run: | + if [[ "${{ inputs.dry_run }}" == "true" ]]; then + echo "=== DRY RUN ===" + npm publish --provenance --access public --dry-run ./dist/rclnodejs-*.tgz + else + npm publish --provenance --access public ./dist/rclnodejs-*.tgz + fi diff --git a/.github/workflows/prebuild-linux-arm64.yml b/.github/workflows/prebuild-linux-arm64.yml index b840a512..6a854e35 100644 --- a/.github/workflows/prebuild-linux-arm64.yml +++ b/.github/workflows/prebuild-linux-arm64.yml @@ -44,7 +44,7 @@ jobs: with: required-ros-distributions: ${{ matrix.ros_distribution }} - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - name: Install dependencies shell: bash @@ -59,7 +59,7 @@ jobs: npm run prebuild - name: Upload prebuilt binary - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: prebuilt-linux-arm64-node${{ matrix.node-version }}-${{ matrix.ubuntu_codename }}-${{ matrix.ros_distribution }} path: prebuilds/linux-arm64/*.node diff --git a/.github/workflows/prebuild-linux-x64.yml b/.github/workflows/prebuild-linux-x64.yml index c24235af..c7458d31 100644 --- a/.github/workflows/prebuild-linux-x64.yml +++ b/.github/workflows/prebuild-linux-x64.yml @@ -44,7 +44,7 @@ jobs: with: required-ros-distributions: ${{ matrix.ros_distribution }} - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - name: Install dependencies shell: bash @@ -59,7 +59,7 @@ jobs: npm run prebuild - name: Upload prebuilt binary - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: prebuilt-linux-x64-node${{ matrix.node-version }}-${{ matrix.ubuntu_codename }}-${{ matrix.ros_distribution }} path: prebuilds/linux-x64/*.node From 9bfcb269069a93f27c4624e660b0550efc43ac21 Mon Sep 17 00:00:00 2001 From: Minggang Wang Date: Wed, 1 Apr 2026 10:49:27 +0800 Subject: [PATCH 3/3] Address comments --- .github/workflows/npm-publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index f4033105..fb1f8b70 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -22,15 +22,15 @@ permissions: jobs: prebuild-x64: + if: github.repository == 'RobotWebTools/rclnodejs' uses: ./.github/workflows/prebuild-linux-x64.yml prebuild-arm64: + if: github.repository == 'RobotWebTools/rclnodejs' uses: ./.github/workflows/prebuild-linux-arm64.yml publish: needs: [prebuild-x64, prebuild-arm64] - # Only publish from the official repository, not forks - if: github.repository == 'RobotWebTools/rclnodejs' runs-on: ubuntu-latest environment: npm-publish permissions: