-
Notifications
You must be signed in to change notification settings - Fork 0
91 lines (75 loc) · 3.23 KB
/
main1.yml
File metadata and controls
91 lines (75 loc) · 3.23 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
name: Generate Flatpak Node Sources (generated-sources.json)
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
jobs:
generate-sources:
runs-on: ubuntu-24.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install flatpak-node-generator via pipx
run: |
python3 -m pip install --user pipx
python3 -m pipx ensurepath
pipx install flatpak-node-generator
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Generate or update package-lock.json (v1 format)
run: npm install --package-lock-only --ignore-scripts --lockfile-version=2
# ────────────────────────────────────────────────────────────────
# 关键步骤:将 lockfile 中的所有 git+ssh 替换为 https
# ────────────────────────────────────────────────────────────────
- name: Convert git+ssh to https in package-lock.json
run: |
# 备份原始文件
cp package-lock.json package-lock.json.bak
# 替换 git+ssh://git@github.com/... → https://github.com/...
sed -i 's|git+ssh://git@github.com/|https://github.com/|g' package-lock.json
# 替换 git@github.com:... → https://github.com/...
sed -i 's|git@github.com:|https://github.com/|g' package-lock.json
# 可选:移除 resolved 中的 ssh 部分(如果还有残留)
sed -i 's|^.*"resolved": "git+ssh://.*$| "resolved": "https://github.com${BASH_REMATCH[1]}",|g' package-lock.json || true
# 显示变更(方便 debug)
echo "Changes made to package-lock.json:"
git diff --color=always package-lock.json.bak package-lock.json || true
- name: Remove node_modules (safety)
run: rm -rf node_modules || true
- name: Generate generated-sources.json
run: |
flatpak-node-generator npm package-lock.json --electron --electron-ffmpeg=archive --electron-node-headers --output generated-sources.json
- name: Upload generated-sources.json
uses: actions/upload-artifact@v4
with:
name: flatpak-sources
path: generated-sources.json
if-no-files-found: error
retention-days: 14
- name: Upload modified package-lock.json and related files
uses: actions/upload-artifact@v4
with:
name: flatpak-related-files
path: |
package-lock.json
package.json
generated-sources.json
if-no-files-found: warn
retention-days: 7
- name: Upload logs & backup on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: failure-logs-and-backup
path: |
package-lock.json.bak
npm-debug.log
**/*.log
retention-days: 3