Repository navigation
169 lines (146 loc) · 6.67 KB
/
Copy pathdeploy-web.yml
File metadata and controls
169 lines (146 loc) · 6.67 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
name: Deploy web to GitHub Pages
on:
push:
branches: [master]
paths:
- "src/**"
- "assets/**"
- "Cargo.toml"
- "Cargo.lock"
- "Dioxus.toml"
- "scripts/**"
- ".github/workflows/deploy-web.yml"
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
# 单部署队列:新提交覆盖进行中的旧构建
concurrency:
group: pages
cancel-in-progress: true
jobs:
# 测试先于构建:此前 deploy 无任何质量门(ci 红了也照发)——保"lint 不挡
# 部署"的原意,但正确性必须挡。测试是桌面 target(wasm32 无法在 runner 上
# 执行),故跑在 windows 上,与 ci.yml 的 test-desktop 同一套步骤。
test:
runs-on: windows-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install Rust toolchain (MSVC)
uses: dtolnay/rust-toolchain@6bed0761d98439e5a578e2877258200ad565ba87 # stable branch
- name: Cache cargo
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: test-desktop-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
restore-keys: |
test-desktop-${{ runner.os }}-
- name: Cache ffmpeg static libs
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
with:
path: ffmpeg-dist
key: ffmpeg-static-win-${{ hashFiles('scripts/fetch-ffmpeg-static.sh') }}
- name: Fetch prebuilt ffmpeg static libs
shell: bash
run: |
if [ ! -f ffmpeg-dist/lib/avcodec.lib ]; then
bash scripts/fetch-ffmpeg-static.sh
fi
echo "FFMPEG_DIR=$GITHUB_WORKSPACE/ffmpeg-dist" >> "$GITHUB_ENV"
- name: Test (desktop)
run: cargo test --locked
build:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install Rust toolchain (wasm32 target)
uses: dtolnay/rust-toolchain@6bed0761d98439e5a578e2877258200ad565ba87 # stable branch
with:
targets: wasm32-unknown-unknown
- name: Cache cargo registry (shared)
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
with:
path: |
~/.cargo/registry
~/.cargo/git
key: cargo-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
restore-keys: |
cargo-${{ runner.os }}-
# 只缓存构建输出;dx 每次按钉住的 tag + SHA-256 安装,不能被 restore key 复用。
- name: Cache build output
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
with:
path: target
key: web-${{ runner.os }}-dx0.7.10-${{ hashFiles('Cargo.lock') }}
restore-keys: |
web-${{ runner.os }}-dx0.7.10-
# dx CLI:GitHub Release 资产可变,固定 tag 仍不足以保证内容;每次下载
# 都校验 SHA-256,并断言实际版本,避免缓存或错误资产静默进入构建。
- name: Install dx CLI
run: |
curl -sSL -o dx.tgz \
https://github.com/dioxuslabs/dioxus/releases/download/v0.7.10/dx-x86_64-unknown-linux-gnu.tar.gz
echo "4363e4ed2a3f1eb7f4d38d2d59aed59ce43271c44c16b425e92c89a64761fbe7 dx.tgz" | sha256sum -c -
tar xzf dx.tgz -C ~/.cargo/bin
dx --version | grep -Fx "dioxus 0.7.10 (57d6794)"
# core 不入库(.gitignore);从 TheFunny/ffmpeg-core-st 的 Release 取回,
# 版本与 sha256 钉在 scripts/fetch-ffmpeg-core.sh(唯一出处)。
- name: Fetch ffmpeg core wasm
run: bash scripts/fetch-ffmpeg-core.sh
# dx 不透传 cargo 标志,先用 fetch --locked 卡住锁文件漂移
# (否则 manifest 与 Cargo.lock 不一致时会静默重解析,绕过评审)
- name: Verify lockfile
run: cargo fetch --locked
- name: Build web bundle (release)
run: dx build --platform web --release --base-path /StickerProcess/
# dx 不拷项目 assets/ 到产物目录(见 README/AGENTS.md)——手动补齐。
- name: Assemble Pages artifact
run: |
out=web-dist
mkdir -p "$out"
cp -r target/dx/StickerProcess/release/web/public/. "$out/"
cp assets/ffmpeg.js assets/814.ffmpeg.js assets/ffmpeg-core-st.js \
assets/ffmpeg-core-st.wasm assets/ffmpeg-engine.js \
assets/webcodecs-engine.js assets/webm-muxer.js assets/favicon.png \
assets/og-image.png "$out/"
cp "$out/index.html" "$out/404.html" # Pages 无 SPA fallback,404 兜底
# 分享爬虫(Discord/Telegram)不执行 JS——dx 0.7.10 不支持自定义 index
# 模板,构建后注入静态 description/OG 到 head(App rsx 的 document::Meta
# 管运行时/桌面,静态这份管爬虫;og:url/og:image 需绝对 URL 故放 CI)。
- name: Inject static head meta
run: |
python3 - web-dist/index.html web-dist/404.html <<'PY'
import sys, pathlib
meta = (
'<meta name="description" content="Convert images and videos into Telegram stickers — right in your browser, nothing uploaded.">\n'
' <meta property="og:title" content="Sticker Process">\n'
' <meta property="og:description" content="Image/video to Telegram sticker converter running fully client-side (WASM).">\n'
' <meta property="og:type" content="website">\n'
' <meta property="og:url" content="https://thefunny.github.io/StickerProcess/">\n'
' <meta property="og:image" content="https://thefunny.github.io/StickerProcess/og-image.png">'
)
for p in map(pathlib.Path, sys.argv[1:]):
s = p.read_text(encoding="utf-8")
p.write_text(s.replace("</head>", meta + "\n </head>", 1), encoding="utf-8")
PY
- name: Smoke test mounted web app
run: bash scripts/smoke-web.sh web-dist
- uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5.0.0
- uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1
with:
path: web-dist
# Pages 源 = workflow(build_type: workflow,Run 1 的 configure-pages 已切换)
deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.out.outputs.page_url }}
steps:
- id: out
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5