From 38b97b684015a0567c4a3bea6cd2d8313f981bc9 Mon Sep 17 00:00:00 2001 From: Artyom Savchenko Date: Mon, 2 Mar 2026 13:44:07 +0700 Subject: [PATCH] Allow to launch publish npm manually (#10580) * Allow to launch publish npm manually Signed-off-by: Artem Savchenko * Potential fix for code scanning alert no. 288: Workflow does not contain permissions Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Signed-off-by: Artyom Savchenko --------- Signed-off-by: Artem Savchenko Signed-off-by: Artyom Savchenko Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- .github/workflows/publish-npm.yml | 52 +++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/publish-npm.yml diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml new file mode 100644 index 0000000000..f3b9d350fa --- /dev/null +++ b/.github/workflows/publish-npm.yml @@ -0,0 +1,52 @@ +name: Publish npm + +on: + workflow_dispatch: + inputs: + ref: + description: 'Ref to publish (e.g. refs/tags/v0.7.382 or a branch)' + required: true + default: 'refs/heads/develop' + +jobs: + publish-npm: + permissions: + contents: read + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v6 + with: + ref: ${{ github.event.inputs.ref }} + fetch-depth: 0 + - uses: actions/setup-node@v6 + with: + node-version-file: '.nvmrc' + - name: Cache node modules + uses: actions/cache@v5 + env: + cache-name: cache-node-platform + with: + path: common/temp + key: ${{ runner.os }}-build-cache-node-platform-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: ${{ runner.os }}-build-cache-node-platform- + - name: Installing... + run: node common/scripts/install-run-rush.js install + - name: Building... + run: node common/scripts/install-run-rush.js build + - name: Publish to npm + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + run: | + if [ -z "$NPM_TOKEN" ]; then + echo "::error::NPM_TOKEN secret is not set. Add it in repository Settings > Secrets and variables > Actions." + exit 1 + fi + echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc + REF="${{ github.event.inputs.ref }}" + VERSION="${REF#refs/tags/v}" + VERSION="${VERSION#v}" + if [[ "$REF" == refs/tags/v* ]]; then + node common/scripts/bump.js --check "$VERSION" + fi + node common/scripts/safe-publish.js