-
Notifications
You must be signed in to change notification settings - Fork 0
129 lines (109 loc) · 4.51 KB
/
Copy pathrelease.yml
File metadata and controls
129 lines (109 loc) · 4.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
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: ""
- platform: macos-latest
args: "--target universal-apple-darwin"
- 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 (not used here but keep for potential future runs) ──
# ── 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 }}