fix: 修复 github workflow 发包报错。 #52
Workflow file for this run
This file contains hidden or 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: | |
| push: | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: 'Release tag (beta or latest)' | |
| required: true | |
| default: 'latest' | |
| type: choice | |
| options: | |
| - latest | |
| - beta | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: write | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Install dependencies | |
| run: | | |
| npm i -g pnpm | |
| rm -rf ~/.npm/_cacache | |
| rm -rf node_modules/.cache | |
| rm -rf packages/core/node_modules | |
| pnpm store prune || true | |
| pnpm install --force | |
| - name: Build | |
| run: | | |
| (cd packages/core && \ | |
| pnpm run aeac && \ | |
| pnpm run build:es && \ | |
| pnpm run build:umd) | |
| - name: Determine release tag | |
| id: tag_type | |
| run: | | |
| VERSION=$(node -p "require('./packages/core/package.json').version") | |
| echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | |
| if [[ "$VERSION" == *"beta"* ]] || [[ "${{ github.event.inputs.tag }}" == "beta" ]]; then | |
| echo "TAG=beta" >> $GITHUB_OUTPUT | |
| else | |
| echo "TAG=latest" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Check npm version exists | |
| id: npm_version | |
| run: | | |
| if npm view vue-element-plus-x@${{ steps.tag_type.outputs.VERSION }} version >/dev/null 2>&1; then | |
| echo "EXISTS=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "EXISTS=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Create .tgz package | |
| run: | | |
| cd packages/core | |
| npm pack | |
| - name: Publish to npm | |
| if: (github.event_name == 'push' || github.event.inputs.tag) && steps.npm_version.outputs.EXISTS != 'true' | |
| run: | | |
| cd packages/core | |
| npm publish --tag ${{ steps.tag_type.outputs.TAG }} --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Upload package artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: npm-package | |
| path: packages/core/vue-element-plus-x-${{ steps.tag_type.outputs.VERSION }}.tgz | |
| retention-days: 90 | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| if: startsWith(github.ref, 'refs/tags/') | |
| with: | |
| files: packages/core/vue-element-plus-x-${{ steps.tag_type.outputs.VERSION }}.tgz | |
| generate_release_notes: true | |
| draft: false | |
| prerelease: ${{ steps.tag_type.outputs.TAG == 'beta' }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create Release Pull Request | |
| id: create_release | |
| uses: changesets/action@v1 | |
| with: | |
| publish: pnpm ci:publish | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |