🐛 Solve some detailed problems #24
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: Build and Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| build-and-release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: '20' | |
| - name: Install pnpm | |
| run: npm install -g pnpm lerna | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Build Client & Server | |
| run: npm run build | |
| - name: Copy package.json to dist | |
| run: cp server/package.json server/dist/ | |
| - name: Create script.sh | |
| run: | | |
| echo "cd dist" > script.sh | |
| echo "npm i" >> script.sh | |
| echo "node index.js" >> script.sh | |
| - name: Create script.bat | |
| run: | | |
| echo cd dist > script.bat | |
| echo npm i >> script.bat | |
| echo node index.js >> script.bat | |
| - name: Package into a single ZIP | |
| run: | | |
| cd server | |
| zip -r ../wealth-tracker.zip public dist | |
| zip -j ../wealth-tracker.zip ../script.sh ../script.bat | |
| # 🔑 获取 package.json 的 version | |
| - name: Get Version from package.json | |
| id: get_version | |
| run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT | |
| - name: Create Release | |
| id: create_release | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} | |
| with: | |
| tag_name: v${{ steps.get_version.outputs.version }} | |
| release_name: 🎉 Release ${{ steps.get_version.outputs.version }} 🎉 | |
| draft: false | |
| prerelease: false | |
| - name: Upload ZIP to Release | |
| uses: actions/upload-release-asset@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} | |
| with: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| asset_path: ./wealth-tracker.zip | |
| asset_name: wealth-tracker.zip | |
| asset_content_type: application/zip |