🚀 ci(releases): Version injection support + release/publish workflow #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish to npm | ||
|
Check failure on line 1 in .github/workflows/publish-npm.yaml
|
||
| permissions: | ||
| contents: read | ||
| on: | ||
| release: | ||
| types: [published] | ||
| # TODO: remove this once we have the correct token to publish | ||
| pull_request: | ||
| jobs: | ||
| publish: | ||
| runs-on: namespace-profile-linux-8-vcpu-16-gb-ram-optimal | ||
| steps: | ||
| - uses: namespacelabs/nscloud-checkout-action@v8 | ||
| - uses: actions/setup-node@v6 | ||
| with: | ||
| node-version-file: '.nvmrc' | ||
| registry-url: 'https://registry.npmjs.org' | ||
| package-manager-cache: false | ||
| - uses: pnpm/action-setup@v4 | ||
| - uses: namespacelabs/nscloud-cache-action@v1 | ||
| with: | ||
| cache: pnpm | ||
| - name: Derive release version | ||
| run: | | ||
| TAG='${{ github.event.release.tag_name ?? '0.0.1' }}' | ||
| VERSION="${TAG#v}" | ||
| echo "RELEASE_TAG=$TAG" >> "$GITHUB_ENV" | ||
| echo "RELEASE_VERSION=$VERSION" >> "$GITHUB_ENV" | ||
| - run: pnpm install --prefer-offline --frozen-lockfile | ||
| - name: Bump package.json versions | ||
| run: | | ||
| pnpm -r --filter "@contentful/optimization-*" exec \ | ||
| npm --no-git-tag-version --force version "$RELEASE_VERSION" | ||
| env: | ||
| RELEASE_VERSION: ${{ env.RELEASE_VERSION }} | ||
| - name: Build | ||
| run: pnpm build | ||
| env: | ||
| RELEASE_VERSION: ${{ env.RELEASE_VERSION }} | ||
| - name: Create packages for troubleshooting | ||
| if: ${{ !cancelled() }} | ||
| run: pnpm pack --recursive --filter "@contentful/optimization-*" --pack-destination pkgs | ||
| - name: Upload packages for troubleshooting | ||
| uses: actions/upload-artifact@v6 | ||
| if: ${{ !cancelled() }} | ||
| with: | ||
| name: ci-optimization-sdk-packages | ||
| path: | | ||
| ./pkgs/ | ||
| retention-days: 3 | ||
| # TODO: uncomment this once we have the correct token to publish | ||
| # - name: Publish | ||
| # run: pnpm -r --filter "@contentful/contentful-*" publish --access public --no-git-checks | ||
| # env: | ||
| # NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||