0
0
mirror of https://github.com/sp-tarkov/build.git synced 2025-02-13 06:30:45 -05:00
build/.gitea/workflows/build.yaml

699 lines
29 KiB
YAML
Raw Normal View History

2024-02-29 21:44:53 -05:00
name: SPT Release Build
2024-02-29 21:25:58 -05:00
on:
2024-03-12 00:18:11 -04:00
schedule:
2024-03-23 15:11:58 -04:00
- cron: '* 13 * * *' # Every day at 2pm ET
2024-02-29 21:25:58 -05:00
push:
# main can be removed when actions are available in the sub-project repos
branches: [ main, trigger ]
2024-02-29 21:25:58 -05:00
jobs:
2024-03-11 23:17:50 -04:00
prepare:
runs-on: ubuntu-latest
container:
image: refringe/spt-build-node:1.0.6
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 }}
target_tag: ${{ steps.determine-context.outputs.target_tag }}
build_type: ${{ steps.determine-build-type.outputs.build_type }}
client_version: ${{ steps.versions.outputs.client_version }}
spt_version: ${{ steps.versions.outputs.spt_version }}
mod_enabled_bleeding: ${{ steps.mod-config.outputs.bleeding }}
mod_enabled_bleedingmods: ${{ steps.mod-config.outputs.bleedingmods }}
mod_enabled_debug: ${{ steps.mod-config.outputs.debug }}
mod_enabled_release: ${{ steps.mod-config.outputs.release }}
steps:
2024-03-12 00:26:35 -04:00
- name: Determine Build Context
id: determine-context
run: |
echo "Determining build context..."
if [[ "${{ github.event_name }}" == "schedule" ]]; then
echo "::set-output name=is_nightly::true"
echo "::set-output name=branch_server::3.8.0"
echo "::set-output name=branch_modules::3.8.0"
echo "::set-output name=branch_launcher::3.8.0"
else
echo "::set-output name=is_nightly::false"
2024-03-23 15:11:58 -04:00
echo "::set-output name=target_tag::3.8.0-BEM-20240323"
2024-03-12 00:26:35 -04:00
fi
shell: bash
- name: Determine Build Type
id: determine-build-type
run: |
if [[ "${{ steps.determine-context.outputs.is_nightly }}" == "true" ]]; then
# Nightly builds are currently considered a "bleedingmods" type build
BUILD_TYPE="bleedingmods"
else
TARGET_TAG="${{ steps.determine-context.outputs.target_tag }}"
TARGET_TAG_UPPER="${TARGET_TAG^^}"
# Debug build by default
# BleedingMods builds have "-BEM" in the target tag
# Bleeding builds have "-BE" in the target tag
# Release tags follow basic semantic versioning
BUILD_TYPE="debug"
if [[ "$TARGET_TAG_UPPER" =~ -BEM ]]; then
BUILD_TYPE="bleedingmods"
elif [[ "$TARGET_TAG_UPPER" =~ -BE ]]; then
BUILD_TYPE="bleeding"
elif [[ "$TARGET_TAG_UPPER" =~ ^(v?\d+\.\d+\.\d+)$ ]]; then
BUILD_TYPE="release"
fi
fi
echo "::set-output name=build_type::${BUILD_TYPE}"
shell: bash
2024-03-12 00:26:35 -04:00
- name: Check Existence
id: check-existence
run: |
PROCEED="true"
if [[ "${{ steps.determine-context.outputs.is_nightly }}" == "true" ]]; then
declare -A BRANCHES=(
[Server]="https://dev.sp-tarkov.com/SPT-AKI/Server.git@${{ steps.determine-context.outputs.branch_server }}"
[Modules]="https://dev.sp-tarkov.com/SPT-AKI/Modules.git@${{ steps.determine-context.outputs.branch_modules }}"
[Launcher]="https://dev.sp-tarkov.com/SPT-AKI/Launcher.git@${{ steps.determine-context.outputs.branch_launcher }}"
)
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
TAG="${{ steps.determine-context.outputs.target_tag }}"
REPOS=("https://dev.sp-tarkov.com/SPT-AKI/Server.git" "https://dev.sp-tarkov.com/SPT-AKI/Modules.git" "https://dev.sp-tarkov.com/SPT-AKI/Launcher.git")
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
echo "::set-output name=proceed::${PROCEED}"
shell: bash
- name: Halt Workflow if Necessary
if: steps.check-existence.outputs.proceed == 'false'
run: |
echo "Required branch/tag not found in one or more repositories, halting workflow."
exit 1
shell: bash
- name: Extract Versions
id: versions
run: |
2024-03-26 13:17:09 -04:00
rm -rf /workspace/SPT-AKI/Build/server-core
git init /workspace/SPT-AKI/Build/server-core
cd /workspace/SPT-AKI/Build/server-core
2024-03-12 00:26:35 -04:00
git remote add origin https://dev.sp-tarkov.com/SPT-AKI/Server.git
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
REF=${{ steps.determine-context.outputs.target_tag }}
fi
2024-03-12 00:26:35 -04:00
# Fetch and checkout the specific reference (branch or tag)
git fetch --depth=1 origin "${REF}"
git checkout FETCH_HEAD
ls -la project/assets/configs
2024-03-12 00:26:35 -04:00
# Extract versions from core.json
cd project/assets/configs
SPT_VERSION=$(jq -r '.akiVersion' core.json)
FULL_VERSION=$(jq -r '.compatibleTarkovVersion' core.json)
CLIENT_VERSION=${FULL_VERSION##*.}
2024-03-12 00:26:35 -04:00
echo "::set-output name=client_version::${CLIENT_VERSION}"
echo "::set-output name=spt_version::${SPT_VERSION}"
shell: bash
- name: Extract Mod Configurations
id: mod-config
run: |
2024-03-26 13:17:09 -04:00
rm -rf /workspace/SPT-AKI/Build/server-mods-config
git init /workspace/SPT-AKI/Build/server-mods-config
cd /workspace/SPT-AKI/Build/server-mods-config
git remote add origin https://dev.sp-tarkov.com/SPT-AKI/Server.git
git config core.sparseCheckout true
echo "project/src/ide/BleedingEdgeEntry.ts" >> .git/info/sparse-checkout
echo "project/src/ide/BleedingEdgeModsEntry.ts" >> .git/info/sparse-checkout
echo "project/src/ide/DebugEntry.ts" >> .git/info/sparse-checkout
echo "project/src/ide/ReleaseEntry.ts" >> .git/info/sparse-checkout
if [[ "${{ steps.determine-context.outputs.is_nightly }}" == "true" ]]; then
REF=${{ steps.determine-context.outputs.branch_server }}
else
REF=${{ steps.determine-context.outputs.target_tag }}
fi
# Fetch and checkout the specific reference (branch or tag)
git fetch --depth=1 origin "${REF}"
git checkout FETCH_HEAD
ls -la project/src/ide
# Function to parse G_MODS_ENABLED value
parse_mods_enabled() {
grep 'G_MODS_ENABLED' $1 | sed -e 's/.*G_MODS_ENABLED\s*=\s*\(.*\);/\1/'
}
# Extract the configuration options
MODS_BLEEDING=$(parse_mods_enabled "project/src/ide/BleedingEdgeEntry.ts")
MODS_BLEEDINGMODS=$(parse_mods_enabled "project/src/ide/BleedingEdgeModsEntry.ts")
MODS_DEBUG=$(parse_mods_enabled "project/src/ide/DebugEntry.ts")
MODS_RELEASE=$(parse_mods_enabled "project/src/ide/ReleaseEntry.ts")
echo "::set-output name=bleeding::${MODS_BLEEDING}"
echo "::set-output name=bleedingmods::${MODS_BLEEDINGMODS}"
echo "::set-output name=debug::${MODS_DEBUG}"
echo "::set-output name=release::${MODS_RELEASE}"
shell: bash
build-server:
2024-03-11 23:17:50 -04:00
needs: [prepare]
if: needs.prepare.outputs.proceed == 'true'
2024-02-29 21:25:58 -05:00
runs-on: ubuntu-latest
2024-03-01 11:12:38 -05:00
container:
image: refringe/spt-build-node:1.0.6
outputs:
server_commit: ${{ steps.clone.outputs.server_commit }}
2024-02-29 21:25:58 -05:00
steps:
- name: Clone
id: clone
run: |
2024-03-26 13:17:09 -04:00
rm -rf /workspace/SPT-AKI/Build/server
2024-03-11 23:17:50 -04:00
if [[ "${{ needs.prepare.outputs.is_nightly }}" == "true" ]]; then
BRANCH=${{ needs.prepare.outputs.branch_server }}
echo "Cloning branch $BRANCH"
2024-03-26 13:17:09 -04:00
git clone https://dev.sp-tarkov.com/SPT-AKI/Server.git --branch "$BRANCH" --depth 1 /workspace/SPT-AKI/Build/server
2024-03-11 23:17:50 -04:00
else
TAG=${{ needs.prepare.outputs.target_tag }}
echo "Cloning tag $TAG"
2024-03-26 13:17:09 -04:00
git clone https://dev.sp-tarkov.com/SPT-AKI/Server.git --branch "$TAG" --depth 1 /workspace/SPT-AKI/Build/server
2024-03-11 23:17:50 -04:00
fi
2024-03-26 13:17:09 -04:00
cd /workspace/SPT-AKI/Build/server
echo "::set-output name=server_commit::$(git rev-parse --short HEAD)"
2024-03-11 23:58:37 -04:00
shell: bash
- name: Pull LFS Files
2024-03-02 14:48:27 -05:00
run: |
2024-03-26 13:17:09 -04:00
cd /workspace/SPT-AKI/Build/server
2024-03-02 14:48:27 -05:00
git lfs pull && git lfs ls-files
2024-03-11 23:58:37 -04:00
shell: bash
- name: Runner Debug Information
2024-03-02 13:59:49 -05:00
run: |
2024-03-26 13:17:09 -04:00
cd /workspace/SPT-AKI/Build/server
echo "Git version: $(git --version)"
echo "Git LFS version: $(git-lfs --version)"
echo "Node.js version: $(node --version)"
echo "NPM version: $(npm --version)"
echo "Latest Commit Hash: $(git rev-parse HEAD)"
echo "Associated Tags: $(git tag --contains HEAD)"
echo "Last Commit Message:" && git log -1 --pretty=%B
2024-03-11 23:58:37 -04:00
shell: bash
2024-03-01 18:54:44 -05:00
2024-03-02 14:07:51 -05:00
- name: Install Dependencies
2024-03-02 14:48:27 -05:00
run: |
2024-03-26 13:17:09 -04:00
cd /workspace/SPT-AKI/Build/server/project
2024-03-12 00:45:50 -04:00
rm -rf package-lock.json node_modules
npm cache clean --force
2024-03-02 14:48:27 -05:00
npm install
2024-03-11 23:58:37 -04:00
shell: bash
2024-03-02 13:59:49 -05:00
2024-03-02 14:07:51 -05:00
- name: Build Server
2024-03-02 14:48:27 -05:00
run: |
2024-03-26 13:17:09 -04:00
cd /workspace/SPT-AKI/Build/server/project
BUILD_TYPE="${{ needs.prepare.outputs.build_type }}"
echo "Running build for $BUILD_TYPE"
npm run build:$BUILD_TYPE -- --arch=x64 --platform=win32
2024-03-04 22:17:07 -05:00
printf "\nBuilt!\n\n"
2024-03-26 13:17:09 -04:00
tree -C /workspace/SPT-AKI/Build/server/project/build
shell: bash
2024-03-02 13:59:49 -05:00
2024-03-09 21:00:36 -05:00
- name: Artifact Server
2024-03-09 00:04:53 -05:00
uses: actions/upload-artifact@v3
with:
2024-03-09 21:00:36 -05:00
name: server-artifact
2024-03-26 13:17:09 -04:00
path: /workspace/SPT-AKI/Build/server/project/build/
compression-level: 0
retention-days: 1
overwrite: true
build-modules:
needs: [prepare]
2024-03-11 23:17:50 -04:00
if: needs.prepare.outputs.proceed == 'true'
runs-on: ubuntu-latest
container:
image: refringe/spt-build-dotnet:1.0.0
steps:
- name: Clone
run: |
2024-03-11 23:17:50 -04:00
if [[ "${{ needs.prepare.outputs.is_nightly }}" == "true" ]]; then
BRANCH=${{ needs.prepare.outputs.branch_modules }}
echo "Cloning modules from branch $BRANCH"
2024-03-26 13:17:09 -04:00
git clone https://dev.sp-tarkov.com/SPT-AKI/Modules.git --branch "$BRANCH" --depth 1 /workspace/SPT-AKI/Build/modules
2024-03-11 23:17:50 -04:00
else
TAG=${{ needs.prepare.outputs.target_tag }}
echo "Cloning modules from tag $TAG"
2024-03-26 13:17:09 -04:00
git clone https://dev.sp-tarkov.com/SPT-AKI/Modules.git --branch "$TAG" --depth 1 /workspace/SPT-AKI/Build/modules
2024-03-11 23:20:10 -04:00
fi
2024-03-11 23:58:37 -04:00
shell: bash
- name: Download Client Module Package
run: |
2024-03-26 13:17:09 -04:00
DIR_MANAGED="/workspace/SPT-AKI/Build/modules/project/Shared/Managed"
DOWNLOAD_PATH="$DIR_MANAGED/${{ needs.prepare.outputs.client_version }}.zip"
DOWNLOAD_URL="${{ secrets.MODULE_DOMAIN }}/${{ needs.prepare.outputs.client_version }}.zip"
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"
shell: bash
- name: Decompress Client Module Package
run: |
2024-03-26 13:17:09 -04:00
cd /workspace/SPT-AKI/Build/modules/project/Shared/Managed
7z x ${{ needs.prepare.outputs.client_version }}.zip -aoa
echo "Client module package decompressed."
shell: bash
- name: Delete Client Module Package
run: |
2024-03-26 13:17:09 -04:00
cd /workspace/SPT-AKI/Build/modules/project/Shared/Managed
rm -f ${{ needs.prepare.outputs.client_version }}.zip
echo "Client module package deleted."
shell: bash
- name: Build Modules
run: |
2024-03-26 13:17:09 -04:00
cd /workspace/SPT-AKI/Build/modules/project
dotnet build -c Release -p:Version=${{ needs.prepare.outputs.spt_version }}
2024-03-04 22:17:07 -05:00
printf "\nBuilt!\n\n"
2024-03-26 13:17:09 -04:00
tree /workspace/SPT-AKI/Build/modules/project/Build
shell: bash
2024-03-09 21:00:36 -05:00
- name: Artifact Modules
2024-03-09 00:04:53 -05:00
uses: actions/upload-artifact@v3
2024-03-04 21:12:10 -05:00
with:
2024-03-09 21:00:36 -05:00
name: modules-artifact
2024-03-26 13:17:09 -04:00
path: /workspace/SPT-AKI/Build/modules/project/Build
compression-level: 0
retention-days: 1
2024-03-04 21:12:10 -05:00
overwrite: true
build-launcher:
needs: [prepare]
2024-03-11 23:17:50 -04:00
if: needs.prepare.outputs.proceed == 'true'
runs-on: ubuntu-latest
container:
image: refringe/spt-build-dotnet:1.0.0
steps:
- name: Clone
run: |
2024-03-11 23:17:50 -04:00
if [[ "${{ needs.prepare.outputs.is_nightly }}" == "true" ]]; then
BRANCH=${{ needs.prepare.outputs.branch_launcher }}
echo "Cloning launcher from branch $BRANCH"
2024-03-26 13:17:09 -04:00
git clone https://dev.sp-tarkov.com/SPT-AKI/Launcher.git --branch "$BRANCH" --depth 1 /workspace/SPT-AKI/Build/launcher
2024-03-11 23:17:50 -04:00
else
TAG=${{ needs.prepare.outputs.target_tag }}
echo "Cloning launcher from tag $TAG"
2024-03-26 13:17:09 -04:00
git clone https://dev.sp-tarkov.com/SPT-AKI/Launcher.git --branch "$TAG" --depth 1 /workspace/SPT-AKI/Build/launcher
2024-03-11 23:20:10 -04:00
fi
2024-03-11 23:58:37 -04:00
shell: bash
2024-03-04 22:24:35 -05:00
- name: Build Launcher
run: |
2024-03-26 13:17:09 -04:00
cd /workspace/SPT-AKI/Build/launcher/project
2024-03-04 22:24:35 -05:00
dotnet build
printf "\nBuilt!\n\n"
2024-03-26 13:17:09 -04:00
tree /workspace/SPT-AKI/Build/launcher/project/Build
2024-03-04 22:24:35 -05:00
shell: bash
2024-03-05 11:22:44 -05:00
2024-03-09 21:00:36 -05:00
- name: Artifact Launcher
2024-03-09 00:04:53 -05:00
uses: actions/upload-artifact@v3
2024-03-05 11:22:44 -05:00
with:
2024-03-09 21:00:36 -05:00
name: launcher-artifact
2024-03-26 13:17:09 -04:00
path: /workspace/SPT-AKI/Build/launcher/project/Build
compression-level: 0
retention-days: 1
2024-03-05 11:22:44 -05:00
overwrite: true
assemble-release:
2024-03-11 23:17:50 -04:00
needs: [prepare, build-server, build-modules, build-launcher]
runs-on: ubuntu-latest
container:
image: refringe/spt-build-node:1.0.6
outputs:
2024-03-11 14:43:56 -04:00
base_name: ${{ steps.generate-filename.outputs.base_name }}
2024-03-09 21:15:23 -05:00
build_name: ${{ steps.generate-filename.outputs.build_name }}
steps:
2024-03-12 00:26:35 -04:00
- name: Clean Directory
run: |
2024-03-26 13:17:09 -04:00
rm -rf /workspace/SPT-AKI/Build/release /workspace/SPT-AKI/Build/build
mkdir -p /workspace/SPT-AKI/Build/release
2024-03-12 00:26:35 -04:00
shell: bash
- name: Download Server Artifact
uses: actions/download-artifact@v3
with:
name: server-artifact
2024-03-26 13:17:09 -04:00
path: /workspace/SPT-AKI/Build/release/
2024-03-12 00:26:35 -04:00
- name: Download Modules Artifact
uses: actions/download-artifact@v3
with:
name: modules-artifact
2024-03-26 13:17:09 -04:00
path: /workspace/SPT-AKI/Build/release/
2024-03-12 00:26:35 -04:00
- name: Download Launcher Artifact
uses: actions/download-artifact@v3
with:
name: launcher-artifact
2024-03-26 13:17:09 -04:00
path: /workspace/SPT-AKI/Build/release/
2024-03-12 00:26:35 -04:00
- name: Clone Build Project
uses: actions/checkout@v3
with:
2024-03-26 13:17:09 -04:00
path: /workspace/SPT-AKI/Build/build
2024-03-12 00:26:35 -04:00
- name: Merge Static Assets and Dynamic Files
2024-03-26 13:17:09 -04:00
run: cp -rvf /workspace/SPT-AKI/Build/build/static-assets/* /workspace/SPT-AKI/Build/release/
2024-03-12 00:26:35 -04:00
shell: bash
- name: List Release Contents
2024-03-26 13:17:09 -04:00
run: tree /workspace/SPT-AKI/Build/release
2024-03-12 00:26:35 -04:00
shell: bash
- name: Generate Release Filename
id: generate-filename
run: |
BUILD_TYPE=${{ needs.prepare.outputs.build_type }}
2024-03-12 00:26:35 -04:00
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 }}
2024-03-12 00:26:35 -04:00
DATE=$(date +%Y%m%d)
# Conditionally format the BASE_NAME based on BUILD_TYPE and if it's a nightly build
if [[ "${{ needs.prepare.outputs.is_nightly }}" == "true" ]]; then
BASE_NAME="SPT-NIGHTLY-${SPT_VERSION}-${CLIENT_VERSION}-${SERVER_COMMIT}-${DATE}"
2024-03-12 00:26:35 -04:00
else
# Make BUILD_TYPE and TARGET_TAG uppercase
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}"
else
# For debug and non-nightly-bleeding builds, include either TAG_PART or DATE, but not both
# Determine TAG_PART based on TARGET_TAG structure
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
fi
2024-03-12 00:26:35 -04:00
fi
echo "::set-output name=base_name::${BASE_NAME}"
echo "::set-output name=build_name::${BASE_NAME}.7z"
shell: bash
- name: Artifact Release
uses: actions/upload-artifact@v3
with:
name: release-artifact
2024-03-26 13:17:09 -04:00
path: /workspace/SPT-AKI/Build/release
2024-03-12 00:26:35 -04:00
compression-level: 0
retention-days: 1
overwrite: true
2024-03-09 21:00:36 -05:00
publish-release:
needs: [prepare, assemble-release, build-server]
runs-on: ubuntu-latest
container:
image: refringe/spt-build-node:1.0.6
steps:
2024-03-12 00:26:35 -04:00
- name: Download Release Artifact
uses: actions/download-artifact@v3
with:
name: release-artifact
2024-03-26 13:17:09 -04:00
path: /workspace/SPT-AKI/Build/release
2024-03-09 15:00:30 -05:00
2024-03-12 00:26:35 -04:00
- name: Compress Release
run: |
2024-03-26 13:17:09 -04:00
cd /workspace/SPT-AKI/Build/release
2024-03-12 00:26:35 -04:00
7z a -mx=9 -m0=lzma2 "../${{ needs.assemble-release.outputs.build_name }}" ./*
echo "Release compressed as ${{ needs.assemble-release.outputs.build_name }}."
shell: bash
2024-03-12 00:26:35 -04:00
- name: Upload Release to HTTPS Source
id: upload-https-7z
run: |
2024-03-26 13:17:09 -04:00
cd /workspace/SPT-AKI/Build/
2024-03-12 00:26:35 -04:00
echo "${{ secrets.SFTP_HOST_KEY }}" > known_host
2024-03-26 13:17:09 -04:00
sshpass -p "${{ secrets.SFTP_PASSWORD }}" scp -v -o "Port=${{ secrets.SFTP_PORT }}" -o "ConnectTimeout=20" -o "UserKnownHostsFile=known_host" -o "StrictHostKeyChecking=yes" "/workspace/SPT-AKI/Build/${{ needs.assemble-release.outputs.build_name }}" ${{ secrets.SFTP_USERNAME }}@${{ secrets.SFTP_HOST }}:/public/builds
echo "::set-output name=link_https::${{ secrets.SFTP_MIRROR_LINK }}/builds/${{ needs.assemble-release.outputs.build_name }}"
2024-03-12 00:26:35 -04:00
shell: bash
- name: Create Torrent File
if: needs.prepare.outputs.build_type == 'release'
2024-03-12 00:26:35 -04:00
id: torrent_create
run: |
BASE_NAME="${{ needs.assemble-release.outputs.base_name }}"
BUILD_NAME="${{ needs.assemble-release.outputs.build_name }}"
TORRENT_NAME="${BASE_NAME}.torrent"
2024-03-26 13:17:09 -04:00
TORF_OUTPUT=$(/opt/venv/bin/torf --yes --out "/workspace/SPT-AKI/Build/${TORRENT_NAME}" \
2024-03-12 00:26:35 -04:00
--webseed "${{ steps.upload-https-7z.outputs.link_https }}" \
--tracker "http://open.acgnxtracker.com:80/announce,https://tracker.tamersunion.org:443/announce,http://tracker.renfei.net:8080/announce,udp://tracker.torrent.eu.org:451/announce,udp://ec2-18-191-163-220.us-east-2.compute.amazonaws.com:6969/announce" \
--comment "Official ${BASE_NAME} release, built by the team at sp-tarkov.com. Have fun!" \
--creator "sp-tarkov.com" \
--verbose \
2024-03-26 13:17:09 -04:00
"/workspace/SPT-AKI/Build/${{ needs.assemble-release.outputs.build_name }}")
2024-03-12 00:26:35 -04:00
MAGNET_LINK=$(echo "${TORF_OUTPUT}" | grep -oP 'Magnet\t\K.*')
echo "::set-output name=link_magnet::${MAGNET_LINK}"
echo "::set-output name=torrent_name::${TORRENT_NAME}"
shell: bash
- name: Upload Torrent to HTTPS Source
if: needs.prepare.outputs.build_type == 'release'
2024-03-12 00:26:35 -04:00
id: upload-https-torrent
run: |
2024-03-26 13:17:09 -04:00
cd /workspace/SPT-AKI/Build/
2024-03-12 00:26:35 -04:00
echo "${{ secrets.SFTP_HOST_KEY }}" > known_host
2024-03-26 13:17:09 -04:00
sshpass -p "${{ secrets.SFTP_PASSWORD }}" scp -v -o "Port=${{ secrets.SFTP_PORT }}" -o "ConnectTimeout=20" -o "UserKnownHostsFile=known_host" -o "StrictHostKeyChecking=yes" "/workspace/SPT-AKI/Build/${{ steps.torrent_create.outputs.torrent_name }}" ${{ secrets.SFTP_USERNAME }}@${{ secrets.SFTP_HOST }}:/public/builds
echo "::set-output name=link_torrent::${{ secrets.SFTP_MIRROR_LINK }}/builds/${{ steps.torrent_create.outputs.torrent_name }}"
2024-03-12 00:26:35 -04:00
shell: bash
2024-03-12 00:26:35 -04:00
- name: Clean Old HTTPS Source Releases
run: |
2024-03-26 13:17:09 -04:00
cd /workspace/SPT-AKI/Build/
2024-03-12 00:26:35 -04:00
echo "${{ secrets.SFTP_HOST_KEY }}" > known_hosts
2024-03-12 00:26:35 -04:00
# Creating a script for sftp to execute
echo "cd /public/builds" > sftp_commands.txt
2024-03-12 00:26:35 -04:00
echo "ls" >> sftp_commands.txt
2024-03-12 00:26:35 -04:00
# Fetch a remote list of files
FILE_LIST=$(sshpass -p "${{ secrets.SFTP_PASSWORD }}" sftp -oBatchMode=no -oPort=${{ secrets.SFTP_PORT }} -oUserKnownHostsFile=known_hosts -oStrictHostKeyChecking=yes -b sftp_commands.txt ${{ secrets.SFTP_USERNAME }}@${{ secrets.SFTP_HOST }})
2024-03-06 23:41:39 -05:00
2024-03-12 00:26:35 -04:00
echo "Files listed:"
echo "$FILE_LIST"
2024-03-12 00:26:35 -04:00
# Filtering and processing the file list
echo "$FILE_LIST" | tr ' ' '\n' | grep -E 'SPT-(NIGHTLY|DEBUG|BLEEDING|BLEEDINGMODS).*\.(7z|torrent)$' | while read filename; do
echo "Processing file: $filename"
# Extract date from filename
if [[ "$filename" =~ ([0-9]{8})\.(7z|torrent)$ ]]; then
file_date="${BASH_REMATCH[1]}"
file_date_fmt=$(date -d "${file_date:0:4}-${file_date:4:2}-${file_date:6:2}" +%s)
current_date=$(date +%s)
limit_date=$(date -d "@$((current_date - 14 * 24 * 3600))" +%s)
if [[ "$file_date_fmt" -lt "$limit_date" ]]; then
echo "Marked for deletion: $filename"
echo "rm \"/public/builds/$filename\"" >> delete_commands.txt
fi
fi
2024-03-12 00:26:35 -04:00
done
# Check if there are files to delete and execute
if [ -s delete_commands.txt ]; then
echo "Running deletion task..."
sshpass -p "${{ secrets.SFTP_PASSWORD }}" sftp -oBatchMode=no -oPort=${{ secrets.SFTP_PORT }} -oUserKnownHostsFile=known_hosts -oStrictHostKeyChecking=yes -b delete_commands.txt ${{ secrets.SFTP_USERNAME }}@${{ secrets.SFTP_HOST }}
else
echo "No old files to delete."
fi
shell: bash
- name: Upload Release to Mega
id: upload-mega
run: |
mega-https on
mega-login "${{ secrets.MEGA_EMAIL }}" "${{ secrets.MEGA_PASSWORD }}"
2024-03-26 13:17:09 -04:00
mega-put -c "/workspace/SPT-AKI/Build/${{ needs.assemble-release.outputs.build_name }}" "/spt-release/${{ needs.assemble-release.outputs.build_name }}"
2024-03-12 00:26:35 -04:00
# Generate link and save it.
EXPORT_OUTPUT=$(mega-export -a "/spt-release/${{ needs.assemble-release.outputs.build_name }}" -f)
LINK_MEGA=$(echo "$EXPORT_OUTPUT" | grep -o 'https://mega.nz/file/[A-Za-z0-9#_\-]*')
echo "::set-output name=link_mega::${LINK_MEGA}"
mega-logout
shell: bash
- name: Clean Old Mega Releases
run: |
mega-https on
mega-login "${{ secrets.MEGA_EMAIL }}" "${{ secrets.MEGA_PASSWORD }}"
# List files and filter out old NIGHTLY, DEBUG, or BLEEDING files
mega-ls /spt-release | grep -E 'SPT-(NIGHTLY|DEBUG|BLEEDING|BLEEDINGMODS).*\.7z$' | while read -r filename; do
2024-03-12 00:26:35 -04:00
# Extract date from filename
if [[ "$filename" =~ ([0-9]{8})\.7z$ ]]; then
file_date="${BASH_REMATCH[1]}"
file_date_fmt=$(date -d "${file_date:0:4}-${file_date:4:2}-${file_date:6:2}" +%s)
# Get current date minus 14 days
2024-03-12 00:26:35 -04:00
current_date=$(date +%s)
limit_date=$(date -d "@$((current_date - 14 * 24 * 3600))" +%s)
2024-03-12 00:26:35 -04:00
# Compare dates and delete old files
if [[ "$file_date_fmt" -lt "$limit_date" ]]; then
echo "Deleting old file: $filename"
mega-rm "/spt-release/$filename"
fi
2024-03-11 11:22:01 -04:00
fi
2024-03-12 00:26:35 -04:00
done
# Remove old file versions to save space.
mega-deleteversions -f /spt-release/*
mega-logout
shell: bash
- name: Post Build Info to Discord
env:
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
BUILD_TYPE: ${{ needs.prepare.outputs.build_type }}
2024-03-12 00:26:35 -04:00
BASE_NAME: ${{ needs.assemble-release.outputs.base_name }}
BUILD_NAME: ${{ needs.assemble-release.outputs.build_name }}
LINK_MEGA: ${{ steps.upload-mega.outputs.link_mega }}
LINK_HTTPS: ${{ steps.upload-https-7z.outputs.link_https }}
LINK_TORRENT: ${{ steps.upload-https-torrent.outputs.link_torrent }}
MODS_ENABLED_BLEEDING: ${{ needs.prepare.outputs.mod_enabled_bleeding }}
MODS_ENABLED_BLEEDINGMODS: ${{ needs.prepare.outputs.mod_enabled_bleedingmods }}
MODS_ENABLED_DEBUG: ${{ needs.prepare.outputs.mod_enabled_debug }}
MODS_ENABLED_RELEASE: ${{ needs.prepare.outputs.mod_enabled_release }}
2024-03-12 00:26:35 -04:00
run: |
2024-03-26 13:17:09 -04:00
cd /workspace/SPT-AKI/Build/
2024-03-14 22:26:22 -04:00
UPPER_BUILD_TYPE=$(echo "$BUILD_TYPE" | tr '[:lower:]' '[:upper:]')
FOOTER_MESSAGES=("You look great today!" "Don't ban me, Phantom!" "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")
2024-03-12 00:26:35 -04:00
FOOTER_MESSAGE="${FOOTER_MESSAGES[$RANDOM % ${#FOOTER_MESSAGES[@]}]}"
TIMESTAMP=$(date --iso-8601=seconds)
FILE_SIZE_MB=$(stat -c %s "$BUILD_NAME" | awk '{printf "%.2f MB", $1 / 1024 / 1024}')
FILE_HASH=$(sha256sum "$BUILD_NAME" | awk '{print $1}')
MODS=""
2024-03-12 00:26:35 -04:00
if [[ "${{ needs.prepare.outputs.is_nightly }}" == "true" ]]; then
2024-03-14 22:26:22 -04:00
EMBED_COLOR=16705372
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.'
MODS="$MODS_ENABLED_BLEEDINGMODS"
2024-03-12 00:26:35 -04:00
else
if [ "$BUILD_TYPE" == "bleeding" ]; then
2024-03-14 12:20:23 -04:00
EMBED_COLOR=15548997
2024-03-14 22:26:22 -04: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.'
MODS="$MODS_ENABLED_BLEEDING"
elif [ "$BUILD_TYPE" == "bleedingmods" ]; then
EMBED_COLOR=15548997
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.'
MODS="$MODS_ENABLED_BLEEDINGMODS"
elif [ "$BUILD_TYPE" == "debug" ]; then
2024-03-14 12:20:23 -04:00
EMBED_COLOR=2123412
2024-03-14 22:26:22 -04: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.'
MODS="$MODS_ENABLED_DEBUG"
else
2024-03-14 12:20:23 -04:00
EMBED_COLOR=5763719
2024-03-14 22:26:22 -04:00
EMBED_DESCRIPTION=$'A new stable build is now ready for download. 7-Zip is *required* to extract the release. Have fun! 🎉'
MODS="$MODS_ENABLED_RELEASE"
fi
2024-03-12 00:26:35 -04:00
fi
2024-03-14 22:50:58 -04:00
fields_json='[
{"name": "Name", "value": "'"$BASE_NAME"'"},
{"name": "Type", "value": "'"$BUILD_TYPE"'", "inline": true},
{"name": "Mods Enabled", "value": "'"$MODS"'", "inline": true},
{"name": "File Size", "value": "'"$FILE_SIZE_MB"'", "inline": true},
{"name": "SHA-256 Hash", "value": "'"$FILE_HASH"'"},
{"name": "Primary Download Link", "value": "'"$LINK_MEGA"'"}
]'
if [ "$BUILD_TYPE" = "release" ]; then
2024-03-14 23:02:25 -04:00
fields_json=$(echo "$fields_json" | jq --arg LINK_TORRENT "$LINK_TORRENT" '. += [{"name": "Torrent Link", "value": $LINK_TORRENT}]')
2024-03-14 22:50:58 -04:00
fi
2024-03-14 23:02:25 -04:00
fields_json=$(echo "$fields_json" | jq --arg LINK_HTTPS "$LINK_HTTPS" '. += [{"name": "Fallback Mirror", "value": $LINK_HTTPS}]')
2024-03-14 22:50:58 -04:00
payload=$(jq -n \
--argjson fields "$fields_json" \
2024-03-12 00:26:35 -04:00
--arg EMBED_DESCRIPTION "$EMBED_DESCRIPTION" \
2024-03-14 22:50:58 -04:00
--argjson EMBED_COLOR "$EMBED_COLOR" \
2024-03-12 00:26:35 -04:00
--arg FOOTER_MESSAGE "$FOOTER_MESSAGE" \
--arg TIMESTAMP "$TIMESTAMP" \
'{
2024-03-14 22:26:22 -04:00
"content": $EMBED_DESCRIPTION,
2024-03-12 00:26:35 -04:00
"embeds": [
{
2024-03-14 22:33:56 -04:00
"title": "Build Information",
"color": $EMBED_COLOR,
2024-03-14 22:50:58 -04:00
"fields": $fields,
"footer": {"text": $FOOTER_MESSAGE, "icon_url": "https://i.imgur.com/28JJJec.png"},
2024-03-14 22:33:56 -04:00
"timestamp": $TIMESTAMP
2024-03-12 00:26:35 -04:00
}
2024-03-14 22:26:22 -04:00
],
"username": "BuildBot",
"avatar_url": "https://i.imgur.com/28JJJec.png"
2024-03-14 22:50:58 -04:00
}')
echo "$payload" > payload_discord.json
2024-03-12 00:26:35 -04:00
echo "Payload Generated:"
cat payload_discord.json
echo "Sending Payload..."
curl -H "Content-Type: application/json" \
-X POST \
--data-binary @payload_discord.json \
2024-03-23 15:11:58 -04:00
-v \
2024-03-12 00:26:35 -04:00
$DISCORD_WEBHOOK_URL
shell: bash