Skip to content

Commit 6bb1a74

Browse files
committed
First CI
1 parent 3db74e4 commit 6bb1a74

2 files changed

Lines changed: 147 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
6+
pull_request:
7+
8+
release:
9+
types: [released]
10+
11+
workflow_dispatch:
12+
13+
jobs:
14+
build:
15+
runs-on: windows-latest
16+
17+
steps:
18+
- name: Download UT2004 Minimal
19+
uses: actions/checkout@v4
20+
with:
21+
repository: Deaod/UT2004Minimal
22+
path: UT2004/
23+
ssh-key: ${{ secrets.UT2004_MINIMAL_KEY }}
24+
persist-credentials: false
25+
26+
- name: Determine Package Name
27+
run: |
28+
$ref = "${{ github.ref }}"
29+
$repoName = "${{ github.event.repository.name }}"
30+
$sha = "${{ github.sha }}"
31+
$prever = (Get-Date -UFormat "%Y%m%d%H%M%S")
32+
if ("${{ github.ref_type }}" -eq "tag") {
33+
echo ("PKG_NAME="+$repoName+"_"+$ref.SubString(10)) >> $env:GITHUB_ENV
34+
echo ("PKG_VER="+$ref.SubString(10)) >> $env:GITHUB_ENV
35+
} elseif ($ref.StartsWith("refs/pull/")) {
36+
echo ("PKG_NAME="+$repoName+"_pr_"+$ref.SubString(10, $ref.Length - 16)) >> $env:GITHUB_ENV
37+
echo ("PKG_VER=pr_"+$ref.SubString(10, $ref.Length - 16)) >> $env:GITHUB_ENV
38+
} else {
39+
echo ("PKG_NAME="+$repoName+"_"+$ref.SubString(11)+"-"+$sha.SubString(0,8)) >> $env:GITHUB_ENV
40+
echo ("PKG_VER="+$ref.SubString(11)+"-"+$sha.SubString(0,8)) >> $env:GITHUB_ENV
41+
echo ("PREVIEW_VER=v"+$prever+"-"+$ref.SubString(11)) >> $env:GITHUB_ENV
42+
}
43+
44+
- name: Checkout ${{ github.event.repository.name }}
45+
uses: actions/checkout@v4
46+
with:
47+
path: UT2004/${{ env.PKG_NAME }}/
48+
49+
- name: Rename Localization Files
50+
run: |
51+
function Replace-PackageName-File {
52+
param(
53+
$File,
54+
$SubDir
55+
)
56+
57+
$OldName = $File.Name
58+
$NewName = ($File.Name -replace "${{ github.event.repository.name }}\.","${{ env.PKG_NAME }}.")
59+
$NewItem = ("${{ env.PKG_NAME }}"+$SubDir+$NewName)
60+
Write-Output ($SubDir + $OldName + " -> " + $SubDir + $NewName)
61+
if (Test-Path -Path $NewItem) { Remove-Item $NewItem }
62+
(Get-Content -Path $File.FullName) | ForEach-Object {
63+
($_ -replace "${{ github.event.repository.name }}\.","${{ env.PKG_NAME }}.") >> $NewItem
64+
}
65+
Remove-Item $File
66+
}
67+
68+
function Replace-PackageName {
69+
param(
70+
[string]$SubDir,
71+
[string]$FilePattern
72+
)
73+
if (Test-Path -Path ("UT2004/${{ env.PKG_NAME }}"+$SubDir+$FilePattern)) {
74+
Get-ChildItem ("${{ env.PKG_NAME }}"+$SubDir+$FilePattern) | ForEach-Object {
75+
Replace-PackageName-File $_ $SubDir
76+
}
77+
}
78+
}
79+
80+
Replace-PackageName "/System/" "${{ github.event.repository.name }}.*"
81+
Replace-PackageName "/USrc/" "${{ github.event.repository.name }}.upkg"
82+
Replace-PackageName "/Classes/" "*.cmds"
83+
84+
- name: Create VersionInfo.uc
85+
shell: cmd
86+
run: |
87+
set BUILD_DIR=UT2004/${{ env.PKG_NAME }}/
88+
UT2004/${{ env.PKG_NAME }}/Build/CreateVersionInfo.bat ${{ github.event.repository.name }} ${{ env.PKG_VER }} ${{ env.PKG_NAME }}
89+
90+
- name: Build ${{ github.event.repository.name }}
91+
run: "UT2004/${{ env.PKG_NAME }}/Build.bat silent noint nouz verbose"
92+
93+
- name: Save make.log
94+
uses: actions/upload-artifact@v4
95+
with:
96+
name: ucc-output
97+
path: UT2004/${{ env.PKG_NAME }}/Build/Temp/make.log
98+
99+
- name: Collect Release Files
100+
run: |
101+
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 }
102+
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 }
103+
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 }
104+
if (Test-Path -Path "UT2004/${{ env.PKG_NAME }}/LICENSE") { Copy-Item -Path "UT2004/${{ env.PKG_NAME }}/LICENSE" -Destination "Release" -Verbose }
105+
if (Test-Path -Path "UT2004/${{ env.PKG_NAME }}/README.md") { Copy-Item -Path "UT2004/${{ env.PKG_NAME }}/README.md" -Destination "Release" -Verbose }
106+
if (Test-Path -Path "UT2004/${{ env.PKG_NAME }}/Build/Dependencies" -PathType Container) {
107+
Get-ChildItem "UT2004/${{ env.PKG_NAME }}/Build/Dependencies" | ForEach-Object {
108+
$Dep = $_
109+
if (Test-Path $Dep -PathType Container) {
110+
Get-ChildItem $Dep | ForEach-Object {
111+
Copy-Item $_ -Destination "Release" -Recurse -Force -Verbose
112+
}
113+
}
114+
}
115+
}
116+
117+
- name: Save ${{ github.event.repository.name }} Package
118+
uses: actions/upload-artifact@v4
119+
with:
120+
name: "${{ env.PKG_NAME }}"
121+
path: |
122+
Release/**/*
123+
Release/*
124+
!Release/**/*.uz
125+
126+
- name: Create Release Asset
127+
run: |
128+
cd Release
129+
7z a -tzip -- "${{ env.PKG_NAME }}.zip" *
130+
131+
- name: Attach Asset To Release
132+
if: success() && github.event_name == 'release'
133+
uses: shogo82148/actions-upload-release-asset@v1
134+
with:
135+
upload_url: ${{ github.event.release.upload_url }}
136+
asset_path: Release/${{ env.PKG_NAME }}.zip
137+
overwrite: true
138+
139+
- name: Create Pre-Release
140+
if: success() && github.event_name == 'push'
141+
uses: softprops/action-gh-release@v2
142+
with:
143+
name: VoteSys ${{ env.PREVIEW_VER }}
144+
prerelease: true
145+
files: Release/${{ env.PKG_NAME }}.zip
146+
tag_name: ${{ env.PREVIEW_VER }}

build.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ call :SetPackageName "%BUILD_DIR%."
121121
call "%~dp0BuildSettings.bat"
122122

123123
set BUILD_TEMP=%BUILD_DIR%Build\Temp\
124-
mkdir %BUILD_TEMP%
124+
if not exist "%BUILD_TEMP%" mkdir "%BUILD_TEMP%"
125125

126126
if %VERBOSE% GEQ 1 (
127127
echo PACKAGE_NAME=%PACKAGE_NAME%

0 commit comments

Comments
 (0)