From a310908e8eb8604fff54d37191f7e8c6330fae7c Mon Sep 17 00:00:00 2001 From: xBoyMinemc <86919167+xBoyMinemc@users.noreply.github.com> Date: Tue, 5 Nov 2024 15:33:27 +0800 Subject: [PATCH] There are a thousand Hamlets in a thousand people's eyes. --- .github/workflows/node.js.yml | 60 ++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 8b5b9f6..a1bcb94 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -13,38 +13,40 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 + - name: Get the latest commit message + id: get_latest_commit + run: | + latest_commit=$(git log -1 --pretty=format:%s) + echo "latest_commit_message=$latest_commit" >> $GITHUB_ENV + + - name: Read changelog + id: read_changelog + run: | + changelog=$(< CHANGELOG.md) + echo "CHANGELOG<> $GITHUB_ENV + echo "$changelog" >> $GITHUB_ENV + echo "EOF" >> $GITHUB_ENV + - name: Set up Node.js + if: startsWith(env.latest_commit_message, 'v') uses: actions/setup-node@v3 with: node-version: 'latest' - - - name: Install TypeScript - run: npm install typescript@latest - - name: Install dependencies - run: npm i - - # - name: tsc build - # run: tsc - - # - name: webpack build - # run: webpack - - # - name: Build project - # run: node packer.js - - # - name: Release - # uses: softprops/action-gh-release@v1 - # with: - # files: ./node_modules/* - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # 使用 GitHub 提供的 token 进行发布 - - - - name: Upload compressed archive - uses: actions/upload-artifact@v4 + - name: npm run build + if: startsWith(env.latest_commit_message, 'v') + run: npm run build + + - name: Release + uses: softprops/action-gh-release@v1 + # Check if commit message starts with 'v' + if: startsWith(env.latest_commit_message, 'v') with: - name: my-compressed-archive - path: ./node_modules/ - - + tag_name: ${{ github.ref }} + name: Release ${{ env.latest_commit_message }} + body: ${{ env.CHANGELOG }} + draft: false + prerelease: false + files: build/* + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}