|
| 1 | +# See: |
| 2 | +# - <https://github.com/tauri-apps/tauri-action> |
| 3 | +# - <https://wsh032.github.io/pytauri/> |
| 4 | + |
| 5 | +name: 'publish (standalone)' |
| 6 | + |
| 7 | +on: |
| 8 | + workflow_dispatch: |
| 9 | + push: |
| 10 | + branches: |
| 11 | + - release |
| 12 | + |
| 13 | +defaults: |
| 14 | + run: |
| 15 | + shell: bash |
| 16 | + |
| 17 | +jobs: |
| 18 | + publish-tauri: |
| 19 | + permissions: |
| 20 | + contents: write |
| 21 | + strategy: |
| 22 | + fail-fast: false |
| 23 | + matrix: |
| 24 | + include: |
| 25 | + - platform: 'macos-latest' # for Arm based macs (M1 and above). |
| 26 | + target: 'aarch64-apple-darwin' |
| 27 | + - platform: 'macos-latest' # for Intel based macs. |
| 28 | + target: 'x86_64-apple-darwin' |
| 29 | + - platform: 'ubuntu-22.04' |
| 30 | + target: 'x86_64-unknown-linux-gnu' |
| 31 | + - platform: 'windows-latest' |
| 32 | + target: 'x86_64-pc-windows-msvc' |
| 33 | + |
| 34 | + runs-on: ${{ matrix.platform }} |
| 35 | + steps: |
| 36 | + - uses: actions/checkout@v4 |
| 37 | + |
| 38 | + - name: install dependencies (ubuntu only) |
| 39 | + if: matrix.platform == 'ubuntu-22.04' # This must match the platform value defined above. |
| 40 | + run: | |
| 41 | + sudo apt-get update |
| 42 | + sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf |
| 43 | +
|
| 44 | + - name: install Rust stable |
| 45 | + uses: dtolnay/rust-toolchain@stable |
| 46 | + with: |
| 47 | + # Those targets are only used on macos runners so it's in an `if` to slightly speed up windows and linux builds. |
| 48 | + targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }} |
| 49 | + |
| 50 | + - name: Rust cache |
| 51 | + uses: swatinem/rust-cache@v2 |
| 52 | + |
| 53 | + - name: Install uv |
| 54 | + uses: astral-sh/setup-uv@v5 |
| 55 | + with: |
| 56 | + enable-cache: true |
| 57 | + |
| 58 | + # see: |
| 59 | + # - <https://github.com/astral-sh/python-build-standalone/releases> |
| 60 | + # - <https://raw.githubusercontent.com/astral-sh/python-build-standalone/latest-release/latest-release.json> |
| 61 | + # - <https://gregoryszorc.com/docs/python-build-standalone/main/running.html#obtaining-distributions> |
| 62 | + - name: download python-build-standalone |
| 63 | + env: |
| 64 | + PYTHON_VERSION: '3.13.1' # update this by yourself |
| 65 | + DATE: '20250115' # update this by yourself |
| 66 | + TARGET: ${{ matrix.target }} |
| 67 | + run: | |
| 68 | + url="https://github.com/astral-sh/python-build-standalone/releases/download/${DATE}/cpython-${PYTHON_VERSION}+${DATE}-${TARGET}-install_only_stripped.tar.gz" |
| 69 | + mkdir -p ./pyembed |
| 70 | + curl -L $url | tar -xz -C ./pyembed |
| 71 | +
|
| 72 | + - name: install your project into the embedded python environment |
| 73 | + env: |
| 74 | + PYTAURI_STANDALONE: 1 # see your `setup.py` |
| 75 | + PYTHON_PATH: ${{ matrix.platform == 'windows-latest' && './pyembed/python/python.exe' || './pyembed/python/bin/python3' }} |
| 76 | + run: | |
| 77 | + uv pip install \ |
| 78 | + --exact \ |
| 79 | + --python=${PYTHON_PATH} \ |
| 80 | + . |
| 81 | +
|
| 82 | + - name: set build environment variables (windows) |
| 83 | + if: matrix.platform == 'windows-latest' |
| 84 | + shell: powershell |
| 85 | + run: | |
| 86 | + $PYO3_PYTHON = (Resolve-Path -LiteralPath ".\pyembed\python\python.exe").Path |
| 87 | + echo "PYO3_PYTHON=$PYO3_PYTHON" >> $env:GITHUB_ENV |
| 88 | +
|
| 89 | + - name: set build environment variables (linux) |
| 90 | + if: matrix.platform == 'ubuntu-22.04' |
| 91 | + shell: bash |
| 92 | + # `nicegui-app` is your app `productName` in `tauri.conf.json`. |
| 93 | + run: | |
| 94 | + export PYO3_PYTHON=$(realpath ./pyembed/python/bin/python3) |
| 95 | + export RUSTFLAGS=" \ |
| 96 | + -C link-arg=-Wl,-rpath,\$ORIGIN/../lib/nicegui-app/lib \ |
| 97 | + -L $(realpath ./pyembed/python/lib)" |
| 98 | +
|
| 99 | + echo "PYO3_PYTHON=$PYO3_PYTHON" >> $GITHUB_ENV |
| 100 | + echo "RUSTFLAGS=$RUSTFLAGS" >> $GITHUB_ENV |
| 101 | +
|
| 102 | + - name: set build environment variables (macos) |
| 103 | + if: matrix.platform == 'macos-latest' |
| 104 | + shell: bash |
| 105 | + run: | |
| 106 | + export PYO3_PYTHON=$(realpath ./pyembed/python/bin/python3) |
| 107 | + export RUSTFLAGS=" \ |
| 108 | + -C link-arg=-Wl,-rpath,@executable_path/../Resources/lib \ |
| 109 | + -L $(realpath ./pyembed/python/lib)" |
| 110 | + |
| 111 | + echo "PYO3_PYTHON=$PYO3_PYTHON" >> $GITHUB_ENV |
| 112 | + echo "RUSTFLAGS=$RUSTFLAGS" >> $GITHUB_ENV |
| 113 | +
|
| 114 | + - name: Build and bundle the app |
| 115 | + uses: tauri-apps/tauri-action@v0 |
| 116 | + env: |
| 117 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 118 | + with: |
| 119 | + tagName: app-v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version. |
| 120 | + releaseName: 'App v__VERSION__' |
| 121 | + releaseBody: 'See the assets to download this version and install.' |
| 122 | + releaseDraft: true |
| 123 | + prerelease: false |
| 124 | + args: '--target ${{ matrix.target }} --config tauri.bundle.json --verbose' |
| 125 | + includeDebug: true |
0 commit comments