Skip to content

Commit

Permalink
Refactor GitHub Actions workflow to separate test and publish jobs
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
takanotume24 committed Dec 4, 2024
1 parent ad3e849 commit 0e33fcc
Showing 1 changed file with 57 additions and 10 deletions.
67 changes: 57 additions & 10 deletions .github/workflows/publish-to-auto-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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: |
Expand All @@ -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: |
Expand All @@ -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 }}
Expand All @@ -94,4 +141,4 @@ jobs:
releaseBody: "See the assets to download this version and install."
releaseDraft: true
prerelease: false
args: ${{ matrix.args }}
args: ${{ matrix.args }}

0 comments on commit 0e33fcc

Please sign in to comment.