fix: decode changelog #124
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: | |
logLevel: | |
required: true | |
default: 'warning' | |
push: | |
branches: | |
- master | |
- main | |
permissions: | |
issues: write | |
contents: write | |
packages: write | |
pull-requests: write | |
env: | |
NODE_VERION: 18.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 != '' }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
persist-credentials: false | |
ref: ${{ github.ref }} | |
- name: Download dist | |
uses: actions/cache/restore@v3 | |
with: | |
path: ./dist | |
key: dist-${{ needs.check-version.outputs.NEXT_RELEASE_VERSION }} | |
- name: Use Node.js ${{ env.NODE_VERION }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ env.NODE_VERION }} | |
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@v3 | |
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@v6 | |
id: decode-changelog | |
with: | |
result-encoding: string | |
script: | | |
const encodedChangelog = '${{ needs.check-version.outputs.NEXT_RELEASE_CHANGELOG }}' | |
return encodedChangelog..replaceAll('%0A', '\\n').replaceAll('%0D', '\\r').replaceAll('%25', '%') | |
- name: Send notification | |
uses: bndynet/github-action-webex@v1 | |
with: | |
action: message | |
token: ${{ secrets.WX_TOKEN }} | |
server: ${{ secrets.WX_SERVER }} | |
room-id: ${{ secrets.WX_ROOMID }} | |
message: "${{ steps.decode-changelog.outputs.result }}" | |
# message: "${{ github.repository }} v${{ needs.check-version.outputs.NEXT_RELEASE_VERSION }} has been released" | |
- run: | | |
echo "${{ steps.decode-changelog.outputs.result }}" >> $GITHUB_STEP_SUMMARY |