diff --git a/.github/workflows/Create-Release-with-SPT-AKI-Integration.yaml b/.github/workflows/Create-Release-with-SPT-AKI-Integration.yaml index a034c567..712a8ad4 100644 --- a/.github/workflows/Create-Release-with-SPT-AKI-Integration.yaml +++ b/.github/workflows/Create-Release-with-SPT-AKI-Integration.yaml @@ -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 diff --git a/.gitignore b/.gitignore index 2fe6eea3..b23f2dd5 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,8 @@ SITConfig*.json *.pem mod.js dist/ -*dynamicAssort.json \ No newline at end of file +*dynamicAssort.json +Aki-Server +SITCoop +tempZipContents +*.zip diff --git a/packageBuild.ts b/packageBuild.ts index 24d4f746..5424a465 100644 --- a/packageBuild.ts +++ b/packageBuild.ts @@ -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 }); @@ -65,6 +66,7 @@ const filesToRemove = [ ".git/", ".gitea/", ".gitignore", + "package_release_with_server.ps1", ]; filesToRemove.forEach((file) => { diff --git a/package_release_with_server.ps1 b/package_release_with_server.ps1 new file mode 100644 index 00000000..2832f008 --- /dev/null +++ b/package_release_with_server.ps1 @@ -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"