Skip to content

Release

Release #16

Workflow file for this run

name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: "Existing git tag to release (e.g. v0.5.0)"
required: true
type: string
permissions:
contents: write
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- platform: windows-latest
args: "--bundles nsis,msi"
- platform: macos-latest
args: "--target universal-apple-darwin --bundles app,dmg,updater"
- platform: ubuntu-latest
args: ""
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Resolve release tag
id: release_tag
shell: bash
run: |
if [ "${{ github.event_name }}" = "push" ]; then
TAG="${GITHUB_REF_NAME}"
else
TAG="${{ inputs.tag }}"
fi
if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+([-.][0-9A-Za-z.]+)?$ ]]; then
echo "Invalid tag format: $TAG"
echo "Expected format like v0.5.0"
exit 1
fi
git fetch --tags --force
if ! git rev-parse -q --verify "refs/tags/$TAG" >/dev/null; then
echo "Tag not found: $TAG"
echo "Create/push the tag first, then re-run release."
exit 1
fi
echo "version=$TAG" >> "$GITHUB_OUTPUT"
# ── macOS: universal binary needs both targets ──────────────────────────
- name: Add macOS targets
if: matrix.platform == 'macos-latest'
run: |
rustup target add aarch64-apple-darwin
rustup target add x86_64-apple-darwin
# ── Node.js ─────────────────────────────────────────────────────────────
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Install frontend dependencies
run: npm ci
- name: Extract release notes from CHANGELOG.md
id: changelog
shell: bash
run: |
VERSION_NO_V="${{ steps.release_tag.outputs.version }}"
VERSION_NO_V="${VERSION_NO_V#v}"
SECTION=$(awk -v version="$VERSION_NO_V" '
$0 ~ "^## \\[" version "\\]" { in_section=1; next }
in_section && $0 ~ /^## \[/ { exit }
in_section { print }
' CHANGELOG.md)
MACOS_NOTE="\n\n---\n\n### 🚩 macOS 无签名运行说明\n\n**首次打开如遇“无法验证开发者”或“已损坏”提示,请右键 App → 打开,或在终端执行:**\n\n\n xattr -dr com.apple.quarantine /Applications/TimeLens.app\n\n**如仍无法运行,请在“系统设置 → 隐私与安全性”中允许此 App。**\n"
if [ -z "$SECTION" ]; then
echo "notes=No changelog entry found for version ${VERSION_NO_V}.${MACOS_NOTE}" >> "$GITHUB_OUTPUT"
else
{
echo "notes<<EOF"
printf '%s\n' "$SECTION"
printf '%b' "$MACOS_NOTE"
echo "EOF"
} >> "$GITHUB_OUTPUT"
fi
# ── Rust ────────────────────────────────────────────────────────────────
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust
uses: Swatinem/rust-cache@v2
with:
workspaces: src-tauri
# ── Linux system libs (required by glib-sys, gtk, webkit2gtk) ─────────────
- name: Install Linux dependencies
if: matrix.platform == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y \
libwebkit2gtk-4.1-dev \
libgtk-3-dev \
libayatana-appindicator3-dev \
librsvg2-dev \
libglib2.0-dev \
pkg-config
# ── Build & publish ──────────────────────────────────────────────────────
- name: Build and release
uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
with:
tagName: ${{ steps.release_tag.outputs.version }}
releaseName: "TimeLens ${{ steps.release_tag.outputs.version }}"
releaseBody: ${{ steps.changelog.outputs.notes }}
releaseDraft: false
prerelease: false
args: ${{ matrix.args }}