-
Notifications
You must be signed in to change notification settings - Fork 0
173 lines (154 loc) · 7.14 KB
/
Copy pathrelease.yml
File metadata and controls
173 lines (154 loc) · 7.14 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
name: Release
on:
push:
tags: ['v*'] # 例: v1.2.3
workflow_dispatch:
permissions:
contents: write
actions: read # Action ZIP を取るのに必須
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
# ──────────────────────────────────────────────────────────────
- platform: macos-latest
args: '--target universal-apple-darwin'
os: macos # ファイル名に入れる
arch: universal
ext: dmg
dir: dmg # 出力が入る bundle サブフォルダ
# ──────────────────────────────────────────────────────────────
- platform: ubuntu-22.04
args: ''
os: linux
arch: x86_64
ext: AppImage
dir: appimage
# ──────────────────────────────────────────────────────────────
- platform: windows-latest
args: ''
os: windows
arch: x86_64
ext: msi
dir: msi
# ──────────────────────────────────────────────────────────────
runs-on: ${{ matrix.platform }}
steps:
# 1) 取得 & セットアップ -------------------------------------------------
- uses: actions/checkout@v4
- if: matrix.platform == 'ubuntu-22.04'
name: Install Linux deps
run: |
sudo apt-get update
sudo apt-get install -y \
libgtk-3-dev libwebkit2gtk-4.0-dev libappindicator3-dev \
librsvg2-dev patchelf
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}
- uses: swatinem/rust-cache@v2
- uses: pnpm/action-setup@v4
with:
package_json_file: frontend/package.json
- uses: actions/setup-node@v4
with:
node-version: lts/*
cache: pnpm
cache-dependency-path: frontend/pnpm-lock.yaml
- name: Install frontend deps
working-directory: frontend
run: pnpm install --frozen-lockfile
# 2) ビルドのみ ---------------------------------------------------------
- id: tauri
uses: tauri-apps/tauri-action@v0.5.20 # ← 最新パッチ
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN || github.token }}
with:
projectPath: frontend
# ★ tagName / releaseName を渡さない=アップロードしない
args: ${{ matrix.args }}
# 3) タグ文字列から "v" を除いたバージョン番号を取得 -------------------
- id: ver
shell: bash
run: echo "ver=${GITHUB_REF_NAME#v}" >>"$GITHUB_OUTPUT"
# 4) リネーム + リリース作成/アップロード ------------------------------
- name: Rename & upload asset
shell: bash
env:
GH_TOKEN: ${{ secrets.GH_TOKEN || github.token }}
run: |
set -euo pipefail
TAG="${GITHUB_REF_NAME}" # 例: v1.2.3
VER="${TAG#v}" # → 1.2.3
OS="${{ matrix.os }}"
ARCH="${{ matrix.arch }}"
EXT="${{ matrix.ext }}"
DIR="${{ matrix.dir }}"
PROJECT_PATH="frontend" # ★ 実プロジェクトに合わせて
# 1) バンドル・ディレクトリを決定 ...............................
CANDIDATES=(
"${PROJECT_PATH}/src-tauri/target/universal-apple-darwin/release/bundle/${DIR}"
"${PROJECT_PATH}/src-tauri/target/release/bundle/${DIR}"
"src-tauri/target/universal-apple-darwin/release/bundle/${DIR}"
"src-tauri/target/release/bundle/${DIR}"
)
for p in "${CANDIDATES[@]}"; do
if [[ -d "${p}" ]]; then
BUNDLE_DIR="${p}"
break
fi
done
# 見つからなければ再帰検索
if [[ -z "${BUNDLE_DIR:-}" || ! -d "${BUNDLE_DIR}" ]]; then
BUNDLE_DIR=$(find "${PROJECT_PATH}/src-tauri/target" \
-type d -path "*/bundle/${DIR}" | head -n1 || true)
fi
if [[ -z "${BUNDLE_DIR}" || ! -d "${BUNDLE_DIR}" ]]; then
echo "::error :: No bundle directory found for ${DIR}"
exit 1
fi
# 2) 生成物ファイルを取得(AppImage / DMG / MSI など).............
FILE=$(find "${BUNDLE_DIR}" -maxdepth 1 -type f -name "*.${EXT}" | head -n1)
if [[ -z "${FILE}" ]]; then
echo "::error :: No bundle found in ${BUNDLE_DIR}"
exit 1
fi
# 3) 統一フォーマット名へリネーム .................................
NEW="CommandForgeEditor-v${VER}-${OS}-${ARCH}.${EXT}"
mv "${FILE}" "${NEW}"
# 4) ドラフトリリース作成 (既存ならスキップ) & 資産アップロード ....
if ! gh release view "${TAG}" &>/dev/null; then
gh release create "${TAG}" \
-t "CommandForgeEditor ${TAG}" \
-n "See the assets to download and install this version." \
--draft
fi
gh release upload "${TAG}" "${NEW}" --clobber
# ────────────────────────────────────────────────────────────────
# ★★ ここから追加 : 直接実行バイナリも探してアップロード
# ────────────────────────────────────────────────────────────────
exe_suffix=""
[[ "${OS}" == "windows" ]] && exe_suffix=".exe"
BIN_CANDIDATES=(
"${PROJECT_PATH}/src-tauri/target/universal-apple-darwin/release/CommandForgeEditor"
"${PROJECT_PATH}/src-tauri/target/${{ matrix.platform == 'macos-latest' && 'universal-apple-darwin' || 'release' }}/release/CommandForgeEditor${exe_suffix}"
"${PROJECT_PATH}/src-tauri/target/release/CommandForgeEditor${exe_suffix}"
"src-tauri/target/universal-apple-darwin/release/CommandForgeEditor"
"src-tauri/target/release/CommandForgeEditor${exe_suffix}"
)
for p in "${BIN_CANDIDATES[@]}"; do
if [[ -f "${p}" ]]; then
BIN_FILE="${p}"
break
fi
done
if [[ -n "${BIN_FILE:-}" && -f "${BIN_FILE}" ]]; then
RAW="CommandForgeEditor-v${VER}-${OS}-${ARCH}${exe_suffix}"
cp "${BIN_FILE}" "${RAW}" # 元を残したい場合は cp
gh release upload "${TAG}" "${RAW}" --clobber
echo "Uploaded raw binary: ${RAW}"
else
echo "No standalone binary found; skipped raw upload."
fi