chore: optimize ci to skip bump commits #8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: "Release" | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| bump-version: | |
| if: "!contains(github.event.head_commit.message, 'chore: bump version')" | |
| runs-on: ubuntu-latest | |
| outputs: | |
| new_tag: ${{ steps.tag_version.outputs.new_tag }} | |
| new_version: ${{ steps.tag_version.outputs.new_version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Bump version and push tag | |
| id: tag_version | |
| uses: mathieudutour/github-tag-action@v6.2 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| default_bump: patch | |
| dry_run: true | |
| - name: Update version in files | |
| run: | | |
| NEW_VERSION=${{ steps.tag_version.outputs.new_version }} | |
| echo "Updating files to version $NEW_VERSION" | |
| jq ".version = \"$NEW_VERSION\"" package.json > package.json.tmp && mv package.json.tmp package.json | |
| jq ".version = \"$NEW_VERSION\"" src-tauri/tauri.conf.json > tauri.conf.json.tmp && mv tauri.conf.json.tmp src-tauri/tauri.conf.json | |
| - name: Git Auto Commit | |
| uses: stefanzweifel/git-auto-commit-action@v5 | |
| with: | |
| commit_message: "chore: bump version to v${{ steps.tag_version.outputs.new_version }} [skip ci]" | |
| file_pattern: "package.json src-tauri/tauri.conf.json" | |
| tagging_message: "v${{ steps.tag_version.outputs.new_version }}" | |
| publish: | |
| needs: bump-version | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - platform: "macos-latest" | |
| args: "--target aarch64-apple-darwin" | |
| - platform: "macos-latest" | |
| args: "--target x86_64-apple-darwin" | |
| - platform: "ubuntu-22.04" | |
| args: "" | |
| - platform: "windows-latest" | |
| args: "" | |
| runs-on: ${{ matrix.platform }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ needs.bump-version.outputs.new_tag }} | |
| - name: setup node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: lts/* | |
| - name: install Rust stable | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }} | |
| - name: install dependencies (ubuntu only) | |
| if: matrix.platform == 'ubuntu-22.04' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf libssl-dev pkg-config | |
| - name: install frontend dependencies | |
| run: yarn install | |
| - uses: tauri-apps/tauri-action@v0 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tagName: ${{ needs.bump-version.outputs.new_tag }} | |
| releaseName: "App ${{ needs.bump-version.outputs.new_tag }}" | |
| releaseBody: "See the assets to download this version and install." | |
| releaseDraft: false | |
| prerelease: false | |
| args: ${{ matrix.args }} |