π Release #71
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: π Release | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: Version | |
required: true | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
permissions: | |
contents: write | |
jobs: | |
prepare: | |
if: ${{ github.event.inputs.version != '' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: π Set all monorepo's package version | |
run: | | |
node -e "const fs = require('fs'); const package = JSON.parse(fs.readFileSync('./package.json')); package.version = '${{ github.event.inputs.version }}'; fs.writeFileSync('./package.json', JSON.stringify(package, null, 4));" | |
node -e "const fs = require('fs'); const package = JSON.parse(fs.readFileSync('./doc/package.json')); package.version = '${{ github.event.inputs.version }}'; fs.writeFileSync('./doc/package.json', JSON.stringify(package, null, 4));" | |
node -e "const fs = require('fs'); const package = JSON.parse(fs.readFileSync('./svg/package.json')); package.version = '${{ github.event.inputs.version }}'; fs.writeFileSync('./svg/package.json', JSON.stringify(package, null, 4));" | |
for package in $(ls packages); do | |
node -e "const fs = require('fs'); const package = JSON.parse(fs.readFileSync('./packages/$package/package.json')); package.version = '${{ github.event.inputs.version }}'; fs.writeFileSync('./packages/$package/package.json', JSON.stringify(package, null, 4));" | |
done | |
- name: π Commit and push changes | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "GitHub Actions" | |
git add -A | |
git commit -m "chore(release): v${{ github.event.inputs.version }}" || exit 0 | |
git push | |
git tag -a v${{ github.event.inputs.version }} -m "v${{ github.event.inputs.version }}" | |
git push origin v${{ github.event.inputs.version }} | |
release-verdaccio: | |
needs: [prepare] | |
runs-on: ubuntu-latest | |
steps: | |
- run: | | |
echo "release: ${{ github.event.inputs.version }}" | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: v${{ github.event.inputs.version }} | |
- name: Install pnpm | |
uses: pnpm/action-setup@v4 | |
with: | |
run_install: false | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
registry-url: https://registry.npmjs.org | |
- name: π Install & Build & Publish | |
run: | | |
pnpm i | |
pnpm generate && pnpm build | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
registry-url: ${{ secrets.VERDACCIO_URL }} | |
scope: '@univerjs' | |
- name: π Install & Build & Publish | |
run: | | |
pnpm publish --access public -r --no-git-checks | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.VERDACCIO_TOKEN }} | |
release-npm: | |
needs: [prepare] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: v${{ github.event.inputs.version }} | |
- name: Install pnpm | |
uses: pnpm/action-setup@v4 | |
with: | |
run_install: false | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
registry-url: https://registry.npmjs.org | |
- name: π Install & Build & Publish | |
run: | | |
pnpm i | |
pnpm generate && pnpm build | |
pnpm publish --access public -r --no-git-checks | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
dispatch-docs: | |
needs: [release-verdaccio, release-npm] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Invoke deployment hook | |
uses: peter-evans/repository-dispatch@v2 | |
with: | |
token: ${{ secrets.GH_TOKEN }} | |
repository: dream-num/univer.ai | |
event-type: deploy | |
notify: | |
needs: [release-verdaccio, release-npm] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Invoke deployment hook | |
uses: distributhor/workflow-webhook@v3 | |
with: | |
webhook_url: ${{ secrets.WEBHOOK_URL }} | |
data: > | |
{ | |
"type": "release", | |
"version": "v${{ github.event.inputs.version }}", | |
"workflow": { | |
"id": "${{ github.run_id }}" | |
}, | |
"preview": { | |
"π Docs": "https://univer.ai/icons" | |
} | |
} |