0
0
mirror of https://github.com/sp-tarkov/build.git synced 2025-02-13 08:10:46 -05:00

First pass at nightly builds

This commit is contained in:
Refringe 2024-03-11 23:17:50 -04:00
parent 3a912dab01
commit a041e1fcd3
Signed by: Refringe
GPG Key ID: 7715B85B4A6306ED

View File

@ -1,57 +1,98 @@
name: SPT Release Build name: SPT Release Build
on: on:
push: push:
branches: [ main ] branches: [ main ]
pull_request: pull_request:
branches: [ main ] branches: [ main ]
schedule:
- cron: '0 19 * * *' # 7pm UTC/3pm ET, every day
jobs: jobs:
check-tag-exists: prepare:
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs: outputs:
proceed: ${{ steps.check.outputs.proceed }} proceed: ${{ steps.check-existence.outputs.proceed }}
target_tag: ${{ steps.check.outputs.target_tag }} 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 }}
steps: steps:
- name: Check Tag Exists in All Repositories - name: Determine Build Context
id: check id: determine-context
run: | run: |
# The tag needs to be saved as a variable so that it can be used throughout the build process. echo "Determining build context..."
TAG="3.8.0-BE-20240308" if [[ "${{ github.event_name }}" == "schedule" ]]; then
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") echo "::set-output name=is_nightly::true"
PROCEED="true" echo "::set-output name=branch_server::3.8.0"
for REPO in ${REPOS[@]}; do echo "::set-output name=branch_modules::3.8.0"
echo "Checking for tag $TAG in $REPO..." echo "::set-output name=branch_launcher::3.8.0"
if ! git ls-remote --tags $REPO $TAG | grep -q $TAG; then else
echo "Tag $TAG not found in $REPO" echo "::set-output name=is_nightly::false"
PROCEED="false" echo "::set-output name=target_tag::3.8.0-BE-20240308"
break fi
fi
done
echo "::set-output name=proceed::${PROCEED}"
echo "::set-output name=target_tag::${TAG}"
shell: bash
- name: Tag Not Found - name: Check Existence
if: steps.check.outputs.proceed == 'false' id: check-existence
run: | run: |
echo "Tag not found in one or more repositories, halting workflow." 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}"
- 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 exit 1
build-server: build-server:
needs: check-tag-exists needs: [prepare]
if: needs.check-tag-exists.outputs.proceed == 'true' if: needs.prepare.outputs.proceed == 'true'
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: container:
image: refringe/spt-build-node:1.0.5 image: refringe/spt-build-node:1.0.5
outputs: outputs:
build_type: ${{ steps.build-type.outputs.build_type }} build_type: ${{ steps.build-type.outputs.build_type }}
client_version: ${{ steps.version.outputs.client_version }}
spt_version: ${{ steps.version.outputs.spt_version }}
steps: steps:
- name: Clone - name: Clone
run: | run: |
TARGET_TAG=${{ needs.check-tag-exists.outputs.target_tag }} if [[ "${{ needs.prepare.outputs.is_nightly }}" == "true" ]]; then
rm -rf /workspace/refringe/Build/server BRANCH=${{ needs.prepare.outputs.branch_server }}
git clone https://dev.sp-tarkov.com/SPT-AKI/Server.git --branch "${TARGET_TAG}" --depth 1 /workspace/refringe/Build/server echo "Cloning branch $BRANCH"
git clone https://dev.sp-tarkov.com/SPT-AKI/Server.git --branch "$BRANCH" --depth 1 /workspace/refringe/Build/server
else
TAG=${{ needs.prepare.outputs.target_tag }}
echo "Cloning tag $TAG"
git clone https://dev.sp-tarkov.com/SPT-AKI/Server.git --branch "$TAG" --depth 1 /workspace/refringe/Build/server
fi
- name: Pull LFS Files - name: Pull LFS Files
run: | run: |
@ -69,54 +110,54 @@ jobs:
echo "Associated Tags: $(git tag --contains HEAD)" echo "Associated Tags: $(git tag --contains HEAD)"
echo "Last Commit Message:" && git log -1 --pretty=%B echo "Last Commit Message:" && git log -1 --pretty=%B
- name: Cache Keys
id: cache-keys
run: |
cd /workspace/refringe/Build/server
echo "::set-output name=commit_hash::$(git rev-parse HEAD)"
TAGS=$(git tag --contains HEAD || echo "no-tag")
if [ -z "$TAGS" ]; then
TAGS="no-tag"
fi
TAGS="${TAGS//$'\n'/-}" # Replace newline characters with dashes
TAGS="${TAGS//,/-}" # Replace commas with dashes
echo "::set-output name=tags::${TAGS}"
echo "Commit Hash: ${{ steps.cache-keys.outputs.commit_hash }}"
echo "Tags: ${{ steps.cache-keys.outputs.tags }}"
shell: bash
- name: Determine Build Type - name: Determine Build Type
id: build-type id: build-type
run: | run: |
TAGS="${{ steps.cache-keys.outputs.tags }}" # Check if this is a nightly build
BUILD_TYPE="debug" # Default if [[ "${{ needs.prepare.outputs.is_nightly }}" == "true" ]]; then
if [[ "$TAGS" =~ -BE ]]; then # Nightly builds are always considered "bleeding"
BUILD_TYPE="bleeding" BUILD_TYPE="bleeding"
elif [[ "$TAGS" =~ ^(v?\d+\.\d+\.\d+)$ ]]; then else
BUILD_TYPE="release" cd /workspace/refringe/Build/server
# Prepare tags for check
TAGS=$(git tag --contains HEAD || echo "no-tag")
if [ -z "$TAGS" ]; then
TAGS="no-tag"
fi
TAGS="${TAGS//$'\n'/-}" # Replace newline characters with dashes
TAGS="${TAGS//,/-}" # Replace commas with dashes
# Debug build by default
# Bleeding builds have "-BE" in the tag
# Release tags follow basic semantic versioning
BUILD_TYPE="debug"
if [[ "$TAGS" =~ -BE ]]; then
BUILD_TYPE="bleeding"
elif [[ "$TAGS" =~ ^(v?\d+\.\d+\.\d+)$ ]]; then
BUILD_TYPE="release"
fi
fi fi
echo "::set-output name=build_type::${BUILD_TYPE}" echo "::set-output name=build_type::${BUILD_TYPE}"
shell: bash shell: bash
- name: Build Cache - name: Determine Versions
id: build-cache id: version
uses: actions/cache@v4 run: |
with: cd /workspace/refringe/Build/server/project/assets/configs
path: /workspace/refringe/Build/server/project/build SPT_VERSION=$(jq -r '.akiVersion' core.json)
key: build-${{ steps.cache-keys.outputs.commit_hash }}-${{ steps.cache-keys.outputs.tags }}-${{ steps.build-type.outputs.build_type }} FULL_VERSION=$(jq -r '.compatibleTarkovVersion' core.json)
restore-keys: | CLIENT_VERSION=${FULL_VERSION##*.}
build-${{ steps.cache-keys.outputs.commit_hash }}-${{ steps.cache-keys.outputs.tags }}- echo "::set-output name=client_version::${CLIENT_VERSION}"
build-${{ steps.cache-keys.outputs.commit_hash }}- echo "::set-output name=spt_version::${SPT_VERSION}"
build- shell: bash
- name: Install Dependencies - name: Install Dependencies
if: steps.build-cache.outputs.cache-hit != 'true'
run: | run: |
cd /workspace/refringe/Build/server/project cd /workspace/refringe/Build/server/project
npm install npm install
- name: Build Server - name: Build Server
if: steps.build-cache.outputs.cache-hit != 'true'
run: | run: |
cd /workspace/refringe/Build/server/project cd /workspace/refringe/Build/server/project
BUILD_TYPE="${{ steps.build-type.outputs.build_type }}" BUILD_TYPE="${{ steps.build-type.outputs.build_type }}"
@ -136,52 +177,28 @@ jobs:
overwrite: true overwrite: true
build-modules: build-modules:
needs: check-tag-exists needs: [prepare, build-server]
if: needs.check-tag-exists.outputs.proceed == 'true' if: needs.prepare.outputs.proceed == 'true'
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: container:
image: refringe/spt-build-dotnet:1.0.0 image: refringe/spt-build-dotnet:1.0.0
outputs:
spt_version: ${{ steps.extract-client-version.outputs.spt_version }}
client_version: ${{ steps.extract-client-version.outputs.client_version }}
steps: steps:
- name: Clone - name: Clone
run: | run: |
TARGET_TAG=${{ needs.check-tag-exists.outputs.target_tag }} if [[ "${{ needs.prepare.outputs.is_nightly }}" == "true" ]]; then
rm -rf /workspace/refringe/Build/modules BRANCH=${{ needs.prepare.outputs.branch_modules }}
git clone https://dev.sp-tarkov.com/SPT-AKI/Modules.git --branch "${TARGET_TAG}" --depth 1 /workspace/refringe/Build/modules echo "Cloning modules from branch $BRANCH"
git clone https://dev.sp-tarkov.com/SPT-AKI/Modules.git --branch "$BRANCH" --depth 1 /workspace/refringe/Build/modules
- name: Fetch Server Core Config else
run: | TAG=${{ needs.prepare.outputs.target_tag }}
TARGET_TAG=${{ needs.check-tag-exists.outputs.target_tag }} echo "Cloning modules from tag $TAG"
rm -rf /workspace/refringe/Build/server-core git clone https://dev.sp-tarkov.com/SPT-AKI/Modules.git --branch "$TAG" --depth 1 /workspace/refringe/Build/modules
git init /workspace/refringe/Build/server-core
cd /workspace/refringe/Build/server-core
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
git fetch --depth=1 origin "${TARGET_TAG}"
git checkout FETCH_HEAD
ls -la project/assets/configs
shell: bash
- name: Extract Client Version
id: extract-client-version
run: |
cd /workspace/refringe/Build/server-core/project/assets/configs
SPT_VERSION=$(jq -r '.akiVersion' core.json)
FULL_VERSION=$(jq -r '.compatibleTarkovVersion' core.json)
CLIENT_VERSION=${FULL_VERSION##*.}
echo "Extracted Client Version: $CLIENT_VERSION"
echo "::set-output name=client_version::${CLIENT_VERSION}"
echo "::set-output name=spt_version::${SPT_VERSION}"
shell: bash
- name: Download Client Module Package - name: Download Client Module Package
run: | run: |
DIR_MANAGED="/workspace/refringe/Build/modules/project/Shared/Managed" DIR_MANAGED="/workspace/refringe/Build/modules/project/Shared/Managed"
DOWNLOAD_PATH="$DIR_MANAGED/${{ steps.extract-client-version.outputs.client_version }}.zip" DOWNLOAD_PATH="$DIR_MANAGED/${{ needs.build-server.outputs.client_version }}.zip"
DOWNLOAD_URL="$MODULE_DOMAIN/${{ steps.extract-client-version.outputs.client_version }}.zip" DOWNLOAD_URL="${{ secrets.MODULE_DOMAIN }}/${{ needs.build-server.outputs.client_version }}.zip"
echo "Downloading Client Module Package from $DOWNLOAD_URL to $DOWNLOAD_PATH" echo "Downloading Client Module Package from $DOWNLOAD_URL to $DOWNLOAD_PATH"
mkdir -p "$DIR_MANAGED" mkdir -p "$DIR_MANAGED"
wget -q -O "$DOWNLOAD_PATH" "$DOWNLOAD_URL" || { wget -q -O "$DOWNLOAD_PATH" "$DOWNLOAD_URL" || {
@ -194,20 +211,18 @@ jobs:
fi fi
echo "Download Successful: $DOWNLOAD_PATH" echo "Download Successful: $DOWNLOAD_PATH"
shell: bash shell: bash
env:
MODULE_DOMAIN: ${{ secrets.MODULE_DOMAIN }}
- name: Decompress Client Module Package - name: Decompress Client Module Package
run: | run: |
cd /workspace/refringe/Build/modules/project/Shared/Managed cd /workspace/refringe/Build/modules/project/Shared/Managed
7z x ${{ steps.extract-client-version.outputs.client_version }}.zip -aoa 7z x ${{ needs.build-server.outputs.client_version }}.zip -aoa
echo "Client module package decompressed." echo "Client module package decompressed."
shell: bash shell: bash
- name: Delete Client Module Package - name: Delete Client Module Package
run: | run: |
cd /workspace/refringe/Build/modules/project/Shared/Managed cd /workspace/refringe/Build/modules/project/Shared/Managed
rm -f ${{ steps.extract-client-version.outputs.client_version }}.zip rm -f ${{ needs.build-server.outputs.client_version }}.zip
echo "Client module package deleted." echo "Client module package deleted."
shell: bash shell: bash
@ -229,17 +244,22 @@ jobs:
overwrite: true overwrite: true
build-launcher: build-launcher:
needs: check-tag-exists needs: [prepare, build-server]
if: needs.check-tag-exists.outputs.proceed == 'true' if: needs.prepare.outputs.proceed == 'true'
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: container:
image: refringe/spt-build-dotnet:1.0.0 image: refringe/spt-build-dotnet:1.0.0
steps: steps:
- name: Clone - name: Clone
run: | run: |
TARGET_TAG=${{ needs.check-tag-exists.outputs.target_tag }} if [[ "${{ needs.prepare.outputs.is_nightly }}" == "true" ]]; then
rm -rf /workspace/refringe/Build/launcher BRANCH=${{ needs.prepare.outputs.branch_launcher }}
git clone https://dev.sp-tarkov.com/SPT-AKI/Launcher.git --branch "${TARGET_TAG}" --depth 1 /workspace/refringe/Build/launcher echo "Cloning launcher from branch $BRANCH"
git clone https://dev.sp-tarkov.com/SPT-AKI/Launcher.git --branch "$BRANCH" --depth 1 /workspace/refringe/Build/launcher
else
TAG=${{ needs.prepare.outputs.target_tag }}
echo "Cloning launcher from tag $TAG"
git clone https://dev.sp-tarkov.com/SPT-AKI/Launcher.git --branch "$TAG" --depth 1 /workspace/refringe/Build/launcher
- name: Build Launcher - name: Build Launcher
run: | run: |
@ -259,7 +279,7 @@ jobs:
overwrite: true overwrite: true
assemble-release: assemble-release:
needs: [check-tag-exists, build-server, build-modules, build-launcher] needs: [prepare, build-server, build-modules, build-launcher]
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: container:
image: refringe/spt-build-node:1.0.5 image: refringe/spt-build-node:1.0.5
@ -307,8 +327,8 @@ jobs:
id: generate-filename id: generate-filename
run: | run: |
BUILD_TYPE=${{ needs.build-server.outputs.build_type }} BUILD_TYPE=${{ needs.build-server.outputs.build_type }}
SPT_VERSION=${{ needs.build-modules.outputs.spt_version }} SPT_VERSION=${{ needs.build-server.outputs.spt_version }}
CLIENT_VERSION=${{ needs.build-modules.outputs.client_version }} CLIENT_VERSION=${{ needs.build-server.outputs.client_version }}
DATE=$(date +%Y%m%d) DATE=$(date +%Y%m%d)
# Make BUILD_TYPE uppercase # Make BUILD_TYPE uppercase
@ -335,7 +355,7 @@ jobs:
overwrite: true overwrite: true
publish-release: publish-release:
needs: [assemble-release, determine-build-type, build-server] needs: [assemble-release, build-server]
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: container:
image: refringe/spt-build-node:1.0.5 image: refringe/spt-build-node:1.0.5
@ -371,7 +391,7 @@ jobs:
TORF_OUTPUT=$(/opt/venv/bin/torf --yes --out "/workspace/refringe/Build/${TORRENT_NAME}" \ TORF_OUTPUT=$(/opt/venv/bin/torf --yes --out "/workspace/refringe/Build/${TORRENT_NAME}" \
--webseed "${{ steps.upload-https-7z.outputs.link_https }}" \ --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" \ --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 "Offical ${BASE_NAME} release, built by the team at sp-tarkov.com. Have fun!" \ --comment "Official ${BASE_NAME} release, built by the team at sp-tarkov.com. Have fun!" \
--creator "sp-tarkov.com" \ --creator "sp-tarkov.com" \
--verbose \ --verbose \
"/workspace/refringe/Build/${{ needs.assemble-release.outputs.build_name }}") "/workspace/refringe/Build/${{ needs.assemble-release.outputs.build_name }}")
@ -482,10 +502,10 @@ jobs:
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
BUILD_TYPE: ${{ needs.build-server.outputs.build_type }} BUILD_TYPE: ${{ needs.build-server.outputs.build_type }}
BASE_NAME: ${{ needs.assemble-release.outputs.base_name }} 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_MEGA: ${{ steps.upload-mega.outputs.link_mega }}
LINK_HTTPS: ${{ steps.upload-https-7z.outputs.link_https }} LINK_HTTPS: ${{ steps.upload-https-7z.outputs.link_https }}
LINK_TORRENT: ${{ steps.upload-https-torrent.outputs.link_torrent }} LINK_TORRENT: ${{ steps.upload-https-torrent.outputs.link_torrent }}
BUILD_NAME: ${{ needs.assemble-release.outputs.build_name }}
run: | run: |
cd /workspace/refringe/Build/ cd /workspace/refringe/Build/
FOOTER_MESSAGES=("You look great today!" "Powered by coffee" "Did you remember to hydrate today?" "Have you tried turning it off and on again?" "In Chomp we trust" "Beep boop, I'm a bot" "Keep calm and commit your code" "May the source be with you" "Go to bed, Terk" "Please direct all support requests to Drakia" "Meaw") FOOTER_MESSAGES=("You look great today!" "Powered by coffee" "Did you remember to hydrate today?" "Have you tried turning it off and on again?" "In Chomp we trust" "Beep boop, I'm a bot" "Keep calm and commit your code" "May the source be with you" "Go to bed, Terk" "Please direct all support requests to Drakia" "Meaw")
@ -507,7 +527,7 @@ jobs:
EMBED_TITLE="Release Build Now Available" EMBED_TITLE="Release Build Now Available"
EMBED_DESCRIPTION=$'A new stable release build is now ready for download. 7-Zip is *required* to extract the release.' EMBED_DESCRIPTION=$'A new stable release build is now ready for download. 7-Zip is *required* to extract the release.'
fi fi
EMBED_DESCRIPTION+=$'\n\n**Build Information:** 📊\nName: *'"${BASE_NAME}"$'*\nFile Size: *'"${FILE_SIZE_MB}"$'*\nSHA-256 Hash: *'"${FILE_HASH}"$'*\n\n**Primary Download Link:** 🚀\n'"${LINK_MEGA}"$'\n\n**Torrent Link:** 🔗\n'"${LINK_TORRENT}"$'\n\nIn order to conserve bandwidth, please consider using the *above* methods to download the release. If you have issues using those methods, you are free to download using any of the following HTTP mirrors.\n\nWhile the links *below* are not secret, **do not advertise them**. The primary MEGA link or torrent should be used to advertise any downloads.\n\n**Mirrors:** 🌐\n'"${LINK_HTTPS}" EMBED_DESCRIPTION+=$'\n\n**Build Information:** 📊\nName: *'"${BASE_NAME}"$'*\nFile Size: *'"${FILE_SIZE_MB}"$'*\nSHA-256 Hash: *'"${FILE_HASH}"$'*\n\n**Primary Download Link:** 🚀\n'"${LINK_MEGA}"$'\n\n**Torrent Link:** 🔗\n'"${LINK_TORRENT}"$'\n\nIn order to conserve bandwidth, please consider using the *above* methods to download the release. If you have issues using those methods, you are free to download using any of the following HTTP mirrors.\n\nWhile the links *below* are not secret, **do not advertise them**. The primary MEGA link or torrent should be used to advertise any downloads.\n\n**Mirrors:** 🌐\n'"${LINK_HTTPS}"
jq -n \ jq -n \
--arg EMBED_TITLE "$EMBED_TITLE" \ --arg EMBED_TITLE "$EMBED_TITLE" \
@ -519,7 +539,7 @@ jobs:
'{ '{
"username": "BuildBot", "username": "BuildBot",
"avatar_url": "https://i.imgur.com/28JJJec.png", "avatar_url": "https://i.imgur.com/28JJJec.png",
"content": "✨ **New Build Available!** ✨ (THIS IS A TEST)", "content": "✨ **New Build Available!** ✨",
"embeds": [ "embeds": [
{ {
"title": $EMBED_TITLE, "title": $EMBED_TITLE,