CD #9
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: CD | |
on: | |
workflow_dispatch: | |
inputs: | |
vizzu: | |
description: 'Vizzu version to tag' | |
required: true | |
workspace: | |
description: 'Yarn workspace to use' | |
required: true | |
release_workspace: | |
description: 'Publish package to npm' | |
default: false | |
type: boolean | |
jobs: | |
publish: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- name: Enable Corepack | |
run: | | |
corepack enable | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
cache: 'yarn' | |
cache-dependency-path: 'yarn.lock' | |
- name: Set up yarn | |
run: | | |
yarn --immutable | |
- name: Build packages | |
run: | | |
yarn workspace ${{ inputs.workspace }} build && | |
yarn workspace ${{ inputs.workspace }} pack | |
- name: Publish package | |
if: ${{ inputs.release_workspace }} | |
run: | | |
echo "npmAuthToken: \"${VIZZUHQ_NPM_API}\"" > .yarnrc.yml | |
yarn workspace ${{ inputs.workspace }} npm publish --access public | |
env: | |
VIZZUHQ_NPM_API: ${{ secrets.VIZZUHQ_NPM_API }} | |
- name: Tag package | |
run: | | |
echo "npmAuthToken: \"${VIZZUHQ_NPM_API}\"" > .yarnrc.yml | |
yarn workspaces list --json | while IFS= read -r line; do | |
LOCATION=$(echo "$line" | jq -r '.location') | |
WORKSPACE=$(echo "$line" | jq -r '.name') | |
if [ "$WORKSPACE" != "${{ inputs.workspace }}" ]; then | |
continue | |
fi | |
VERSION=$(cat $LOCATION/package.json | jq -r '.version') | |
VIZZU_VERSION="${{ inputs.vizzu }}" | |
TAGS=("vizzu-${VIZZU_VERSION%%.*}" "vizzu-${VIZZU_VERSION%.*}" "vizzu-$VIZZU_VERSION") | |
for TAG in "${TAGS[@]}"; do | |
yarn workspace $WORKSPACE npm tag add $WORKSPACE@$VERSION $TAG | |
done | |
done | |
env: | |
VIZZUHQ_NPM_API: ${{ secrets.VIZZUHQ_NPM_API }} |