From 9f3e9e5d17e3c81df1ab874d1bb353423e6f513d Mon Sep 17 00:00:00 2001 From: Katsuyuki Omuro Date: Thu, 24 Oct 2024 18:24:43 +0900 Subject: [PATCH] Publish to GitHub packages in addition to npmjs --- .github/workflows/publish_release.yml | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish_release.yml b/.github/workflows/publish_release.yml index 623d398ec..a7f598cf6 100644 --- a/.github/workflows/publish_release.yml +++ b/.github/workflows/publish_release.yml @@ -12,17 +12,39 @@ jobs: uses: actions/checkout@v4 - name: "Fetch unshallow repo" run: git fetch --prune --unshallow + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 'lts/*' + registry-url: 'https://registry.npmjs.org' + - name: Set up auth for GitHub packages + run: | + npm config set "//npm.pkg.github.com/:_authToken" "\${NODE_AUTH_TOKEN}" - name: Update npm packages to latest version working-directory: ./npm/@fastly/cli run: npm install && npm version "${{ github.ref_name }}" --allow-same-version - - name: Publish npm packages + - name: Publish packages to npmjs.org + working-directory: ./npm/@fastly + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + run: | + for dir in *; do + ( + echo $dir + cd $dir + npm publish --access=public + ) + done + - name: Publish packages to GitHub packages working-directory: ./npm/@fastly + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | + npm config set "@fastly:registry" "https://npm.pkg.github.com/" for dir in *; do ( echo $dir cd $dir - npm config set "//registry.npmjs.org/:_authToken" "${{ secrets.NPM_TOKEN }}" npm publish --access=public ) done