From 45a091bd1fcc4e10ad06df85b1b9bb5164a92eaa Mon Sep 17 00:00:00 2001 From: Mikkel Jakobsen Date: Thu, 29 Aug 2024 11:34:40 +0200 Subject: [PATCH] Copy npm publishing strategy from another project --- .github/workflows/release-package.yml | 19 +++++++++++++++++-- package.json | 2 +- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release-package.yml b/.github/workflows/release-package.yml index e6a7ed4..9baea38 100644 --- a/.github/workflows/release-package.yml +++ b/.github/workflows/release-package.yml @@ -16,6 +16,21 @@ jobs: registry-url: https://npm.pkg.github.com/ - run: npm ci - run: npm run build - - run: npm publish + + - name: Modify package.json for local context + if: steps.version.outputs.is_valid == 'true' + # Values in package.json must match the current GitHub repository to + # publish to it. + run: | + npm exec -- json -I -f package.json -e "this.name='@$GITHUB_REPOSITORY'" + npm exec -- json -I -f package.json -e "this.repository='https://github.com/$GITHUB_REPOSITORY'" + + - name: Release NPM package + if: steps.version.outputs.is_valid == 'true' + # The latest tag follows tagged versions to follow NPM conventions. + run: | + npm version ${{ env.NPM_VERSION }} --no-git-tag-version + cat package.json + npm publish --tag latest env: - NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/package.json b/package.json index 836934a..c8bf35f 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "json-to-zod": "./dist/src/cli.js" }, "publishConfig": { - "spaceo:registry": "https://npm.pkg.github.com" + "registry": "https://npm.pkg.github.com" }, "dependencies": { "cosmiconfig": "^9.0.0",