publish (standalone) #11
Workflow file for this run
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
# See: | |
# - <https://github.com/tauri-apps/tauri-action> | |
# - <https://pytauri.github.io/pytauri/latest/usage/tutorial/build-standalone/> | |
name: 'publish (standalone)' | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- release | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
publish-tauri: | |
permissions: | |
contents: write # required for creating github releases | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- platform: 'macos-latest' # for Arm based macs (M1 and above). | |
target: 'aarch64-apple-darwin' | |
- platform: 'macos-latest' # for Intel based macs. | |
target: 'x86_64-apple-darwin' | |
- platform: 'ubuntu-22.04' | |
target: 'x86_64-unknown-linux-gnu' | |
- platform: 'windows-latest' | |
target: 'x86_64-pc-windows-msvc' | |
runs-on: ${{ matrix.platform }} | |
steps: | |
- uses: actions/checkout@v4 | |
- 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.1-dev libappindicator3-dev librsvg2-dev patchelf | |
- 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: Rust cache | |
uses: swatinem/rust-cache@v2 | |
- name: Install uv | |
uses: astral-sh/setup-uv@v5 | |
with: | |
enable-cache: true | |
# see: | |
# - <https://github.com/astral-sh/python-build-standalone/releases> | |
# - <https://raw.githubusercontent.com/astral-sh/python-build-standalone/latest-release/latest-release.json> | |
# - <https://gregoryszorc.com/docs/python-build-standalone/main/running.html#obtaining-distributions> | |
- name: download python-build-standalone | |
env: | |
PYTHON_VERSION: '3.13.1' # update this by yourself | |
TAG: '20250115' # update this by yourself | |
TARGET: ${{ matrix.target }} | |
run: | | |
url="https://github.com/astral-sh/python-build-standalone/releases/download/${TAG}/cpython-${PYTHON_VERSION}+${TAG}-${TARGET}-install_only_stripped.tar.gz" | |
DEST_DIR="pyembed" | |
mkdir "$DEST_DIR" | |
curl -L "$url" | tar -xz -C "$DEST_DIR" | |
if [[ "${{ runner.os }}" == "macOS" ]]; then | |
python_major_minor="${PYTHON_VERSION%.*}" # "3.13.7" -> "3.13" | |
install_name_tool -id "@rpath/libpython${python_major_minor}.dylib" "$DEST_DIR/python/lib/libpython${python_major_minor}.dylib" | |
fi | |
- name: install your project into the embedded python environment | |
env: | |
PYTAURI_STANDALONE: 1 # see your `setup.py` | |
USE_CYTHON: 1 # see your `setup.py` | |
PYTHON_PATH: ${{ matrix.platform == 'windows-latest' && './pyembed/python/python.exe' || './pyembed/python/bin/python3' }} | |
run: | | |
uv pip install \ | |
--exact \ | |
--compile-bytecode \ | |
--python=${PYTHON_PATH} \ | |
. | |
- name: set build environment variables (windows) | |
if: matrix.platform == 'windows-latest' | |
shell: powershell | |
run: | | |
$PYO3_PYTHON = (Resolve-Path -LiteralPath ".\pyembed\python\python.exe").Path | |
echo "PYO3_PYTHON=$PYO3_PYTHON" >> $env:GITHUB_ENV | |
- name: set build environment variables (linux) | |
if: matrix.platform == 'ubuntu-22.04' | |
shell: bash | |
env: | |
# `nicegui-app` is your app `productName` in `tauri.conf.json` | |
PROJECT_NAME: 'nicegui-app' | |
run: | | |
export PYO3_PYTHON=$(realpath ./pyembed/python/bin/python3) | |
export RUSTFLAGS=" \ | |
-C link-arg=-Wl,-rpath,\$ORIGIN/../lib/${PROJECT_NAME}/lib \ | |
-L $(realpath ./pyembed/python/lib)" | |
echo "PYO3_PYTHON=$PYO3_PYTHON" >> $GITHUB_ENV | |
echo "RUSTFLAGS=$RUSTFLAGS" >> $GITHUB_ENV | |
- name: set build environment variables (macos) | |
if: matrix.platform == 'macos-latest' | |
shell: bash | |
run: | | |
export PYO3_PYTHON=$(realpath ./pyembed/python/bin/python3) | |
export RUSTFLAGS=" \ | |
-C link-arg=-Wl,-rpath,@executable_path/../Resources/lib \ | |
-L $(realpath ./pyembed/python/lib)" | |
echo "PYO3_PYTHON=$PYO3_PYTHON" >> $GITHUB_ENV | |
echo "RUSTFLAGS=$RUSTFLAGS" >> $GITHUB_ENV | |
- name: Build and bundle the app | |
uses: tauri-apps/tauri-action@v0 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tagName: app-v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version. | |
releaseName: 'App v__VERSION__' | |
releaseBody: 'See the assets to download this version and install.' | |
releaseDraft: true | |
prerelease: false | |
args: '--target ${{ matrix.target }} --config tauri.bundle.json --verbose' | |
includeDebug: true |