Publish CLI to NPM (Release) #12
Workflow file for this run
This file contains 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 CLI to NPM (Release) | |
on: | |
release: | |
types: [published] | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [20] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.PACKAGE_SECRET }} | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Check version correctness | |
env: | |
GITHUB_REF: ${{ github.ref }} | |
run: | | |
PACKAGE_VERSION=v$(npm --prefix=src/connector-cli pkg get version | tr -d '"') | |
TAG_VERSION=${GITHUB_REF#refs/tags/} | |
if [ "$PACKAGE_VERSION" = "$TAG_VERSION" ]; then | |
echo "The package.json version matches the tag version." | |
else | |
echo "The package.json version does not match the tag version." | |
echo "package.json version: $PACKAGE_VERSION" | |
echo "Tag version: $TAG_VERSION" | |
exit 1 | |
fi | |
- name: Install dependencies | |
run: yarn | |
- name: Build | |
run: yarn workspace @chili-publish/connector-cli run build | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
registry-url: 'https://registry.npmjs.org' | |
scope: '@chili-publish' | |
- name: Publish | |
run: yarn publish src/connector-cli --access=public | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} |