Skip to content

Release

Release #140

Workflow file for this run

name: Release
on:
workflow_dispatch:
# push:
# branches:
# - master
# - main
permissions:
issues: write
contents: write
packages: write
pull-requests: write
env:
NODE_VERSION: 20.x
jobs:
check-version:
uses: ./.github/workflows/_check-version.yml
no-version:
runs-on: ubuntu-latest
needs: check-version
if: ${{ needs.check-version.outputs.NEXT_RELEASE_VERSION == '' }}
steps:
- run: |
echo "There is no new version to be released."
build:
uses: ./.github/workflows/_build.yml
needs: check-version
if: ${{ needs.check-version.outputs.NEXT_RELEASE_VERSION != '' }}
release:
runs-on: ubuntu-latest
needs: [check-version, build]
if: ${{ needs.check-version.outputs.NEXT_RELEASE_VERSION != '' && needs.build.result == 'success' }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
ref: ${{ github.ref }}
- name: Download dist
uses: actions/cache/restore@v4
with:
path: ./dist
key: dist-${{ needs.check-version.outputs.NEXT_RELEASE_VERSION }}
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: https://registry.npmjs.org
- name: Publish to NPM
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Set up registry for GitHub
uses: actions/setup-node@v4
with:
registry-url: https://npm.pkg.github.com/
- name: Publish to GitHub
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Decode changelog
uses: actions/github-script@v7
id: decode-changelog
with:
result-encoding: string
script: |
const encodedChangelog = '${{ needs.check-version.outputs.NEXT_RELEASE_CHANGELOG }}'
return encodedChangelog.replaceAll('%25', '%').replaceAll('%0D', '\r').replaceAll('%0A', '\n').replaceAll(/^#\s\[/g, '## [')
- name: Send notification
uses: bndynet/github-action-webex@v2
with:
action: message
token: ${{ secrets.WX_TOKEN }}
server: ${{ secrets.WX_SERVER }}
rooms: ${{ secrets.WX_ROOMID }}
message: "# 🚀 [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) \n\n\n${{ steps.decode-changelog.outputs.result }}"
- run: |
echo "${{ steps.decode-changelog.outputs.result }}" >> $GITHUB_STEP_SUMMARY