Publish to NPM #85
Workflow file for this run
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 | |
on: | |
release: | |
types: [published] | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
registry-url: https://registry.npmjs.com/ | |
scope: '@relewise' | |
- name: Get the latest tag | |
uses: actions-ecosystem/action-get-latest-tag@v1 | |
id: get-latest-tag | |
- name: Calculate environment variables | |
run: | | |
echo 'TAG_NAME=${{ steps.get-latest-tag.outputs.tag }}' | |
echo 'PACKAGE_PATH=${{ steps.get-latest-tag.outputs.tag }}' | cut -d '@' -f 1 >> $GITHUB_ENV | |
- uses: brettdorrans/write-version-to-file@master | |
if: ${{ env.PACKAGE_PATH == 'client' }} | |
name: Update version | |
with: | |
filename: './packages/${{ env.PACKAGE_PATH }}/src/version.ts' | |
placeholder: '${VERSION}' | |
- run: npm ci | |
working-directory: ./packages/${{ env.PACKAGE_PATH }} | |
- run: npm run publish | |
working-directory: ./packages/${{ env.PACKAGE_PATH }} | |
- name: Determine NPM Tag | |
id: determine-tag | |
run: | | |
VERSION=$(node -p "require('./packages/${{ env.PACKAGE_PATH }}/package.json').version") | |
TAG="latest" | |
if [[ "$VERSION" == *"-alpha"* ]]; then | |
TAG="alpha" | |
elif [[ "$VERSION" == *"-beta"* ]]; then | |
TAG="beta" | |
fi | |
echo "NPM_TAG=$TAG" >> $GITHUB_ENV | |
echo "Publishing version $VERSION with tag $TAG" | |
- name: Publish to NPM | |
run: npm publish --access public --tag $NPM_TAG | |
working-directory: ./packages/${{ env.PACKAGE_PATH }} | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |