forked from utspect/InstaGibPlus
-
Notifications
You must be signed in to change notification settings - Fork 6
178 lines (150 loc) · 6.41 KB
/
ci.yml
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
172
173
174
175
176
177
name: CI
on:
push:
pull_request:
release:
types: [published]
workflow_dispatch:
jobs:
build:
runs-on: windows-latest
steps:
- name: Download 469d Patch
uses: robinraju/release-downloader@v1.9
with:
repository: "OldUnreal/UnrealTournamentPatches"
tag: "v469d"
fileName: "OldUnreal-UTPatch469d-Windows.zip"
- name: Extract Patch
run: 7z x "OldUnreal-UTPatch469d-Windows.zip"
- name: Determine Package Name
run: |
$ref = "${{ github.ref }}"
$repoName = "${{ github.event.repository.name }}"
$sha = "${{ github.sha }}"
if ("${{ github.ref_type }}" -eq "tag") {
echo ("PKG_NAME="+$repoName+"_"+$ref.SubString(10)) >> $env:GITHUB_ENV
echo ("PKG_VER="+$ref.SubString(10)) >> $env:GITHUB_ENV
} elseif ($ref.StartsWith("refs/pull/")) {
echo ("PKG_NAME="+$repoName+"_pr_"+$ref.SubString(10, $ref.Length - 16)) >> $env:GITHUB_ENV
echo ("PKG_VER=pr_"+$ref.SubString(10, $ref.Length - 16)) >> $env:GITHUB_ENV
} else {
echo ("PKG_NAME="+$repoName+"_"+$ref.SubString(11)+"-"+$sha.SubString(0,8)) >> $env:GITHUB_ENV
echo ("PKG_VER="+$ref.SubString(11)+"-"+$sha.SubString(0,8)) >> $env:GITHUB_ENV
}
- name: Save Package Name In File
run: echo ("${{ env.PKG_NAME }}") >> PackageName
- name: Create Package Name Artifact
uses: actions/upload-artifact@v4
with:
name: PackageName
path: PackageName
retention-days: 1
if-no-files-found: error
- name: Checkout ${{ github.event.repository.name }}
uses: actions/checkout@v4
with:
path: ${{ env.PKG_NAME }}/
- name: Rename + Update Files
run: |
function Replace-PackageName-File {
param(
$File,
$SubDir
)
$OldName = $File.Name
$NewName = ($File.Name -replace "${{ github.event.repository.name }}\.","${{ env.PKG_NAME }}.")
$NewItem = ("${{ env.PKG_NAME }}"+$SubDir+$NewName)
if ($OldName -eq $NewName) {
Rename-Item -Path $File.FullName -NewName ($File.FullName+".bak")
$File = (Get-Item ($File.FullName+".bak"))
} else {
Write-Output ($SubDir + $OldName + " -> " + $SubDir + $NewName)
if (Test-Path -Path $NewItem) { Remove-Item $NewItem }
}
(Get-Content -Path $File.FullName) | ForEach-Object {
($_ -replace "${{ github.event.repository.name }}\.","${{ env.PKG_NAME }}.") >> $NewItem
}
Remove-Item $File
}
function Replace-PackageName {
param(
[string]$SubDir,
[string]$FilePattern
)
if (Test-Path -Path ("${{ env.PKG_NAME }}"+$SubDir+$FilePattern)) {
Get-ChildItem ("${{ env.PKG_NAME }}"+$SubDir+$FilePattern) | ForEach-Object {
Replace-PackageName-File $_ $SubDir
}
}
}
Replace-PackageName "/System/" "${{ github.event.repository.name }}.*"
Replace-PackageName "/System/" "ACEFileList-${{ github.event.repository.name }}.*"
Replace-PackageName "/System/" "ACETweakList-${{ github.event.repository.name }}.*"
Replace-PackageName "/Classes/" "${{ github.event.repository.name }}.upkg"
Replace-PackageName "/Classes/" "*.uc"
- name: Extract Necessary Resources
run: 7z x "${{ env.PKG_NAME }}/Build/BuildEnv.zip"
- name: Create VersionInfo.uc
shell: cmd
run: |
set BUILD_DIR=${{ env.PKG_NAME }}/
${{ env.PKG_NAME }}/Build/CreateVersionInfo.bat ${{ github.event.repository.name }} ${{ env.PKG_VER }} ${{ env.PKG_NAME }}
- name: Build ${{ github.event.repository.name }}
run: "${{ env.PKG_NAME }}/Build.bat silent noint nouz verbose"
- name: Save UCC.log
if: failure()
uses: actions/upload-artifact@v4
with:
name: ucc-output
path: System/UCC.log
- name: Collect Release Files
run: |
if (Test-Path -Path "${{ env.PKG_NAME }}/System" -PathType Container) { Copy-Item -Path "${{ env.PKG_NAME }}/System" -Destination "Release/System" -Recurse -Force -Verbose }
if (Test-Path -Path "${{ env.PKG_NAME }}/Docs" -PathType Container) { Copy-Item -Path "${{ env.PKG_NAME }}/Docs" -Destination "Release/Docs" -Recurse -Force -Verbose }
if (Test-Path -Path "${{ env.PKG_NAME }}/LICENSE") { Copy-Item -Path "${{ env.PKG_NAME }}/LICENSE" -Destination "Release" -Verbose }
if (Test-Path -Path "${{ env.PKG_NAME }}/README.md") { Copy-Item -Path "${{ env.PKG_NAME }}/README.md" -Destination "Release" -Verbose }
if (Test-Path -Path "${{ env.PKG_NAME }}/Build/Dependencies" -PathType Container) {
Get-ChildItem "${{ env.PKG_NAME }}/Build/Dependencies" | ForEach-Object {
$Dep = $_
if (Test-Path $Dep -PathType Container) {
Get-ChildItem $Dep | ForEach-Object {
Copy-Item $_ -Destination "Release" -Recurse -Force -Verbose
}
}
}
}
- name: Save ${{ github.event.repository.name }} Package
uses: actions/upload-artifact@v4
with:
name: "${{ env.PKG_NAME }}"
path: |
Release/**/*
Release/*
!Release/**/*.uz
release:
runs-on: windows-latest
needs: build
if: ${{ github.event_name == 'release' }}
steps:
- name: Download Artifact
uses: actions/download-artifact@v4
with:
name: PackageName
- name: Restore Package Name
run: |
echo ("PKG_NAME=" + (Get-Content -Path "PackageName")) >> $env:GITHUB_ENV
Remove-Item -Path "PackageName"
- name: Download Artifact
uses: actions/download-artifact@v4
with:
name: ${{ env.PKG_NAME }}
- name: Create Release Asset
run: >
7z a -tzip -- "${{ env.PKG_NAME }}.zip" *
- name: Attach Asset To Release
uses: shogo82148/actions-upload-release-asset@v1
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ env.PKG_NAME }}.zip
overwrite: true