Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Highlights

#### GitHub Publication Workflow Template

> - [#23](https://github.com/pytauri/create-pytauri-app/pull/23) - feat: add publish workflow template.

We've added `.github/workflows/publish.yaml` to the template to help you publish your application on GitHub Actions.
This workflow is triggered every time you push to the `release` branch, or you can also trigger it manually.
Alternatively, you can modify it to suit your workflow.

### Fixed

- [#22](https://github.com/pytauri/create-pytauri-app/pull/22) - fix(svelte): fix incorrect `frontendDist` path in svelte template.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
# See:
# - <https://github.com/tauri-apps/tauri-action>
# - <https://pytauri.github.io/pytauri/latest/usage/tutorial/build-standalone/>

name: "publish"

on:
# Manual trigger
workflow_dispatch:
# On push to `release` branch
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-14" # for Intel based macs.
target: "x86_64-apple-darwin"
- platform: "macos-14" # for Arm based macs (M1 and above).
target: "aarch64-apple-darwin"
- platform: "ubuntu-22.04"
target: "x86_64-unknown-linux-gnu"
- platform: "ubuntu-22.04-arm"
target: "aarch64-unknown-linux-gnu"
- platform: "windows-2022"
target: "x86_64-pc-windows-msvc"
- platform: "windows-11-arm"
target: "aarch64-pc-windows-msvc"

runs-on: {% raw %}${{ matrix.platform }}{% endraw %}
steps:
- uses: actions/checkout@v4

- name: Install system dependencies (ubuntu only)
if: runner.os == 'Linux'
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:
targets: {% raw %}${{ matrix.target }}{% endraw %}
- name: Rust cache
uses: swatinem/rust-cache@v2

- name: Install uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
# version-file: "pyproject.toml"

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
# Optional: when there is a `packageManager` field in the `package.json`
version: "latest"
- name: Install Node.js
uses: actions/setup-node@v4
with:
# Or: `node-version-file: package.json`
node-version: lts/*
cache: "pnpm"

- name: Install project dependencies
run: |
pnpm install

# 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.7" # update this by yourself
TAG: "20250828" # update this by yourself
TARGET: {% raw %}${{ matrix.target }}{% endraw %}
{% raw -%}
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="src-tauri/pyembed"

mkdir "$DEST_DIR"
curl -L "$url" | tar -xz -C "$DEST_DIR"

# ref: <https://github.com/pytauri/pytauri/issues/99#issuecomment-2704556726>
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
{%- endraw %}

- name: Install the project into the embedded python environment
env:
PYTAURI_STANDALONE: 1 # see your `setup.py`
PYTHON_PATH: {% raw %}${{ runner.os == 'Windows' && './src-tauri/pyembed/python/python.exe' || './src-tauri/pyembed/python/bin/python3' }}{% endraw %}
{% raw -%}
run: |
uv pip install \
--exact \
--compile-bytecode \
--python=${{ env.PYTHON_PATH }} \
./src-tauri
{%- endraw %}

# Set build environment variables, see:
# <https://pytauri.github.io/pytauri/latest/usage/tutorial/build-standalone/#build-and-bundle>

- name: Set build environment variables (windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$PYO3_PYTHON = (Resolve-Path -LiteralPath ".\src-tauri\pyembed\python\python.exe").Path
echo "PYO3_PYTHON=$PYO3_PYTHON" >> $env:GITHUB_ENV

- name: Set build environment variables (linux)
if: runner.os == 'Linux'
shell: bash
env:
# `{{ project_name }}` is your app `productName` in `tauri.conf.json`
PRODUCT_NAME: "{{ project_name }}"
run: |
PYO3_PYTHON=$(realpath ./src-tauri/pyembed/python/bin/python3)
RUSTFLAGS=" \
-C link-arg=-Wl,-rpath,\$ORIGIN/../lib/$PRODUCT_NAME/lib \
-L $(realpath ./src-tauri/pyembed/python/lib)"

echo "PYO3_PYTHON=$PYO3_PYTHON" >> $GITHUB_ENV
echo "RUSTFLAGS=$RUSTFLAGS" >> $GITHUB_ENV

- name: Set build environment variables (macos)
if: runner.os == 'macOS'
shell: bash
run: |
PYO3_PYTHON=$(realpath ./src-tauri/pyembed/python/bin/python3)
RUSTFLAGS=" \
-C link-arg=-Wl,-rpath,@executable_path/../Resources/lib \
-L $(realpath ./src-tauri/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: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
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
includeDebug: true # Optional, disable to speed up the build
args: {% raw %}'--target ${{ matrix.target }} --config src-tauri/tauri.bundle.json --verbose'{% endraw %}
Loading