Skip to content

🚀 ci(releases): Version injection support + release/publish workflow #2

🚀 ci(releases): Version injection support + release/publish workflow

🚀 ci(releases): Version injection support + release/publish workflow #2

Workflow file for this run

name: Publish to npm

Check failure on line 1 in .github/workflows/publish-npm.yaml

View workflow run for this annotation

GitHub Actions / .github/workflows/publish-npm.yaml

Invalid workflow file

(Line: 32, Col: 14): Unexpected symbol: '??'. Located at position 31 within expression: github.event.release.tag_name ?? '0.0.1'
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 }}