Merge branch 'main' of https://github.com/02engine/desktop #63
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |