2024-02-29 21:44:53 -05:00
name : SPT Release Build
2024-03-12 18:38:04 -04:00
2024-02-29 21:25:58 -05:00
on :
2024-03-12 00:18:11 -04:00
schedule :
2024-11-28 15:40:06 -05:00
- cron : "0 4 * * *" # Nightly should trigger at 4am UTC (11pm EST).
2024-11-22 21:33:27 -05:00
repository_dispatch :
types : [ build-trigger]
2024-11-22 22:06:42 -05:00
workflow_dispatch :
inputs :
buildTag :
description : "The tag to build on"
required : true
type : string
2024-03-12 18:38:04 -04:00
2024-11-23 09:16:22 -05:00
concurrency :
group : spt-release-build
cancel-in-progress : true
2024-02-29 21:25:58 -05:00
jobs :
2024-03-11 23:17:50 -04:00
prepare :
2024-03-02 22:46:27 -05:00
runs-on : ubuntu-latest
2024-03-11 23:52:56 -04:00
container :
2025-01-03 17:24:23 -05:00
image : refringe/spt-build-node:1.1.0
2024-03-02 22:46:27 -05:00
outputs :
2024-03-11 23:17:50 -04:00
proceed : ${{ steps.check-existence.outputs.proceed }}
is_nightly : ${{ steps.determine-context.outputs.is_nightly }}
branch_server : ${{ steps.determine-context.outputs.branch_server }}
branch_modules : ${{ steps.determine-context.outputs.branch_modules }}
branch_launcher : ${{ steps.determine-context.outputs.branch_launcher }}
2024-11-22 22:19:04 -05:00
target_tag : ${{ steps.determine-context.outputs.target_tag }}
2024-03-14 17:27:16 -04:00
build_type : ${{ steps.determine-build-type.outputs.build_type }}
2024-03-11 23:50:58 -04:00
client_version : ${{ steps.versions.outputs.client_version }}
spt_version : ${{ steps.versions.outputs.spt_version }}
2024-03-14 11:58:11 -04:00
2024-03-02 22:46:27 -05:00
steps :
2024-04-25 23:54:08 -04:00
- name : Determine Build Context
id : determine-context
2024-11-22 21:33:27 -05:00
shell : bash
env :
EVENT_NAME : ${{ github.event_name }}
CLIENT_PAYLOAD_TAG : ${{ github.event.client_payload.tag }}
2024-11-22 22:06:42 -05:00
WORKFLOW_INPUT_TAG : ${{ github.event.inputs.buildTag }}
2024-04-25 23:54:08 -04:00
run : |
echo "Determining build context..."
2024-11-22 21:33:27 -05:00
if [[ "$EVENT_NAME" == "schedule" ]]; then
echo "is_nightly=true" >> $GITHUB_OUTPUT
2025-01-02 14:08:55 -05:00
echo "branch_server=4.0.0-DEV" >> $GITHUB_OUTPUT
echo "branch_modules=4.0.0-DEV" >> $GITHUB_OUTPUT
echo "branch_launcher=4.0.0-DEV" >> $GITHUB_OUTPUT
2024-11-22 22:19:04 -05:00
echo "Context is nightly build"
2024-04-25 23:54:08 -04:00
else
2024-11-22 21:33:27 -05:00
echo "is_nightly=false" >> $GITHUB_OUTPUT
2024-11-22 22:06:42 -05:00
# Determine the tag based on the event type
if [[ "$EVENT_NAME" == "workflow_dispatch" ]]; then
TAG_NAME="$WORKFLOW_INPUT_TAG"
elif [[ "$EVENT_NAME" == "repository_dispatch" ]]; then
TAG_NAME="$CLIENT_PAYLOAD_TAG"
else
echo "Unsupported event: $EVENT_NAME"
2024-11-22 21:33:27 -05:00
exit 1
fi
2024-04-25 23:54:08 -04:00
2024-11-22 22:06:42 -05:00
if [[ -z "$TAG_NAME" ]]; then
echo "No tag provided in event payload."
exit 1
fi
echo "target_tag=$TAG_NAME" >> $GITHUB_OUTPUT
2024-11-22 22:19:04 -05:00
echo "Target tag is $TAG_NAME"
2024-04-25 23:54:08 -04:00
fi
- name : Determine Build Type
id : determine-build-type
2024-11-22 21:33:27 -05:00
shell : bash
2024-04-25 23:54:08 -04:00
run : |
if [[ "${{ steps.determine-context.outputs.is_nightly }}" == "true" ]]; then
2025-01-03 17:15:54 -05:00
BUILD_TYPE="bleeding"
2024-04-25 23:54:08 -04:00
else
2024-11-22 22:19:04 -05:00
TARGET_TAG="${{ steps.determine-context.outputs.target_tag }}"
2024-11-22 21:33:27 -05:00
TARGET_TAG_UPPER="${TARGET_TAG^^}"
2024-04-25 23:54:08 -04:00
BUILD_TYPE="debug"
if [[ "$TARGET_TAG_UPPER" =~ -BEM ]]; then
2025-01-03 17:16:17 -05:00
#BUILD_TYPE="bleedingmods"
BUILD_TYPE="bleeding" # CHOMP! KEK
2024-04-25 23:54:08 -04:00
elif [[ "$TARGET_TAG_UPPER" =~ -BE ]]; then
BUILD_TYPE="bleeding"
2025-01-03 17:16:52 -05:00
elif [[ "$TARGET_TAG_UPPER" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
2024-04-25 23:54:08 -04:00
BUILD_TYPE="release"
2024-03-12 00:26:35 -04:00
fi
2024-04-25 23:54:08 -04:00
fi
2024-11-22 21:33:27 -05:00
echo "build_type=$BUILD_TYPE" >> $GITHUB_OUTPUT
2024-11-22 22:19:04 -05:00
echo "Build type is $BUILD_TYPE"
2024-04-25 23:54:08 -04:00
- name : Check Existence
id : check-existence
2024-11-22 21:33:27 -05:00
shell : bash
2024-04-25 23:54:08 -04:00
run : |
PROCEED="true"
if [[ "${{ steps.determine-context.outputs.is_nightly }}" == "true" ]]; then
declare -A BRANCHES=(
2024-11-22 21:33:27 -05:00
[ Server]="https://github.com/sp-tarkov/server.git@${{ steps.determine-context.outputs.branch_server }}"
[ Modules]="https://github.com/sp-tarkov/modules.git@${{ steps.determine-context.outputs.branch_modules }}"
[ Launcher]="https://github.com/sp-tarkov/launcher.git@${{ steps.determine-context.outputs.branch_launcher }}"
2024-04-25 23:54:08 -04:00
)
for REPO_NAME in "${!BRANCHES[@]}"; do
REPO_URL="${BRANCHES[$REPO_NAME]%@*}"
BRANCH="${BRANCHES[$REPO_NAME]##*@}"
echo "Checking for branch $BRANCH in $REPO_NAME..."
if ! git ls-remote --heads $REPO_URL $BRANCH | grep -q $BRANCH; then
echo "Branch $BRANCH not found in $REPO_URL"
PROCEED="false"
break
fi
done
else
2024-11-22 22:19:04 -05:00
TAG="${{ steps.determine-context.outputs.target_tag }}"
2024-11-22 21:33:27 -05:00
REPOS=("https://github.com/sp-tarkov/server.git" "https://github.com/sp-tarkov/modules.git" "https://github.com/sp-tarkov/launcher.git")
2024-04-25 23:54:08 -04:00
for REPO in "${REPOS[@]}"; do
echo "Checking for tag $TAG in $REPO..."
if ! git ls-remote --tags $REPO $TAG | grep -q $TAG; then
echo "Tag $TAG not found in $REPO"
PROCEED="false"
break
fi
done
fi
2024-11-22 21:33:27 -05:00
echo "proceed=$PROCEED" >> $GITHUB_OUTPUT
2024-11-22 23:27:06 -05:00
echo "Matches found. Proceeding with build."
2024-04-25 23:54:08 -04:00
- name : Tag Not Found
if : steps.check-existence.outputs.proceed == 'false'
run : |
echo "Required branch/tag not found in one or more repositories, halting workflow."
exit 1
- name : Extract Versions
id : versions
2024-11-22 21:33:27 -05:00
shell : bash
2024-04-25 23:54:08 -04:00
run : |
2024-06-03 13:37:30 -04:00
rm -rf /workspace/SPT/Build/server-core
git init /workspace/SPT/Build/server-core
cd /workspace/SPT/Build/server-core
2024-11-22 21:33:27 -05:00
git remote add origin https://github.com/sp-tarkov/server.git
2024-04-25 23:54:08 -04:00
git config core.sparseCheckout true
echo "project/assets/configs/core.json" >> .git/info/sparse-checkout
if [[ "${{ steps.determine-context.outputs.is_nightly }}" == "true" ]]; then
REF=${{ steps.determine-context.outputs.branch_server }}
else
2024-11-22 22:19:04 -05:00
REF=${{ steps.determine-context.outputs.target_tag }}
2024-04-25 23:54:08 -04:00
fi
git fetch --depth=1 origin "${REF}"
git checkout FETCH_HEAD
cd project/assets/configs
2024-07-06 11:42:47 +01:00
SPT_VERSION=$(jq -r '.sptVersion' core.json)
2024-04-25 23:54:08 -04:00
FULL_VERSION=$(jq -r '.compatibleTarkovVersion' core.json)
CLIENT_VERSION=${FULL_VERSION##*.}
2024-11-22 21:33:27 -05:00
echo "client_version=$CLIENT_VERSION" >> $GITHUB_OUTPUT
echo "spt_version=$SPT_VERSION" >> $GITHUB_OUTPUT
2024-04-25 23:54:08 -04:00
2024-11-22 23:27:06 -05:00
echo "Client version is $CLIENT_VERSION"
echo "SPT version is $SPT_VERSION"
2024-03-02 22:46:27 -05:00
build-server :
2024-11-22 21:33:27 -05:00
needs : prepare
2024-03-11 23:17:50 -04:00
if : needs.prepare.outputs.proceed == 'true'
2025-01-03 11:27:54 -05:00
runs-on : windows-latest
2024-03-16 18:49:23 -04:00
outputs :
2025-01-03 23:54:26 -05:00
server_commit : ${{ steps.commit-hash.outputs.server_commit }}
2024-02-29 21:25:58 -05:00
steps :
2025-01-03 11:27:54 -05:00
- name : Setup Git Target
shell : pwsh
2024-04-25 23:54:08 -04:00
run : |
2025-01-03 11:27:54 -05:00
if ("${{ needs.prepare.outputs.is_nightly }}" -eq "true") {
echo "TARGET=${{ needs.prepare.outputs.branch_server }}" >> $env:GITHUB_ENV
}
else {
echo "TARGET=${{ needs.prepare.outputs.target_tag }}" >> $env:GITHUB_ENV
}
Write-Host "Cloning target: ${{ env.TARGET }}"
2025-01-03 12:12:16 -05:00
- name : Clone Server
2025-01-03 11:27:54 -05:00
shell : pwsh
2025-01-03 12:12:16 -05:00
run : |
# If found, remove any existing folder from a previous run
$serverPath = "$env:GITHUB_WORKSPACE\SPT\Build\server"
if (Test-Path $serverPath) {
Remove-Item -Recurse -Force $serverPath
}
# Clone the server repo
git clone --depth=1 https://github.com/sp-tarkov/server.git $serverPath
# Move into the cloned repo
Set-Location $serverPath
# Fetch tags if needed
git fetch --tags
# Checkout the ref (branch or tag) from $env.TARGET
git checkout $env:TARGET
# Install LFS and pull files
git lfs install --local
git lfs pull
2025-01-03 11:27:54 -05:00
- name : Output Commit Hash
id : commit-hash
shell : pwsh
2025-01-03 23:54:26 -05:00
run : echo "server_commit=$(git rev-parse --short HEAD)" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
2025-01-03 11:27:54 -05:00
working-directory : ./SPT/Build/server
- uses : actions/setup-node@v4
with :
node-version-file : "SPT/Build/server/project/.nvmrc"
cache : "npm"
cache-dependency-path : "SPT/Build/server/project/package.json"
2024-04-25 23:54:08 -04:00
2025-01-03 17:17:23 -05:00
- name : Get npm cache directory
id : npm-cache-dir
shell : pwsh
run : echo "dir=$(npm config get cache)" >> ${env:GITHUB_OUTPUT}
2025-01-03 11:27:54 -05:00
- name : Check NPM Cache
id : cache-check
uses : actions/cache@v4
with :
2025-01-03 17:17:23 -05:00
path : ${{ steps.npm-cache-dir.outputs.dir }}
key : ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
2025-01-03 11:27:54 -05:00
restore-keys : |
${{ runner.os }}-node-
2024-04-25 23:54:08 -04:00
2025-01-03 11:27:54 -05:00
- name : Install NPM Dependencies
if : steps.cache-check.outputs.cache-hit != 'true'
run : npm install
working-directory : ./SPT/Build/server/project
2024-04-25 23:54:08 -04:00
- name : Build Server
2025-01-03 11:27:54 -05:00
shell : pwsh
run : npm run build:${{ needs.prepare.outputs.build_type }} -- --arch=x64 --platform=win32
working-directory : ./SPT/Build/server/project
2024-04-25 23:54:08 -04:00
2024-11-22 21:33:27 -05:00
- name : Upload Server Artifact
uses : actions/upload-artifact@v4
2024-04-25 23:54:08 -04:00
with :
name : server-artifact
2025-01-03 11:27:54 -05:00
path : ./SPT/Build/server/project/build/
2024-04-25 23:54:08 -04:00
retention-days : 1
2024-11-22 21:33:27 -05:00
if-no-files-found : error
2024-03-02 22:29:09 -05:00
2024-03-02 22:46:27 -05:00
build-modules :
2024-11-22 21:33:27 -05:00
needs : prepare
2024-03-11 23:17:50 -04:00
if : needs.prepare.outputs.proceed == 'true'
2024-03-02 22:29:09 -05:00
runs-on : ubuntu-latest
container :
2024-03-08 12:21:08 -05:00
image : refringe/spt-build-dotnet:1.0.0
2024-03-02 22:29:09 -05:00
steps :
2024-11-22 21:33:27 -05:00
- name : Clone Modules
2024-04-25 23:54:08 -04:00
id : clone-modules
2024-11-22 21:33:27 -05:00
shell : bash
2024-04-25 23:54:08 -04:00
run : |
2024-06-03 13:37:30 -04:00
rm -rf /workspace/SPT/Build/modules
2024-04-25 23:54:08 -04:00
if [[ "${{ needs.prepare.outputs.is_nightly }}" == "true" ]]; then
BRANCH=${{ needs.prepare.outputs.branch_modules }}
echo "Cloning modules from branch $BRANCH"
2024-11-22 21:33:27 -05:00
git clone https://github.com/sp-tarkov/modules.git --branch "$BRANCH" --depth 1 /workspace/SPT/Build/modules
2024-04-25 23:54:08 -04:00
else
TAG=${{ needs.prepare.outputs.target_tag }}
echo "Cloning modules from tag $TAG"
2024-11-22 21:33:27 -05:00
git clone https://github.com/sp-tarkov/modules.git --branch "$TAG" --depth 1 /workspace/SPT/Build/modules
2024-04-25 23:54:08 -04:00
fi
2024-06-03 13:37:30 -04:00
cd /workspace/SPT/Build/modules
2024-11-22 21:33:27 -05:00
echo "modules_commit=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
2024-04-25 23:54:08 -04:00
- name : Download Client Module Package
2024-11-22 21:33:27 -05:00
shell : bash
env :
MODULE_DOMAIN : ${{ secrets.MODULE_DOMAIN }}
2024-04-25 23:54:08 -04:00
run : |
2024-06-03 13:37:30 -04:00
DIR_MANAGED="/workspace/SPT/Build/modules/project/Shared/Managed"
2024-04-25 23:54:08 -04:00
DOWNLOAD_PATH="$DIR_MANAGED/${{ needs.prepare.outputs.client_version }}.7z"
2024-11-22 21:33:27 -05:00
DOWNLOAD_URL="${MODULE_DOMAIN}/${{ needs.prepare.outputs.client_version }}.7z"
2024-04-25 23:54:08 -04:00
echo "Downloading Client Module Package from $DOWNLOAD_URL to $DOWNLOAD_PATH"
mkdir -p "$DIR_MANAGED"
wget -q -O "$DOWNLOAD_PATH" "$DOWNLOAD_URL" || {
echo "Failed to download the module package."
exit 1
}
if [ ! -s "$DOWNLOAD_PATH" ]; then
echo "The module package does not exist or is empty."
exit 1
fi
echo "Download Successful: $DOWNLOAD_PATH"
- name : Decompress Client Module Package
2024-11-22 21:33:27 -05:00
shell : bash
2024-04-25 23:54:08 -04:00
run : |
2024-06-03 13:37:30 -04:00
cd /workspace/SPT/Build/modules/project/Shared/Managed
2024-04-25 23:54:08 -04:00
7z x ${{ needs.prepare.outputs.client_version }}.7z -aoa
echo "Client module package decompressed."
- name : Delete Client Module Package
2024-11-22 21:33:27 -05:00
shell : bash
2024-04-25 23:54:08 -04:00
run : |
2024-06-03 13:37:30 -04:00
cd /workspace/SPT/Build/modules/project/Shared/Managed
2024-04-25 23:54:08 -04:00
rm -f ${{ needs.prepare.outputs.client_version }}.7z
echo "Client module package deleted."
- name : Build Modules
2024-11-22 21:33:27 -05:00
shell : bash
2024-04-25 23:54:08 -04:00
run : |
2024-06-03 13:37:30 -04:00
cd /workspace/SPT/Build/modules/project
2024-04-25 23:54:08 -04:00
dotnet build -c Release -p:Version=${{ needs.prepare.outputs.spt_version }}
printf "\nBuilt!\n\n"
2024-11-22 21:33:27 -05:00
- name : Upload Modules Artifact
uses : actions/upload-artifact@v4
2024-04-25 23:54:08 -04:00
with :
name : modules-artifact
2024-06-03 13:37:30 -04:00
path : /workspace/SPT/Build/modules/project/Build
2024-04-25 23:54:08 -04:00
retention-days : 1
2024-11-22 21:33:27 -05:00
if-no-files-found : error
2024-03-04 21:12:10 -05:00
2024-03-02 22:46:27 -05:00
build-launcher :
2024-11-22 21:33:27 -05:00
needs : prepare
2024-03-11 23:17:50 -04:00
if : needs.prepare.outputs.proceed == 'true'
2024-03-02 22:29:09 -05:00
runs-on : ubuntu-latest
container :
2024-03-08 12:21:08 -05:00
image : refringe/spt-build-dotnet:1.0.0
2024-03-02 22:29:09 -05:00
steps :
2024-11-22 21:33:27 -05:00
- name : Clone Launcher
2024-04-25 23:54:08 -04:00
id : clone-launcher
2024-11-22 21:33:27 -05:00
shell : bash
2024-04-25 23:54:08 -04:00
run : |
2024-06-03 13:37:30 -04:00
rm -rf /workspace/SPT/Build/launcher
2024-04-25 23:54:08 -04:00
if [[ "${{ needs.prepare.outputs.is_nightly }}" == "true" ]]; then
BRANCH=${{ needs.prepare.outputs.branch_launcher }}
echo "Cloning launcher from branch $BRANCH"
2024-11-22 21:33:27 -05:00
git clone https://github.com/sp-tarkov/launcher.git --branch "$BRANCH" --depth 1 /workspace/SPT/Build/launcher
2024-04-25 23:54:08 -04:00
else
TAG=${{ needs.prepare.outputs.target_tag }}
echo "Cloning launcher from tag $TAG"
2024-11-22 21:33:27 -05:00
git clone https://github.com/sp-tarkov/launcher.git --branch "$TAG" --depth 1 /workspace/SPT/Build/launcher
2024-04-25 23:54:08 -04:00
fi
2024-06-03 13:37:30 -04:00
cd /workspace/SPT/Build/launcher
2024-11-22 21:33:27 -05:00
echo "launcher_commit=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
2024-04-25 23:54:08 -04:00
- name : Build Launcher
2024-11-22 21:33:27 -05:00
shell : bash
2024-04-25 23:54:08 -04:00
run : |
2024-06-03 13:37:30 -04:00
cd /workspace/SPT/Build/launcher/project
2024-04-25 23:54:08 -04:00
dotnet build
printf "\nBuilt!\n\n"
2024-11-22 21:33:27 -05:00
- name : Upload Launcher Artifact
uses : actions/upload-artifact@v4
2024-04-25 23:54:08 -04:00
with :
name : launcher-artifact
2024-06-03 13:37:30 -04:00
path : /workspace/SPT/Build/launcher/project/Build
2024-04-25 23:54:08 -04:00
retention-days : 1
2024-11-22 21:33:27 -05:00
if-no-files-found : error
2024-03-05 23:05:43 -05:00
2024-03-28 19:06:01 -04:00
assemble-and-publish :
2024-03-11 23:17:50 -04:00
needs : [ prepare, build-server, build-modules, build-launcher]
2024-03-05 23:05:43 -05:00
runs-on : ubuntu-latest
container :
2025-01-03 17:24:23 -05:00
image : refringe/spt-build-node:1.1.0
2024-03-05 23:05:43 -05:00
steps :
2024-04-25 23:54:08 -04:00
- name : Clean Directory
2024-11-22 21:33:27 -05:00
shell : bash
2024-04-25 23:54:08 -04:00
run : |
2024-11-22 23:33:56 -05:00
rm -rf release build
mkdir -p release
2024-04-25 23:54:08 -04:00
- name : Download Server Artifact
2024-11-22 21:33:27 -05:00
uses : actions/download-artifact@v4
2024-04-25 23:54:08 -04:00
with :
name : server-artifact
2024-11-22 23:33:56 -05:00
path : release/
2024-04-25 23:54:08 -04:00
- name : Download Modules Artifact
2024-11-22 21:33:27 -05:00
uses : actions/download-artifact@v4
2024-04-25 23:54:08 -04:00
with :
name : modules-artifact
2024-11-22 23:33:56 -05:00
path : release/
2024-04-25 23:54:08 -04:00
- name : Download Launcher Artifact
2024-11-22 21:33:27 -05:00
uses : actions/download-artifact@v4
2024-04-25 23:54:08 -04:00
with :
name : launcher-artifact
2024-11-22 23:33:56 -05:00
path : release/
2024-04-25 23:54:08 -04:00
- name : Clone Build Project
2024-11-22 21:33:27 -05:00
uses : actions/checkout@v4
2024-04-25 23:54:08 -04:00
with :
2024-11-22 23:33:56 -05:00
repository : sp-tarkov/build
path : build
2024-04-25 23:54:08 -04:00
- name : Merge Static Assets and Dynamic Files
shell : bash
2024-11-22 23:33:56 -05:00
run : cp -rvf build/static-assets/* release/
2024-04-25 23:54:08 -04:00
- name : List Release Contents
shell : bash
2024-11-22 23:33:56 -05:00
run : tree release
2024-04-25 23:54:08 -04:00
- name : Generate Release Filename
id : generate-filename
2024-11-22 21:33:27 -05:00
shell : bash
2024-04-25 23:54:08 -04:00
run : |
BUILD_TYPE=${{ needs.prepare.outputs.build_type }}
SPT_VERSION=${{ needs.prepare.outputs.spt_version }}
CLIENT_VERSION=${{ needs.prepare.outputs.client_version }}
SERVER_COMMIT=${{ needs.build-server.outputs.server_commit }}
TARGET_TAG=${{ needs.prepare.outputs.target_tag }}
DATE=$(date +%Y%m%d)
if [[ "${{ needs.prepare.outputs.is_nightly }}" == "true" ]]; then
BASE_NAME="SPT-NIGHTLY-${SPT_VERSION}-${CLIENT_VERSION}-${SERVER_COMMIT}-${DATE}"
2024-03-14 11:58:11 -04:00
else
2024-04-25 23:54:08 -04:00
UPPER_BUILD_TYPE=$(echo "$BUILD_TYPE" | tr '[:lower:]' '[:upper:]')
UPPER_TARGET_TAG=$(echo "$TARGET_TAG" | tr '[:lower:]' '[:upper:]')
if [ "$BUILD_TYPE" = "release" ]; then
BASE_NAME="SPT-${SPT_VERSION}-${CLIENT_VERSION}-${SERVER_COMMIT}"
2024-03-14 11:58:11 -04:00
else
2024-04-25 23:54:08 -04:00
TAG_PART=""
if [[ "$UPPER_TARGET_TAG" == *-*-* ]]; then
SUFFIX="${UPPER_TARGET_TAG##*-}"
if [ "$SUFFIX" != "$UPPER_TARGET_TAG" ]; then
TAG_PART="-${SUFFIX}"
fi
fi
if [ -n "$TAG_PART" ]; then
BASE_NAME="SPT-${UPPER_BUILD_TYPE}-${SPT_VERSION}-${CLIENT_VERSION}-${SERVER_COMMIT}${TAG_PART}"
else
BASE_NAME="SPT-${UPPER_BUILD_TYPE}-${SPT_VERSION}-${CLIENT_VERSION}-${SERVER_COMMIT}-${DATE}"
fi
2024-03-14 11:58:11 -04:00
fi
fi
2024-04-25 23:54:08 -04:00
2024-11-22 21:33:27 -05:00
echo "base_name=$BASE_NAME" >> $GITHUB_OUTPUT
echo "build_name=${BASE_NAME}.7z" >> $GITHUB_OUTPUT
2024-04-25 23:54:08 -04:00
2024-11-22 23:53:25 -05:00
echo "Release filename: ${BASE_NAME}.7z"
2024-04-25 23:54:08 -04:00
- name : Compress Release
id : compress-release
2024-11-22 21:33:27 -05:00
shell : bash
2024-04-25 23:54:08 -04:00
run : |
2024-11-22 23:33:56 -05:00
cd release
2024-04-25 23:54:08 -04:00
7z a -mx=9 -m0=lzma2 "../${{ steps.generate-filename.outputs.build_name }}" ./*
echo "Release compressed as ${{ steps.generate-filename.outputs.build_name }}."
2024-04-26 00:21:01 -04:00
FILE_SIZE_MB=$(stat -c %s "../${{ steps.generate-filename.outputs.build_name }}" | awk '{printf "%.2f MB", $1 / 1024 / 1024}')
FILE_HASH=$(md5sum "../${{ steps.generate-filename.outputs.build_name }}" | awk '{print $1}' | xxd -r -p | base64)
2024-04-25 23:54:08 -04:00
2024-11-22 21:33:27 -05:00
echo "file_size_mb=$FILE_SIZE_MB" >> $GITHUB_OUTPUT
echo "file_hash=$FILE_HASH" >> $GITHUB_OUTPUT
2024-04-25 23:54:08 -04:00
- name : R2 Upload
2024-04-26 00:37:32 -04:00
if : needs.prepare.outputs.build_type == 'release'
2024-04-26 01:01:47 -04:00
env :
SPT_VERSION : ${{ needs.prepare.outputs.spt_version }}
CLIENT_VERSION : ${{ needs.prepare.outputs.client_version }}
FILE_HASH : ${{ steps.compress-release.outputs.file_hash }}
2024-11-22 21:33:27 -05:00
R2_ACCESS_KEY : ${{ secrets.R2_ACCESS_KEY }}
R2_SECRET_ACCESS_KEY : ${{ secrets.R2_SECRET_ACCESS_KEY }}
R2_ENDPOINT : ${{ secrets.R2_ENDPOINT }}
R2_BUCKET_NAME : ${{ secrets.R2_BUCKET_NAME }}
R2_FRONT : ${{ secrets.R2_FRONT }}
shell : bash
2024-04-25 23:54:08 -04:00
run : |
# Configure Rclone
echo '[r2]
type = s3
provider = Cloudflare
2024-11-22 21:33:27 -05:00
access_key_id = '"$R2_ACCESS_KEY"'
secret_access_key = '"$R2_SECRET_ACCESS_KEY"'
2024-04-25 23:54:08 -04:00
region = auto
2024-11-22 21:33:27 -05:00
endpoint = '"$R2_ENDPOINT"'
acl = public-read' > ./rclone.conf
2024-04-25 23:54:08 -04:00
2024-04-26 01:01:47 -04:00
# Generate Release JSON File
2024-04-26 01:11:21 -04:00
echo "{
\"AkiVersion\": \"${SPT_VERSION}\",
\"ClientVersion\": \"${CLIENT_VERSION}\",
\"Mirrors\": [{
2024-11-22 21:33:27 -05:00
\"DownloadUrl\": \"${R2_FRONT}/${{ steps.generate-filename.outputs.build_name }}\",
2024-04-26 01:11:21 -04:00
\"Hash\": \"${FILE_HASH}\"
2024-04-25 23:54:08 -04:00
}]
2024-11-22 21:33:27 -05:00
}" > ./release.json
2024-04-25 23:54:08 -04:00
2024-05-15 12:14:02 -04:00
echo "Current Local Directory:"
2024-04-26 00:47:20 -04:00
ls -lah
2024-04-25 23:54:08 -04:00
2024-05-15 12:14:02 -04:00
echo "Current Remote Directory:"
2024-11-22 21:33:27 -05:00
rclone ls r2:${R2_BUCKET_NAME} --config ./rclone.conf
2024-05-15 12:14:02 -04:00
2024-11-22 21:33:27 -05:00
# Remove old .7z files from the bucket
rclone lsf r2:${R2_BUCKET_NAME} --config ./rclone.conf --files-only --include="*.7z" --absolute > files-to-remove.txt
2024-05-15 13:16:51 -04:00
echo "Files to be deleted:"
cat files-to-remove.txt
2024-11-22 21:33:27 -05:00
rclone delete r2:${R2_BUCKET_NAME} --config ./rclone.conf --files-from=files-to-remove.txt --max-depth=1 -vv
2024-04-25 23:54:08 -04:00
2024-11-22 21:33:27 -05:00
# Upload the .7z file using rclone with the above config
rclone copy "./${{ steps.generate-filename.outputs.build_name }}" r2:${R2_BUCKET_NAME} --config ./rclone.conf -vv
2024-04-25 23:54:08 -04:00
# Upload the JSON file using rclone with the above config
2024-11-22 21:33:27 -05:00
rclone copy "./release.json" r2:${R2_BUCKET_NAME} --config ./rclone.conf -vv
echo "R2 Upload completed."
2024-04-25 23:54:08 -04:00
- name : Upload Release to HTTPS Source
id : upload-https-7z
2024-11-22 21:33:27 -05:00
shell : bash
2024-04-25 23:54:08 -04:00
run : |
2024-11-22 23:53:25 -05:00
sshpass -p "${{ secrets.SFTP_PASSWORD }}" scp -v -o "Port=${{ secrets.SFTP_PORT }}" -o "ConnectTimeout=20" -o "StrictHostKeyChecking=no" "${{ steps.generate-filename.outputs.build_name }}" ${{ secrets.SFTP_USERNAME }}@${{ secrets.SFTP_HOST }}:/public/builds
2024-11-22 21:33:27 -05:00
echo "link_https=${{ secrets.SFTP_MIRROR_LINK }}/builds/${{ steps.generate-filename.outputs.build_name }}" >> $GITHUB_OUTPUT
2024-11-22 23:53:25 -05:00
echo "HTTPS Upload completed: ${{ secrets.SFTP_MIRROR_LINK }}/builds/${{ steps.generate-filename.outputs.build_name }}"
2024-04-25 23:54:08 -04:00
- name : Post Build Info to Discord
env :
DISCORD_WEBHOOK_URL : ${{ secrets.DISCORD_WEBHOOK_URL }}
BUILD_TYPE : ${{ needs.prepare.outputs.build_type }}
BASE_NAME : ${{ steps.generate-filename.outputs.base_name }}
BUILD_NAME : ${{ steps.generate-filename.outputs.build_name }}
FILE_SIZE_MB : ${{ steps.compress-release.outputs.file_size_mb }}
FILE_HASH : ${{ steps.compress-release.outputs.file_hash }}
LINK_HTTPS : ${{ steps.upload-https-7z.outputs.link_https }}
2024-11-22 21:33:27 -05:00
IS_NIGHTLY : ${{ needs.prepare.outputs.is_nightly }}
shell : bash
2024-04-25 23:54:08 -04:00
run : |
UPPER_BUILD_TYPE=$(echo "$BUILD_TYPE" | tr '[:lower:]' '[:upper:]')
2025-01-03 17:24:23 -05:00
FOOTER_MESSAGES=("You look great today!" "Powered by coffee" "Life's too short to remove USB safely" "Did you remember to hydrate today?" "Have you tried turning it off and on again?" "There's no place like 127.0.0.1" "In Chomp we trust" "Beep boop, I'm a bot" "Keep calm and commit your code" "This isn't a bug, it's an undocumented feature." "May the source be with you" "Go to bed, Terk" "Please direct all support requests to Drakia" "Meaw" "Chomp approves of this message" "Chomp is life, Chomp is love" "Drakia denies all involvement" "Drakia left this note here just to confuse you" "Cabbit is the reason we can’ t have nice things" "Cabbit voted against this message" "Powered by caffeine, chaos, and Chomp" "RaiRai says hi-hi" "RaiRai wants to remind you that sarcasm is a skill" "Refringe just wobbled" "Refringe is watching" "Refringe rewrote this embed thirty times" "Refringe, professional button-pusher extraordinaire" "Sarix would like you to reconsider your choices" "Stella is currently judging your grammar" "Stella just gave this embed a 6/10" "Waffle has entered the chat, and now it’ s weird" "Waffle is too busy stacking layers of chaos" "Waffle would like to speak to the manager of logic")
2024-04-25 23:54:08 -04:00
FOOTER_MESSAGE="${FOOTER_MESSAGES[$RANDOM % ${#FOOTER_MESSAGES[@]}]}"
TIMESTAMP=$(date --iso-8601=seconds)
MODS=""
if [[ "${{ needs.prepare.outputs.is_nightly }}" == "true" ]]; then
EMBED_COLOR=16705372
2025-01-03 17:24:23 -05:00
EMBED_DESCRIPTION='A new nightly build is available. These are untested and considered unstable. Absolutely no support is provided. **If you ask for help you will be banned from the #dev-builds channel without explanation.** 7-Zip is *required* to extract the release. The download link is temporary.'
2025-01-02 14:08:55 -05:00
MODS='enabled'
2024-03-14 11:58:11 -04:00
else
2024-04-25 23:54:08 -04:00
if [ "$BUILD_TYPE" == "bleeding" ]; then
EMBED_COLOR=15548997
2025-01-03 17:24:23 -05:00
EMBED_DESCRIPTION='A new bleeding edge build is available. These are strictly for testing issues *and not for general gameplay*. 7-Zip is *required* to extract the release. The download link is temporary.'
2025-01-02 14:08:55 -05:00
MODS='disabled'
2024-04-25 23:54:08 -04:00
elif [ "$BUILD_TYPE" == "bleedingmods" ]; then
EMBED_COLOR=15548997
2025-01-03 17:24:23 -05:00
EMBED_DESCRIPTION='A new bleeding edge build is available. These are strictly for testing issues *and not for general gameplay*. 7-Zip is *required* to extract the release. The download link is temporary.'
2025-01-02 14:08:55 -05:00
MODS='enabled'
2024-04-25 23:54:08 -04:00
elif [ "$BUILD_TYPE" == "debug" ]; then
EMBED_COLOR=2123412
2025-01-03 17:24:23 -05:00
EMBED_DESCRIPTION=$'A new debug build is available. These have extra-verbose logging enabled *for testing*. 7-Zip is *required* to extract the release. The download link is temporary.'
2025-01-02 14:08:55 -05:00
MODS='enabled'
2024-04-25 23:54:08 -04:00
else
EMBED_COLOR=5763719
EMBED_DESCRIPTION=$'A new stable build is now ready for download. 7-Zip is *required* to extract the release. Have fun! 🎉'
2025-01-02 14:08:55 -05:00
MODS='enabled'
2024-04-25 23:54:08 -04:00
fi
2024-03-14 11:58:11 -04:00
fi
2024-04-25 23:54:08 -04:00
fields_json='[
{"name": "Name", "value": "'" $BASE_NAME"'"},
{"name": "Build Type", "value": "'"$BUILD_TYPE"'", "inline": true },
{"name": "Mods", "value": "'"$MODS"'", "inline": true },
{"name": "File Size", "value": "'"$FILE_SIZE_MB"'", "inline": true },
{"name": "File Hash", "value": "'" $FILE_HASH"'"},
2025-01-03 17:24:23 -05:00
{"name": "Download", "value": "'" $LINK_HTTPS"'"}
2024-04-25 23:54:08 -04:00
] '
payload=$(jq -n \
--argjson fields "$fields_json" \
--arg EMBED_DESCRIPTION "$EMBED_DESCRIPTION" \
--argjson EMBED_COLOR "$EMBED_COLOR" \
--arg FOOTER_MESSAGE "$FOOTER_MESSAGE" \
--arg TIMESTAMP "$TIMESTAMP" \
'{
"content": $EMBED_DESCRIPTION,
"embeds": [
{
"title": "Build Information" ,
"color": $EMBED_COLOR,
"fields": $fields,
"footer": {"text": $FOOTER_MESSAGE, "icon_url": "https://i.imgur.com/28JJJec.png" },
"timestamp": $TIMESTAMP
}
] ,
"username": "BuildBot" ,
"avatar_url": "https://i.imgur.com/28JJJec.png"
}')
echo "$payload" > payload_discord.json
echo "Payload Generated:"
cat payload_discord.json
echo "Sending Payload..."
curl -H "Content-Type: application/json" \
-X POST \
--data-binary @payload_discord.json \
$DISCORD_WEBHOOK_URL