|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + tags: ['v*'] |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + tag: |
| 10 | + description: 'Tag to build (e.g., v0.1.0)' |
| 11 | + required: true |
| 12 | + |
| 13 | +env: |
| 14 | + CARGO_INCREMENTAL: 0 |
| 15 | + |
| 16 | +jobs: |
| 17 | + release: |
| 18 | + if: github.ref == 'refs/heads/main' |
| 19 | + runs-on: ubuntu-latest |
| 20 | + permissions: |
| 21 | + contents: write |
| 22 | + pull-requests: write |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@v4 |
| 25 | + with: |
| 26 | + fetch-depth: 0 |
| 27 | + |
| 28 | + - uses: pnpm/action-setup@v4 |
| 29 | + |
| 30 | + - uses: actions/setup-node@v4 |
| 31 | + with: |
| 32 | + node-version: 20 |
| 33 | + cache: pnpm |
| 34 | + |
| 35 | + - run: pnpm install |
| 36 | + |
| 37 | + - name: Create Release Pull Request |
| 38 | + id: changesets |
| 39 | + uses: changesets/action@v1 |
| 40 | + env: |
| 41 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 42 | + |
| 43 | + - name: Push tag if version changed |
| 44 | + if: steps.changesets.outputs.hasChangesets == 'false' |
| 45 | + shell: bash |
| 46 | + run: | |
| 47 | + VERSION=$(node -p "require('./package.json').version") |
| 48 | + if ! git ls-remote --tags origin | grep -q "refs/tags/v$VERSION$"; then |
| 49 | + git config user.name "github-actions[bot]" |
| 50 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 51 | + git tag "v$VERSION" |
| 52 | + git push origin "v$VERSION" |
| 53 | + echo "Pushed tag v$VERSION" |
| 54 | + else |
| 55 | + echo "Tag v$VERSION already exists" |
| 56 | + fi |
| 57 | +
|
| 58 | + build: |
| 59 | + if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch' |
| 60 | + strategy: |
| 61 | + fail-fast: false |
| 62 | + matrix: |
| 63 | + include: |
| 64 | + - os: ubuntu-24.04 |
| 65 | + target: x86_64-unknown-linux-gnu |
| 66 | + - os: macos-latest |
| 67 | + target: x86_64-apple-darwin |
| 68 | + - os: macos-latest |
| 69 | + target: aarch64-apple-darwin |
| 70 | + - os: windows-latest |
| 71 | + target: x86_64-pc-windows-msvc |
| 72 | + runs-on: ${{ matrix.os }} |
| 73 | + permissions: |
| 74 | + contents: write |
| 75 | + steps: |
| 76 | + - uses: actions/checkout@v4 |
| 77 | + with: |
| 78 | + ref: ${{ github.event.inputs.tag || github.ref }} |
| 79 | + |
| 80 | + - name: Install Linux dependencies |
| 81 | + if: runner.os == 'Linux' |
| 82 | + run: | |
| 83 | + sudo apt-get update |
| 84 | + sudo apt-get install -y \ |
| 85 | + libwebkit2gtk-4.1-dev \ |
| 86 | + libappindicator3-dev \ |
| 87 | + librsvg2-dev \ |
| 88 | + patchelf \ |
| 89 | + libpipewire-0.3-dev \ |
| 90 | + libgbm-dev \ |
| 91 | + libxcb1-dev \ |
| 92 | + libegl-dev |
| 93 | +
|
| 94 | + - uses: pnpm/action-setup@v4 |
| 95 | + |
| 96 | + - uses: actions/setup-node@v4 |
| 97 | + with: |
| 98 | + node-version: 20 |
| 99 | + cache: pnpm |
| 100 | + |
| 101 | + - uses: dtolnay/rust-toolchain@stable |
| 102 | + with: |
| 103 | + targets: ${{ matrix.target }} |
| 104 | + |
| 105 | + - uses: Swatinem/rust-cache@v2 |
| 106 | + with: |
| 107 | + workspaces: src-tauri |
| 108 | + |
| 109 | + - run: pnpm install |
| 110 | + |
| 111 | + - name: Get tag name |
| 112 | + id: tag |
| 113 | + shell: bash |
| 114 | + run: | |
| 115 | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then |
| 116 | + echo "name=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT |
| 117 | + else |
| 118 | + echo "name=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT |
| 119 | + fi |
| 120 | +
|
| 121 | + - uses: tauri-apps/tauri-action@v0 |
| 122 | + env: |
| 123 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 124 | + with: |
| 125 | + tagName: ${{ steps.tag.outputs.name }} |
| 126 | + releaseName: ${{ steps.tag.outputs.name }} |
| 127 | + releaseBody: "See [CHANGELOG](https://github.com/${{ github.repository }}/blob/main/CHANGELOG.md) for details." |
| 128 | + releaseDraft: false |
| 129 | + prerelease: false |
| 130 | + args: --target ${{ matrix.target }} |
0 commit comments