Skip to content

Update README.md

Update README.md #10

name: Continuous Delivery
on:
workflow_dispatch:
inputs:
pull_request:
description: The number of the PR that is being deployed.
required: false
branch:
description: The branch that is being deployed.
required: false
push:
branches:
- main
paths:
- 'packages/**/src/**'
jobs:
integration:
uses: ./.github/workflows/continuous-integration.yml
publish:
name: Publish
needs: integration
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v3
with:
fetch-depth: 0
repository: ${{ github.event.inputs.repository || github.repository }}
ref: ${{ github.event.inputs.branch || 'main' }}
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
registry-url: 'https://registry.npmjs.org'
cache: 'yarn'
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/.yarn
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
- name: Install dependencies
run: yarn install
- name: Determine tag
id: determine_tag
run: |
# Dispatch a pull request
if [[ ${{ github.event.inputs.pull_request != '' }} == true ]]
then
NUMBER=${{ github.event.inputs.pull_request }}
echo "TAG=pr-${NUMBER}" >> $GITHUB_OUTPUT
# Push or regular dispatch
else
echo "TAG=next" >> $GITHUB_OUTPUT
fi
- name: Publish to NPM
if: steps.determine_tag.outputs.TAG != ''
run: |
TAG=${{ steps.determine_tag.outputs.TAG }}
HEAD="$(git rev-parse --short HEAD)"
for PACKAGE in packages/*
do
if [[ $(git diff HEAD~1 --name-only $PACKAGE/) ]]
then
pushd $PACKAGE
yarn lint
yarn build
yarn version patch
VERSION=$(node -p "require('./package.json').version")
IDENTIFIER="${VERSION}-${TAG}.${HEAD}"
node -e "const fs=require('fs');const package=require('./package.json');package.version='${IDENTIFIER}';fs.writeFileSync('./package.json',JSON.stringify(package, null, 4));"
npm publish --tag $TAG
popd
fi
done
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}