Skip to content

fix: cmd run twice #129

fix: cmd run twice

fix: cmd run twice #129

Workflow file for this run

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('%25', '%').replaceAll('%0D', '\r').replaceAll('%0A', '\n')
- 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: "# ${{ github.repository }} \n\n\n${{ steps.decode-changelog.outputs.result }}"
- run: |
echo "${{ steps.decode-changelog.outputs.result }}" >> $GITHUB_STEP_SUMMARY