From 5a191e3c4d557168cbe6ec1acd271e40242fa438 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=B6=9B?= Date: Sun, 12 Mar 2023 11:40:07 +0800 Subject: [PATCH] =?UTF-8?q?feat(github):=E5=B0=9D=E8=AF=95=E8=AE=BE?= =?UTF-8?q?=E7=BD=AEGithub=20Actions=E6=9D=A5=E8=BF=9B=E8=A1=8C=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E5=8C=96=E7=BC=96=E8=AF=91=E5=8F=91=E5=B8=83=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yml | 102 ++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..9d839a0 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,102 @@ +name: release CI +on: + push: + tags: + - 'v*' + +jobs: + 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: 'comic_viewer ${{ steps.get_version.outputs.VERSION }}' + body: '从附件中下载对应平台的安装包以及应用。' + + build-tauri: + needs: create-release + strategy: + fail-fast: false + matrix: + platform: [macos-latest, ubuntu-latest, windows-latest] + + runs-on: ${{ matrix.platform }} + steps: + - uses: actions/checkout@v2 + + # 安装 Node.js + - name: Setup node + uses: actions/setup-node@v1 + with: + node-version: 16 + + # 安装 Rust + - name: Install Rust stable + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + + # 使用 Rust 缓存,加快安装速度 + - uses: Swatinem/rust-cache@v1 + + - name: install dependencies (ubuntu only) + if: matrix.platform == 'ubuntu-latest' + run: | + sudo apt-get update + sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf + + # 安装PNPM + - uses: pnpm/action-setup@v2 + name: Install pnpm + id: pnpm-install + with: + version: 7 + run_install: false + + # 获取PNPM缓存路径 + - name: Get pnpm store directory + id: pnpm-cache + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT + + # 设置PNPM缓存 + - uses: actions/cache@v3 + name: Setup pnpm cache + with: + path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + # 安装依赖 + - name: Install dependencies + run: pnpm install + + # 执行构建,以及推送 github release + - name: Install app dependencies and build it + run: pnpm tauri build + - uses: tauri-apps/tauri-action@v0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + releaseId: ${{ needs.create-release.outputs.RELEASE_UPLOAD_ID }}'