Skip to content

Commit d86e9e8

Browse files
authored
feat: add publish workflow template (#23)
* feat: add publish workflow template * feat: use oldest runner and add arm64 builds * fix: remove quotes for `--config` argument This causes `'--config="xxx"'` to be passed to `tauri-cli`, which `tauri-cli` cannot handle * docs: changelog * fix: use `--target foo` instead of `--target=bar` for `tauri-action` see <tauri-apps/tauri-action#1135 (comment)>
1 parent 59570c8 commit d86e9e8

File tree

2 files changed

+173
-0
lines changed

2 files changed

+173
-0
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2222

2323
## [Unreleased]
2424

25+
### Highlights
26+
27+
#### GitHub Publication Workflow Template
28+
29+
> - [#23](https://github.com/pytauri/create-pytauri-app/pull/23) - feat: add publish workflow template.
30+
31+
We've added `.github/workflows/publish.yaml` to the template to help you publish your application on GitHub Actions.
32+
This workflow is triggered every time you push to the `release` branch, or you can also trigger it manually.
33+
Alternatively, you can modify it to suit your workflow.
34+
2535
### Fixed
2636

2737
- [#22](https://github.com/pytauri/create-pytauri-app/pull/22) - fix(svelte): fix incorrect `frontendDist` path in svelte template.
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
# See:
2+
# - <https://github.com/tauri-apps/tauri-action>
3+
# - <https://pytauri.github.io/pytauri/latest/usage/tutorial/build-standalone/>
4+
5+
name: "publish"
6+
7+
on:
8+
# Manual trigger
9+
workflow_dispatch:
10+
# On push to `release` branch
11+
push:
12+
branches:
13+
- release
14+
15+
defaults:
16+
run:
17+
shell: bash
18+
19+
jobs:
20+
publish-tauri:
21+
permissions:
22+
contents: write # required for creating github releases
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
include:
27+
- platform: "macos-14" # for Intel based macs.
28+
target: "x86_64-apple-darwin"
29+
- platform: "macos-14" # for Arm based macs (M1 and above).
30+
target: "aarch64-apple-darwin"
31+
- platform: "ubuntu-22.04"
32+
target: "x86_64-unknown-linux-gnu"
33+
- platform: "ubuntu-22.04-arm"
34+
target: "aarch64-unknown-linux-gnu"
35+
- platform: "windows-2022"
36+
target: "x86_64-pc-windows-msvc"
37+
- platform: "windows-11-arm"
38+
target: "aarch64-pc-windows-msvc"
39+
40+
runs-on: {% raw %}${{ matrix.platform }}{% endraw %}
41+
steps:
42+
- uses: actions/checkout@v4
43+
44+
- name: Install system dependencies (ubuntu only)
45+
if: runner.os == 'Linux'
46+
run: |
47+
sudo apt-get update
48+
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
49+
50+
- name: Install Rust stable
51+
uses: dtolnay/rust-toolchain@stable
52+
with:
53+
targets: {% raw %}${{ matrix.target }}{% endraw %}
54+
- name: Rust cache
55+
uses: swatinem/rust-cache@v2
56+
57+
- name: Install uv
58+
uses: astral-sh/setup-uv@v6
59+
with:
60+
enable-cache: true
61+
# version-file: "pyproject.toml"
62+
63+
- name: Install pnpm
64+
uses: pnpm/action-setup@v4
65+
with:
66+
# Optional: when there is a `packageManager` field in the `package.json`
67+
version: "latest"
68+
- name: Install Node.js
69+
uses: actions/setup-node@v4
70+
with:
71+
# Or: `node-version-file: package.json`
72+
node-version: lts/*
73+
cache: "pnpm"
74+
75+
- name: Install project dependencies
76+
run: |
77+
pnpm install
78+
79+
# See:
80+
# - <https://github.com/astral-sh/python-build-standalone/releases>
81+
# - <https://raw.githubusercontent.com/astral-sh/python-build-standalone/latest-release/latest-release.json>
82+
# - <https://gregoryszorc.com/docs/python-build-standalone/main/running.html#obtaining-distributions>
83+
- name: Download python-build-standalone
84+
env:
85+
PYTHON_VERSION: "3.13.7" # update this by yourself
86+
TAG: "20250828" # update this by yourself
87+
TARGET: {% raw %}${{ matrix.target }}{% endraw %}
88+
{% raw -%}
89+
run: |
90+
url="https://github.com/astral-sh/python-build-standalone/releases/download/${TAG}/cpython-${PYTHON_VERSION}+${TAG}-${TARGET}-install_only_stripped.tar.gz"
91+
DEST_DIR="src-tauri/pyembed"
92+
93+
mkdir "$DEST_DIR"
94+
curl -L "$url" | tar -xz -C "$DEST_DIR"
95+
96+
# ref: <https://github.com/pytauri/pytauri/issues/99#issuecomment-2704556726>
97+
if [[ "${{ runner.os }}" == "macOS" ]]; then
98+
python_major_minor="${PYTHON_VERSION%.*}" # "3.13.7" -> "3.13"
99+
install_name_tool -id "@rpath/libpython${python_major_minor}.dylib" "$DEST_DIR/python/lib/libpython${python_major_minor}.dylib"
100+
fi
101+
{%- endraw %}
102+
103+
- name: Install the project into the embedded python environment
104+
env:
105+
PYTAURI_STANDALONE: 1 # see your `setup.py`
106+
PYTHON_PATH: {% raw %}${{ runner.os == 'Windows' && './src-tauri/pyembed/python/python.exe' || './src-tauri/pyembed/python/bin/python3' }}{% endraw %}
107+
{% raw -%}
108+
run: |
109+
uv pip install \
110+
--exact \
111+
--compile-bytecode \
112+
--python=${{ env.PYTHON_PATH }} \
113+
./src-tauri
114+
{%- endraw %}
115+
116+
# Set build environment variables, see:
117+
# <https://pytauri.github.io/pytauri/latest/usage/tutorial/build-standalone/#build-and-bundle>
118+
119+
- name: Set build environment variables (windows)
120+
if: runner.os == 'Windows'
121+
shell: pwsh
122+
run: |
123+
$PYO3_PYTHON = (Resolve-Path -LiteralPath ".\src-tauri\pyembed\python\python.exe").Path
124+
echo "PYO3_PYTHON=$PYO3_PYTHON" >> $env:GITHUB_ENV
125+
126+
- name: Set build environment variables (linux)
127+
if: runner.os == 'Linux'
128+
shell: bash
129+
env:
130+
# `{{ project_name }}` is your app `productName` in `tauri.conf.json`
131+
PRODUCT_NAME: "{{ project_name }}"
132+
run: |
133+
PYO3_PYTHON=$(realpath ./src-tauri/pyembed/python/bin/python3)
134+
RUSTFLAGS=" \
135+
-C link-arg=-Wl,-rpath,\$ORIGIN/../lib/$PRODUCT_NAME/lib \
136+
-L $(realpath ./src-tauri/pyembed/python/lib)"
137+
138+
echo "PYO3_PYTHON=$PYO3_PYTHON" >> $GITHUB_ENV
139+
echo "RUSTFLAGS=$RUSTFLAGS" >> $GITHUB_ENV
140+
141+
- name: Set build environment variables (macos)
142+
if: runner.os == 'macOS'
143+
shell: bash
144+
run: |
145+
PYO3_PYTHON=$(realpath ./src-tauri/pyembed/python/bin/python3)
146+
RUSTFLAGS=" \
147+
-C link-arg=-Wl,-rpath,@executable_path/../Resources/lib \
148+
-L $(realpath ./src-tauri/pyembed/python/lib)"
149+
150+
echo "PYO3_PYTHON=$PYO3_PYTHON" >> $GITHUB_ENV
151+
echo "RUSTFLAGS=$RUSTFLAGS" >> $GITHUB_ENV
152+
153+
- name: Build and bundle the app
154+
uses: tauri-apps/tauri-action@v0
155+
env:
156+
GITHUB_TOKEN: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
157+
with:
158+
tagName: app-v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version.
159+
releaseName: "App v__VERSION__"
160+
releaseBody: "See the assets to download this version and install."
161+
releaseDraft: true
162+
includeDebug: true # Optional, disable to speed up the build
163+
args: {% raw %}'--target ${{ matrix.target }} --config src-tauri/tauri.bundle.json --verbose'{% endraw %}

0 commit comments

Comments
 (0)