diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 5927185..21a75fe 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -19,6 +19,8 @@ jobs: release: name: Create/Update Release Pull Request runs-on: ubuntu-latest + outputs: + release_created: ${{ steps.release.outputs.release_created }} steps: - name: Release Please id: release @@ -29,24 +31,58 @@ jobs: release-type: node package-name: fastify-floc-off + publish-npm: + name: Publish to NPM + needs: release + if: needs.release.outputs.release_created == 'true' + runs-on: ubuntu-latest + steps: - name: Check out repo - if: steps.release.outputs.release_created uses: actions/checkout@v4 with: persist-credentials: false - name: Setup Node - if: steps.release.outputs.release_created uses: actions/setup-node@v4 with: node-version: lts/* - registry-url: https://registry.npmjs.org/ + registry-url: https://registry.npmjs.org - name: Publish to NPM - if: steps.release.outputs.release_created env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - # Remove dev values from package.json + # Remove dev values from package.json before publishing to reduce package size + run: | + npm pkg delete commitlint devDependencies jest scripts + npm publish --ignore-scripts --provenance --registry https://registry.npmjs.org + + publish-ghp: + name: Publish to GitHub Packages + needs: release + if: needs.release.outputs.release_created == 'true' + runs-on: ubuntu-latest + steps: + - name: Check out repo + uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: lts/* + registry-url: https://npm.pkg.github.com + scope: "@fdawgs" + + - name: Scope package + run: | + pkgName=$(npm pkg get name | tr -d '"') + npm pkg set name="@fdawgs/$pkgName" + + - name: Publish to GitHub Packages + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # Remove dev values from package.json before publishing to reduce package size run: | npm pkg delete commitlint devDependencies jest scripts - npm publish --ignore-scripts --provenance + npm publish --ignore-scripts --registry https://npm.pkg.github.com/@fdawgs