|
| 1 | +on: |
| 2 | + push: |
| 3 | + tags: |
| 4 | + - 'v*' |
| 5 | + |
| 6 | +name: Release |
| 7 | + |
| 8 | +jobs: |
| 9 | + build: |
| 10 | + name: Upload Release Asset |
| 11 | + strategy: |
| 12 | + matrix: |
| 13 | + os: [ubuntu-latest] |
| 14 | + runs-on: ${{ matrix.os }} |
| 15 | + outputs: |
| 16 | + release_url: ${{ steps.create_release.outputs.upload_url }} |
| 17 | + steps: |
| 18 | + - name: Checkout code |
| 19 | + uses: actions/checkout@v4 |
| 20 | + |
| 21 | + - uses: actions/setup-node@v4 |
| 22 | + with: |
| 23 | + node-version: 20.x |
| 24 | + - name: Start MongoDB |
| 25 | + uses: supercharge/mongodb-github-action@v1.10.0 |
| 26 | + with: |
| 27 | + mongodb-version: 4.4 |
| 28 | + - name: Start Redis |
| 29 | + uses: supercharge/redis-github-action@1.7.0 |
| 30 | + with: |
| 31 | + redis-version: 6 |
| 32 | + - uses: pnpm/action-setup@v4.0.0 |
| 33 | + with: |
| 34 | + run_install: true |
| 35 | + - name: Test |
| 36 | + run: | |
| 37 | + npm run lint |
| 38 | + npm run test |
| 39 | + npm run test:e2e |
| 40 | +
|
| 41 | + - name: Build project |
| 42 | + run: | |
| 43 | + pnpm run bundle |
| 44 | + - name: Test Bundle Server |
| 45 | + run: | |
| 46 | + bash scripts/workflow/test-server.sh |
| 47 | + # - name: Zip Assets |
| 48 | + # run: | |
| 49 | + # sh scripts/zip-asset.sh |
| 50 | + - name: Create Release |
| 51 | + id: create_release |
| 52 | + uses: actions/create-release@v1 |
| 53 | + env: |
| 54 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 55 | + with: |
| 56 | + tag_name: ${{ github.ref }} |
| 57 | + release_name: Release ${{ github.ref }} |
| 58 | + draft: false |
| 59 | + prerelease: false |
| 60 | + - name: Upload Release Asset |
| 61 | + id: upload-release-asset |
| 62 | + uses: actions/upload-release-asset@v1 |
| 63 | + env: |
| 64 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 65 | + with: |
| 66 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 67 | + asset_path: ./release.zip |
| 68 | + asset_name: release-${{ matrix.os }}.zip |
| 69 | + asset_content_type: application/zip |
| 70 | + # deploy: |
| 71 | + # name: Deploy To Remote Server |
| 72 | + # runs-on: ubuntu-latest |
| 73 | + # needs: [build] |
| 74 | + # steps: |
| 75 | + # - name: Exec deploy script with SSH |
| 76 | + # uses: appleboy/ssh-action@master |
| 77 | + # env: |
| 78 | + # JWTSECRET: ${{ secrets.JWTSECRET }} |
| 79 | + # with: |
| 80 | + # command_timeout: 10m |
| 81 | + # host: ${{ secrets.HOST }} |
| 82 | + # username: ${{ secrets.USER }} |
| 83 | + # password: ${{ secrets.PASSWORD }} |
| 84 | + # envs: JWTSECRET |
| 85 | + # script_stop: true |
| 86 | + # script: | |
| 87 | + # whoami |
| 88 | + # cd |
| 89 | + # source ~/.zshrc |
| 90 | + # cd mx |
| 91 | + # ls -a |
| 92 | + # node server-deploy.js --jwtSecret=$JWTSECRET |
| 93 | + |
| 94 | + build_other_platform: |
| 95 | + name: Build Other Platform |
| 96 | + strategy: |
| 97 | + matrix: |
| 98 | + os: [macos-latest] |
| 99 | + runs-on: ${{ matrix.os }} |
| 100 | + needs: [build] |
| 101 | + steps: |
| 102 | + - name: Checkout code |
| 103 | + uses: actions/checkout@v4 |
| 104 | + - name: Cache pnpm modules |
| 105 | + uses: actions/cache@v3 |
| 106 | + env: |
| 107 | + cache-name: cache-pnpm-modules |
| 108 | + with: |
| 109 | + path: ~/.pnpm-store |
| 110 | + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.node-version }}-${{ hashFiles('**/pnpm-lock.yaml') }} |
| 111 | + restore-keys: | |
| 112 | + ${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.node-version }}- |
| 113 | + - uses: pnpm/action-setup@v4.0.0 |
| 114 | + with: |
| 115 | + run_install: true |
| 116 | + - name: Build project |
| 117 | + run: | |
| 118 | + pnpm run bundle |
| 119 | + - name: Zip Assets |
| 120 | + run: | |
| 121 | + sh scripts/zip-asset.sh |
| 122 | + - name: Upload Release Asset |
| 123 | + id: upload-release-asset |
| 124 | + uses: actions/upload-release-asset@v1 |
| 125 | + env: |
| 126 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 127 | + with: |
| 128 | + upload_url: ${{ needs.build.outputs.release_url }} |
| 129 | + asset_path: ./release.zip |
| 130 | + asset_name: release-${{ matrix.os }}.zip |
| 131 | + asset_content_type: application/zip |
0 commit comments