From 0e33fccd4a555517ccd2cb28e8d33c86525665be Mon Sep 17 00:00:00 2001 From: MATSUNAGA Takuya Date: Wed, 4 Dec 2024 15:10:07 +0900 Subject: [PATCH] Refactor GitHub Actions workflow to separate test and publish jobs - Split the original publish job into two separate jobs: `test-tauri` and `publish-tauri`. - Introduced a new job `update-version` to extract and update version numbers before publishing. - Enhanced platform support in the `publish-tauri` job by specifying matrix configurations for macOS, Ubuntu, and Windows. - Added condition for installing Rust targets only on macOS runners. - Added Ubuntu-specific dependencies installation step. --- .github/workflows/publish-to-auto-release.yml | 67 ++++++++++++++++--- 1 file changed, 57 insertions(+), 10 deletions(-) diff --git a/.github/workflows/publish-to-auto-release.yml b/.github/workflows/publish-to-auto-release.yml index 1e6bfcb..cff0bec 100644 --- a/.github/workflows/publish-to-auto-release.yml +++ b/.github/workflows/publish-to-auto-release.yml @@ -5,13 +5,8 @@ on: branches: - release/** -# This is the example from the readme. -# On each push to the `release` branch it will create or update a GitHub release, build your app, and upload the artifacts to the release. - jobs: - publish-tauri: - permissions: - contents: write + test-tauri: strategy: fail-fast: false matrix: @@ -50,13 +45,18 @@ jobs: - name: install frontend dependencies run: npm install # change this to npm, pnpm or bun depending on which one you use. - + + # If tagName and releaseId are omitted tauri-action will only build the app and won't try to upload any assets. - uses: tauri-apps/tauri-action@v0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: args: ${{ matrix.args }} + update-version: + needs: test-tauri + runs-on: ubuntu-latest + steps: - name: Extract version from branch name id: extract_version run: | @@ -66,9 +66,9 @@ jobs: exit 1 fi echo "VERSION=$VERSION" >> $GITHUB_ENV - + - name: Update version number - run: ./script/update_version $VERSION + run: ./script/update_version.sh $VERSION - name: Set up Git run: | @@ -85,6 +85,53 @@ jobs: with: github_token: ${{ secrets.GITHUB_TOKEN }} + publish-tauri: + needs: update-version + permissions: + contents: write + strategy: + fail-fast: false + matrix: + include: + - platform: "macos-latest" # for Arm based macs (M1 and above). + args: "--target aarch64-apple-darwin" + - platform: "macos-latest" # for Intel based macs. + args: "--target x86_64-apple-darwin" + - platform: "ubuntu-22.04" # for Tauri v1 you could replace this with ubuntu-20.04. + args: "" + - platform: "windows-latest" + args: "" + + runs-on: ${{ matrix.platform }} + steps: + - uses: actions/checkout@v4 + + - name: setup node + uses: actions/setup-node@v4 + with: + node-version-file: '.nvmrc' + + - name: install Rust stable + uses: dtolnay/rust-toolchain@stable + with: + # Those targets are only used on macos runners so it's in an `if` to slightly speed up windows and linux builds. + targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }} + + - name: install dependencies (ubuntu only) + if: matrix.platform == 'ubuntu-22.04' # This must match the platform value defined above. + run: | + sudo apt-get update + sudo apt-get install -y libwebkit2gtk-4.0-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf + + - name: install frontend dependencies + run: npm install # change this to npm, pnpm or bun depending on which one you use. + + - uses: tauri-apps/tauri-action@v0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + args: ${{ matrix.args }} + - uses: tauri-apps/tauri-action@v0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -94,4 +141,4 @@ jobs: releaseBody: "See the assets to download this version and install." releaseDraft: true prerelease: false - args: ${{ matrix.args }} \ No newline at end of file + args: ${{ matrix.args }}