diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6623e00..1e1ab7d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,36 +7,8 @@ on: - 'v*.*.*' jobs: - # 任务:创建 release 版本 - create-release: - runs-on: ubuntu-latest - outputs: - RELEASE_UPLOAD_ID: ${{ steps.create_release.outputs.id }} - - steps: - - uses: actions/checkout@v2 - # 查询版本号(tag) - - name: Query version number - id: get_version - shell: bash - run: | - echo "using version tag ${GITHUB_REF:10}" - echo ::set-output name=version::"${GITHUB_REF:10}" - - # 根据查询到的版本号创建 release - - name: Create Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: '${{ steps.get_version.outputs.VERSION }}' - release_name: 'app ${{ steps.get_version.outputs.VERSION }}' - body: 'See the assets to download this version and install.' - build-electron: name: build and release electron app - needs: create-release runs-on: ${{ matrix.os }} # create a build matrix for jobs @@ -57,18 +29,45 @@ jobs: node-version: 16 # step3: npm install - - name: npm install + - name: Install npm dependencies run: | - npm install && cd frontend && npm install + npm install + cd frontend + npm install + cd ../ # step4: build app for mac/win # 安装依赖执行构建,以及推送 github release - - name: Install app dependencies and build it + - name: Build app # package.json里面配置的编译命令 run: | npm run build-app - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # step5: cleanup artifacts + - name: cleanup artifacts for windows + if: matrix.os == 'windows-latest' + run: | + npx rimraf "out/make/!(*.zip)" + + - name: cleanup artifacts for macos + if: matrix.os == 'macos-latest' + run: | + npx rimraf "out/make/!(*.dmg)" + + + # step6: upload artifacts + - name: upload artifacts + uses: actions/upload-artifact@v2 with: - releaseId: ${{ needs.create-release.outputs.RELEASE_UPLOAD_ID }} \ No newline at end of file + name: ${{ matrix.os }} + path: out/make + + # step7: create release + - name: release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + files: "out/make/**" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file