Skip to content

Commit

Permalink
Create release ci build aki server on both linux and windows (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
qe201020335 authored Feb 20, 2024
1 parent 0ccd504 commit 36d7fd7
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 51 deletions.
59 changes: 10 additions & 49 deletions .github/workflows/Create-Release-with-SPT-AKI-Integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,77 +5,38 @@ name: Create Release with SPT-AKI Integration on Windows

jobs:
build:
strategy:
matrix:
os: [ "ubuntu-latest", "windows-latest" ]
permissions: write-all
name: Create Release
runs-on: windows-latest
runs-on: ${{ matrix.os }}
steps:
- name: Checkout SIT-Server-Mod Branch
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
ref: 'master'

- name: Set up Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '20.10.0'

- name: Install dependencies
run: npm ci

- name: Build SIT-Server-Mod
run: npm run build

- name: Read package.json
id: read_package_json
run: echo "::set-output name=version::$(node -e 'console.log(require(`./package.json`).version)')"

- name: Clone SPT-AKI Server
run: |
git clone -b 3.8.0 --single-branch https://dev.sp-tarkov.com/SPT-AKI/Server.git SPT-AKI-Server
cd SPT-AKI-Server
git lfs fetch
git lfs pull
- name: Build SPT-AKI Server
run: |
cd SPT-AKI-Server\project
npm install
npm run build:release
shell: pwsh

- name: Setup temporary directory for zipping
run: |
$tempPath = "tempZipContents"
New-Item -ItemType Directory -Force -Path $tempPath
New-Item -ItemType Directory -Force -Path "$tempPath\user\mods\SITCoop"
shell: pwsh

- name: Copy build contents to temporary directory
run: |
Copy-Item -Path "SPT-AKI-Server\project\build\*" -Destination "tempZipContents" -Recurse
shell: pwsh

- name: Copy SITCoop mod to temporary directory
run: |
Copy-Item -Path "SITCoop\*" -Destination "tempZipContents\user\mods\SITCoop" -Recurse
shell: pwsh

- name: Zip the temporary directory
run: |
Compress-Archive -Path "tempZipContents\*" -DestinationPath "SPT-AKI-with-SITCoop.zip" -Force
shell: pwsh

- name: Cleanup temporary directory
run: |
Remove-Item -Path "tempZipContents" -Recurse -Force
- name: Build Release Package
id: build
shell: pwsh
run: ./package_release_with_server.ps1 -Overwrite -Branch 3.8.0

- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.read_package_json.outputs.version }}
name: SPT-AKI-with-SITCoop-${{ github.run_number }}
files: SPT-AKI-with-SITCoop.zip
files: ${{ steps.build.outputs.ZIP_NAME }}
draft: true
prerelease: false
generate_release_notes: true
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@ SITConfig*.json
*.pem
mod.js
dist/
*dynamicAssort.json
*dynamicAssort.json
Aki-Server
SITCoop
tempZipContents
*.zip
4 changes: 3 additions & 1 deletion packageBuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ const ignoreList = [
"packageBuild.ts",
"mod.code-workspace",
"package-lock.json",
"tsconfig.json"
"tsconfig.json",
"*.ps1"
];
const exclude = glob.sync(`{${ignoreList.join(",")}}`, { realpath: true, dot: true });

Expand All @@ -65,6 +66,7 @@ const filesToRemove = [
".git/",
".gitea/",
".gitignore",
"package_release_with_server.ps1",
];

filesToRemove.forEach((file) => {
Expand Down
118 changes: 118 additions & 0 deletions package_release_with_server.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
Param(
[Parameter(Mandatory = $false)]
[Switch] $Overwrite,

[Parameter(Mandatory = $false)]
[string] $Branch,

[Parameter(Mandatory = $false)]
[string] $Commit
)

$ErrorActionPreference = "Stop"
$SOURCE_REPO = "https://dev.sp-tarkov.com/SPT-AKI/Server.git"
$SERVER_DIR = "./Aki-Server"
$ZIP_Folder = "./tempZipContents"

# build coop mod
npm ci
npm run build

if ($LASTEXITCODE -ne 0) {
throw ("coop mod npm run build failed, exit code $LASTEXITCODE")
}

# clone aki server
if (Test-Path -Path $SERVER_DIR) {
if ($Overwrite -or (Read-Host "$SERVER_DIR exists, delete? [y/n]") -eq 'y') {
Write-Output "$SERVER_DIR exists, removing"
Remove-Item -Recurse -Force $SERVER_DIR
}
else {
Exit 1
}
}

Write-Output "clone repo"
if ( $Branch.Length -gt 0 ) {
Write-Output "Cloning branch/tag $Branch"
git clone --depth 1 -b $Branch $SOURCE_REPO $SERVER_DIR
}
else {
Write-Output "Cloning default branch"
git clone --depth 1 $SOURCE_REPO $SERVER_DIR
}

Set-Location $SERVER_DIR

if ($Commit.Length -gt 0) {
Write-Output "Checking out the commit $Commit"
git fetch --depth=1 $SOURCE_REPO $Commit
git checkout $Commit

if ($LASTEXITCODE -ne 0) {
throw ("Commit $Commit checkout failed. It doesn't exist? git exit code $LASTEXITCODE")
}
}

#$Head = git rev-parse --short HEAD
#$Branch = git rev-parse --abbrev-ref HEAD
#$CTime = git log -1 --format="%at"
#$CTimeS = (([System.DateTimeOffset]::FromUnixTimeSeconds($CTime)).DateTime).ToString("yyyyMMddHHmmss")
#
#Write-Output "Current HEAD is at $Head in $Branch committed at $CTimeS"
#
#$Tag = git describe --tags --abbrev=0 $Head
#$IsTag = $LASTEXITCODE -eq 0
#if ($IsTag) {
# Write-Output "We also have a tag $Tag at HEAD"
#}

Write-Output "lfs"
git lfs fetch
git lfs pull

Write-Output "build"
Set-Location ./project
npm install
npm run build:release

if ($LASTEXITCODE -ne 0) {
throw ("npm run build:$Target failed, exit code $LASTEXITCODE")
}

Get-ChildItem ./build
#$AkiMeta = (Get-Content ./build/Aki_Data/Server/configs/core.json | ConvertFrom-Json -AsHashtable)
#Write-Output $akiMeta
#
#if ($IsTag) {
# $CInfo = "tag-$Tag"
#}
#elseif ($Branch.Equals("HEAD")) {
# $CInfo = "$Head-$CTimeS"
#}
#else {
# $CInfo = "$Branch-$Head-$CTimeS"
#}
#
#$Suffix = "$Target-v$($akimeta.akiVersion)-$CInfo-Tarkov$($akimeta.compatibleTarkovVersion)"

Set-Location ../../

New-Item -ItemType Directory -Force -Path "$ZIP_Folder/user/mods/"
Copy-Item -Path "$SERVER_DIR/project/build\*" -Destination "$ZIP_Folder" -Recurse
Copy-Item -Path "./SITCoop" -Destination "$ZIP_Folder/user/mods/" -Recurse

# make release package
if ($IsWindows) {
$ZipName = "Aki-Server-win-with-SITCoop.zip"
Compress-Archive -Path "$ZIP_Folder/*" -DestinationPath "$ZipName" -Force
}
else{
$ZipName = "Aki-Server-linux-with-SITCoop.tar.gz"
Set-Location "$ZIP_Folder"
tar --overwrite -cz -f "../$ZipName" ./*
}

Write-Output "Built file: $ZipName"
Write-Output "ZIP_NAME=$ZipName" >> "$env:GITHUB_OUTPUT"

0 comments on commit 36d7fd7

Please sign in to comment.