feat(github):尝试设置Github Actions来进行自动化编译发布。
This commit is contained in:
		
							
								
								
									
										102
									
								
								.github/workflows/release.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										102
									
								
								.github/workflows/release.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -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 }}' | ||||||
		Reference in New Issue
	
	Block a user