-
Notifications
You must be signed in to change notification settings - Fork 231
96 lines (85 loc) · 3.6 KB
/
Copy pathbuild-running-resources.yml
File metadata and controls
96 lines (85 loc) · 3.6 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
name: Build Running Resources
on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches: [main]
jobs:
set-timestamp:
uses: ./.github/workflows/common-set-timestamp.yml
build-running-resources:
needs: set-timestamp
runs-on: windows-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
fetch-depth: 1
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
ref: ${{ github.head_ref || github.ref }}
- name: Install uv
shell: pwsh
run: |
Invoke-WebRequest -Uri https://astral.sh/uv/install.ps1 | Invoke-Expression
- name: Create and activate virtual environment
shell: pwsh
run: |
uv venv .venv --python=3.11.12
- name: Install dependencies
shell: pwsh
run: |
.\.venv\Scripts\Activate.ps1
uv sync --group dev
- name: Build files
shell: pwsh
run: |
chcp 65001
$OutputEncoding = [System.Text.Encoding]::UTF8
[Console]::InputEncoding = [System.Text.Encoding]::UTF8
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
.\.venv\Scripts\Activate.ps1
uv run python src/one_dragon/devtools/compile_po.py
uv run python src/zzz_od/auto_battle/build_utils.py
uv run python deploy/generate_module_manifest.py
env:
PYTHONPATH: src
- name: Check for changes
id: changes
shell: pwsh
run: |
$trackedChanges = @(git diff --name-only --ignore-cr-at-eol -- config/auto_battle/ assets/text/output/ deploy/module_manifest.py)
$untrackedChanges = @(git ls-files --others --exclude-standard -- config/auto_battle/ assets/text/output/ deploy/module_manifest.py)
$changes = @($trackedChanges + $untrackedChanges) | Where-Object { $_ }
Add-Content -Path $env:GITHUB_OUTPUT -Value "changed=$(([bool]$changes).ToString().ToLowerInvariant())"
Add-Content -Path $env:GITHUB_OUTPUT -Value "files<<EOF"
$changes | Add-Content -Path $env:GITHUB_OUTPUT
Add-Content -Path $env:GITHUB_OUTPUT -Value "EOF"
- name: Push changes
if: (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && steps.changes.outputs.changed == 'true'
uses: actions-js/push@v1.5
with:
rebase: true
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.head_ref || github.ref_name }}
message: |
ci: 自动构建运行资源 ${{ needs.set-timestamp.outputs.build_timestamp }}
[skip ci]
- name: Check build artifacts (fork PR)
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository
shell: pwsh
env:
CHANGED: ${{ steps.changes.outputs.changed }}
CHANGED_FILES: ${{ steps.changes.outputs.files }}
run: |
if ($env:CHANGED -eq 'true') {
Write-Host "::error::构建产物未提交,请在本地运行以下命令后提交:"
Write-Host "::error:: uv run python src/one_dragon/devtools/compile_po.py"
Write-Host "::error:: uv run python src/zzz_od/auto_battle/build_utils.py"
Write-Host "::error:: uv run python deploy/generate_module_manifest.py"
Write-Host "变更文件:"
Write-Host $env:CHANGED_FILES
exit 1
}
Write-Host "构建产物已是最新"