-
Notifications
You must be signed in to change notification settings - Fork 14
156 lines (136 loc) · 6.53 KB
/
ci.yml
File metadata and controls
156 lines (136 loc) · 6.53 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
name: CI
on:
push:
pull_request:
release:
types: [released]
workflow_dispatch:
jobs:
build:
runs-on: windows-latest
steps:
- name: Download UT2004 Minimal
uses: actions/checkout@v4
with:
repository: Deaod/UT2004Minimal
path: UT2004/
ssh-key: ${{ secrets.UT2004_MINIMAL_DEPLOY }}
persist-credentials: false
- name: Determine Package Name
run: |
$ref = "${{ github.ref }}"
$repoName = "${{ github.event.repository.name }}"
$sha = "${{ github.sha }}"
$prever = (Get-Date -UFormat "%Y%m%d%H%M%S")
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
echo ("PREVIEW_VER=v"+$prever+"-"+$ref.SubString(11)) >> $env:GITHUB_ENV
}
- name: Checkout ${{ github.event.repository.name }}
uses: actions/checkout@v4
with:
path: UT2004/${{ env.PKG_NAME }}/
- name: Rename Localization Files
run: |
function Replace-PackageName-File {
param(
$File,
$SubDir,
$OldSuffix,
$NewSuffix
)
$OldName = $File.Name
$NewName = ($File.Name -replace ("${{ github.event.repository.name }}"+$OldSuffix),"${{ env.PKG_NAME }}.")
$NewItem = ("UT2004/${{ 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 }}"+$OldSuffix),("${{ env.PKG_NAME }}"+$NewSuffix)) >> $NewItem
}
Remove-Item $File
}
function Replace-PackageName {
param(
[string]$SubDir,
[string]$FilePattern,
[string]$OldSuffix,
[string]$NewSuffix
)
if (Test-Path -Path ("UT2004/${{ env.PKG_NAME }}"+$SubDir+$FilePattern)) {
Get-ChildItem ("UT2004/${{ env.PKG_NAME }}"+$SubDir+$FilePattern) | ForEach-Object {
Replace-PackageName-File $_ $SubDir $OldSuffix $NewSuffix
}
}
}
Replace-PackageName "/System/" "${{ github.event.repository.name }}.*" "\." "."
Replace-PackageName "/USrc/" "${{ github.event.repository.name }}.upkg" "\." "."
Replace-PackageName "/USrc/" "*.cmds" "" ""
- name: Create VersionInfo.uc
shell: cmd
run: |
set BUILD_DIR=UT2004/${{ env.PKG_NAME }}/
UT2004/${{ env.PKG_NAME }}/Build/CreateVersionInfo.bat ${{ github.event.repository.name }} ${{ env.PKG_VER }} ${{ env.PKG_NAME }}
- name: Build ${{ github.event.repository.name }}
run: "UT2004/${{ env.PKG_NAME }}/Build.bat noint nouz"
- name: Save Logs
uses: actions/upload-artifact@v4
with:
name: ucc-logs
path: |
UT2004/**/*.log
- name: Collect Release Files
run: |
if (Test-Path -Path "UT2004/${{ env.PKG_NAME }}/System" -PathType Container) { Copy-Item -Path "UT2004/${{ env.PKG_NAME }}/System" -Destination "Release/System" -Recurse -Force -Verbose }
if (Test-Path -Path "UT2004/${{ env.PKG_NAME }}/Docs" -PathType Container) { Copy-Item -Path "UT2004/${{ env.PKG_NAME }}/Docs" -Destination "Release/Docs" -Recurse -Force -Verbose }
if (Test-Path -Path "UT2004/${{ env.PKG_NAME }}/Help" -PathType Container) { Copy-Item -Path "UT2004/${{ env.PKG_NAME }}/Help" -Destination "Release/Help" -Recurse -Force -Verbose }
if (Test-Path -Path "UT2004/${{ env.PKG_NAME }}/LICENSE") { Copy-Item -Path "UT2004/${{ env.PKG_NAME }}/LICENSE" -Destination "Release" -Verbose }
if (Test-Path -Path "UT2004/${{ env.PKG_NAME }}/README.md") { Copy-Item -Path "UT2004/${{ env.PKG_NAME }}/README.md" -Destination "Release" -Verbose }
if (Test-Path -Path "UT2004/${{ env.PKG_NAME }}/Build/Dependencies" -PathType Container) {
Get-ChildItem "UT2004/${{ env.PKG_NAME }}/Build/Dependencies" | ForEach-Object {
$Dep = $_
if ((Test-Path $Dep -PathType Container) -and (-not (Test-Path -Path ($Dep.FullName+"/noinstall") -PathType Leaf))) {
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
- name: Create Release Asset
run: |
cd Release
7z a -tzip -- "${{ env.PKG_NAME }}.zip" *
- name: Attach Asset To Release
if: success() && github.event_name == 'release'
uses: shogo82148/actions-upload-release-asset@v1
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: Release/${{ env.PKG_NAME }}.zip
overwrite: true
- name: Create Pre-Release
if: success() && github.event_name == 'push'
uses: softprops/action-gh-release@v2
with:
name: ${{ github.event.repository.name }} ${{ env.PREVIEW_VER }}
prerelease: true
files: Release/${{ env.PKG_NAME }}.zip
tag_name: ${{ env.PREVIEW_VER }}