2024-02-29 21:44:53 -05:00
|
|
|
name: SPT Release Build
|
2024-02-29 21:25:58 -05:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches: [ main ]
|
|
|
|
pull_request:
|
|
|
|
branches: [ main ]
|
|
|
|
|
|
|
|
jobs:
|
2024-03-02 22:46:27 -05:00
|
|
|
check-tag-exists:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
outputs:
|
|
|
|
proceed: ${{ steps.check.outputs.proceed }}
|
2024-03-06 17:50:45 -05:00
|
|
|
target_tag: ${{ steps.check.outputs.target_tag }}
|
2024-03-02 22:46:27 -05:00
|
|
|
steps:
|
|
|
|
- name: Check Tag Exists in All Repositories
|
|
|
|
id: check
|
|
|
|
run: |
|
2024-03-04 21:09:03 -05:00
|
|
|
# The tag needs to be saved as a variable so that it can be used throughout the build process.
|
2024-03-08 13:35:14 -05:00
|
|
|
TAG="3.8.0-BE-20240308"
|
2024-03-02 22:46:27 -05:00
|
|
|
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")
|
|
|
|
PROCEED="true"
|
|
|
|
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
|
2024-03-06 17:50:45 -05:00
|
|
|
echo "::set-output name=proceed::${PROCEED}"
|
|
|
|
echo "::set-output name=target_tag::${TAG}"
|
2024-03-02 22:46:27 -05:00
|
|
|
shell: bash
|
2024-03-06 16:49:34 -05:00
|
|
|
|
2024-03-02 22:46:27 -05:00
|
|
|
- name: Tag Not Found
|
|
|
|
if: steps.check.outputs.proceed == 'false'
|
|
|
|
run: |
|
|
|
|
echo "Tag not found in one or more repositories, halting workflow."
|
|
|
|
exit 1
|
|
|
|
|
|
|
|
build-server:
|
|
|
|
needs: check-tag-exists
|
|
|
|
if: needs.check-tag-exists.outputs.proceed == 'true'
|
2024-02-29 21:25:58 -05:00
|
|
|
runs-on: ubuntu-latest
|
2024-03-01 11:12:38 -05:00
|
|
|
container:
|
2024-03-09 14:27:29 -05:00
|
|
|
image: refringe/spt-build-node:1.0.3
|
2024-03-06 17:19:21 -05:00
|
|
|
outputs:
|
|
|
|
build_type: ${{ steps.build-type.outputs.build_type }}
|
2024-02-29 21:25:58 -05:00
|
|
|
steps:
|
2024-03-02 14:42:07 -05:00
|
|
|
- name: Clone
|
|
|
|
run: |
|
2024-03-08 15:05:10 -05:00
|
|
|
TARGET_TAG=${{ needs.check-tag-exists.outputs.target_tag }}
|
2024-03-04 22:07:07 -05:00
|
|
|
rm -rf /workspace/refringe/Build/server
|
2024-03-08 15:05:10 -05:00
|
|
|
git clone https://dev.sp-tarkov.com/SPT-AKI/Server.git --branch "${TARGET_TAG}" --depth 1 /workspace/refringe/Build/server
|
2024-03-02 14:42:07 -05:00
|
|
|
|
|
|
|
- name: Pull LFS Files
|
2024-03-02 14:48:27 -05:00
|
|
|
run: |
|
2024-03-04 22:07:07 -05:00
|
|
|
cd /workspace/refringe/Build/server
|
2024-03-02 14:48:27 -05:00
|
|
|
git lfs pull && git lfs ls-files
|
2024-03-02 14:42:07 -05:00
|
|
|
|
|
|
|
- name: Runner Debug Information
|
2024-03-02 13:59:49 -05:00
|
|
|
run: |
|
2024-03-04 22:07:07 -05:00
|
|
|
cd /workspace/refringe/Build/server
|
2024-03-02 14:38:19 -05:00
|
|
|
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)"
|
2024-03-02 14:52:00 -05:00
|
|
|
echo "Last Commit Message:" && git log -1 --pretty=%B
|
2024-03-01 18:54:44 -05:00
|
|
|
|
2024-03-02 14:38:19 -05:00
|
|
|
- name: Cache Keys
|
|
|
|
id: cache-keys
|
|
|
|
run: |
|
2024-03-04 22:07:07 -05:00
|
|
|
cd /workspace/refringe/Build/server
|
2024-03-02 14:38:19 -05:00
|
|
|
echo "::set-output name=commit_hash::$(git rev-parse HEAD)"
|
2024-03-02 14:52:00 -05:00
|
|
|
TAGS=$(git tag --contains HEAD || echo "no-tag")
|
|
|
|
if [ -z "$TAGS" ]; then
|
2024-03-02 14:38:19 -05:00
|
|
|
TAGS="no-tag"
|
|
|
|
fi
|
2024-03-02 14:56:28 -05:00
|
|
|
TAGS="${TAGS//$'\n'/-}" # Replace newline characters with dashes
|
|
|
|
TAGS="${TAGS//,/-}" # Replace commas with dashes
|
|
|
|
echo "::set-output name=tags::${TAGS}"
|
2024-03-02 14:38:19 -05:00
|
|
|
echo "Commit Hash: ${{ steps.cache-keys.outputs.commit_hash }}"
|
|
|
|
echo "Tags: ${{ steps.cache-keys.outputs.tags }}"
|
2024-03-02 14:52:00 -05:00
|
|
|
shell: bash
|
2024-03-02 14:38:19 -05:00
|
|
|
|
2024-03-02 21:57:09 -05:00
|
|
|
- name: Determine Build Type
|
2024-03-02 15:09:22 -05:00
|
|
|
id: build-type
|
|
|
|
run: |
|
2024-03-02 21:57:09 -05:00
|
|
|
TAGS="${{ steps.cache-keys.outputs.tags }}"
|
2024-03-02 15:30:22 -05:00
|
|
|
BUILD_TYPE="debug" # Default
|
2024-03-02 21:57:09 -05:00
|
|
|
if [[ "$TAGS" =~ -BE ]]; then
|
|
|
|
BUILD_TYPE="bleeding"
|
|
|
|
elif [[ "$TAGS" =~ ^(v?\d+\.\d+\.\d+)$ ]]; then
|
|
|
|
BUILD_TYPE="release"
|
|
|
|
fi
|
2024-03-06 17:19:21 -05:00
|
|
|
echo "::set-output name=build_type::${BUILD_TYPE}"
|
2024-03-02 15:09:22 -05:00
|
|
|
shell: bash
|
|
|
|
|
2024-03-02 14:38:19 -05:00
|
|
|
- name: Build Cache
|
|
|
|
id: build-cache
|
2024-03-01 16:35:27 -05:00
|
|
|
uses: actions/cache@v4
|
2024-03-01 16:29:25 -05:00
|
|
|
with:
|
2024-03-04 22:07:07 -05:00
|
|
|
path: /workspace/refringe/Build/server/project/build
|
2024-03-02 15:09:22 -05:00
|
|
|
key: build-${{ steps.cache-keys.outputs.commit_hash }}-${{ steps.cache-keys.outputs.tags }}-${{ steps.build-type.outputs.build_type }}
|
2024-03-02 14:38:19 -05:00
|
|
|
restore-keys: |
|
2024-03-02 15:09:22 -05:00
|
|
|
build-${{ steps.cache-keys.outputs.commit_hash }}-${{ steps.cache-keys.outputs.tags }}-
|
2024-03-02 14:38:19 -05:00
|
|
|
build-${{ steps.cache-keys.outputs.commit_hash }}-
|
|
|
|
build-
|
2024-03-01 13:19:08 -05:00
|
|
|
|
2024-03-02 14:07:51 -05:00
|
|
|
- name: Install Dependencies
|
2024-03-05 23:05:43 -05:00
|
|
|
if: steps.build-cache.outputs.cache-hit != 'true'
|
2024-03-02 14:48:27 -05:00
|
|
|
run: |
|
2024-03-04 22:07:07 -05:00
|
|
|
cd /workspace/refringe/Build/server/project
|
2024-03-02 14:48:27 -05:00
|
|
|
npm install
|
2024-03-02 13:59:49 -05:00
|
|
|
|
2024-03-02 14:07:51 -05:00
|
|
|
- name: Build Server
|
2024-03-05 23:05:43 -05:00
|
|
|
if: steps.build-cache.outputs.cache-hit != 'true'
|
2024-03-02 14:48:27 -05:00
|
|
|
run: |
|
2024-03-04 22:07:07 -05:00
|
|
|
cd /workspace/refringe/Build/server/project
|
2024-03-02 15:09:22 -05:00
|
|
|
BUILD_TYPE="${{ steps.build-type.outputs.build_type }}"
|
|
|
|
echo "Running build for $BUILD_TYPE"
|
2024-03-08 13:23:24 -05:00
|
|
|
npm run build:$BUILD_TYPE -- --arch=x64 --platform=win32
|
2024-03-04 22:17:07 -05:00
|
|
|
printf "\nBuilt!\n\n"
|
2024-03-04 22:07:07 -05:00
|
|
|
tree -C /workspace/refringe/Build/server/project/build
|
2024-03-04 22:10:27 -05:00
|
|
|
shell: bash
|
2024-03-02 13:59:49 -05:00
|
|
|
|
2024-03-05 22:28:59 -05:00
|
|
|
- name: Archive Build
|
2024-03-09 00:04:53 -05:00
|
|
|
uses: actions/upload-artifact@v3
|
2024-03-02 15:09:22 -05:00
|
|
|
with:
|
2024-03-02 15:25:43 -05:00
|
|
|
name: server-build
|
2024-03-05 22:28:59 -05:00
|
|
|
path: /workspace/refringe/Build/server/project/build/
|
2024-03-08 23:58:24 -05:00
|
|
|
compression-level: 0
|
|
|
|
retention-days: 1
|
2024-03-02 15:09:22 -05:00
|
|
|
overwrite: true
|
2024-03-02 22:29:09 -05:00
|
|
|
|
2024-03-02 22:46:27 -05:00
|
|
|
build-modules:
|
|
|
|
needs: check-tag-exists
|
|
|
|
if: needs.check-tag-exists.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-06 17:19:21 -05:00
|
|
|
outputs:
|
2024-03-08 15:01:14 -05:00
|
|
|
spt_version: ${{ steps.extract-client-version.outputs.spt_version }}
|
2024-03-06 17:50:45 -05:00
|
|
|
client_version: ${{ steps.extract-client-version.outputs.client_version }}
|
2024-03-02 22:29:09 -05:00
|
|
|
steps:
|
|
|
|
- name: Clone
|
|
|
|
run: |
|
2024-03-08 15:05:10 -05:00
|
|
|
TARGET_TAG=${{ needs.check-tag-exists.outputs.target_tag }}
|
2024-03-04 22:07:07 -05:00
|
|
|
rm -rf /workspace/refringe/Build/modules
|
2024-03-08 15:05:10 -05:00
|
|
|
git clone https://dev.sp-tarkov.com/SPT-AKI/Modules.git --branch "${TARGET_TAG}" --depth 1 /workspace/refringe/Build/modules
|
2024-03-02 22:29:09 -05:00
|
|
|
|
2024-03-03 13:08:14 -05:00
|
|
|
- name: Fetch Server Core Config
|
|
|
|
run: |
|
2024-03-08 15:05:10 -05:00
|
|
|
TARGET_TAG=${{ needs.check-tag-exists.outputs.target_tag }}
|
2024-03-04 22:07:07 -05:00
|
|
|
rm -rf /workspace/refringe/Build/server-core
|
|
|
|
git init /workspace/refringe/Build/server-core
|
|
|
|
cd /workspace/refringe/Build/server-core
|
2024-03-03 13:08:14 -05: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
|
2024-03-08 15:05:10 -05:00
|
|
|
git fetch --depth=1 origin "${TARGET_TAG}"
|
2024-03-03 13:08:14 -05:00
|
|
|
git checkout FETCH_HEAD
|
2024-03-03 18:29:54 -05:00
|
|
|
ls -la project/assets/configs
|
2024-03-03 13:08:14 -05:00
|
|
|
shell: bash
|
|
|
|
|
2024-03-03 13:21:07 -05:00
|
|
|
- name: Extract Client Version
|
2024-03-03 18:37:06 -05:00
|
|
|
id: extract-client-version
|
2024-03-03 13:21:07 -05:00
|
|
|
run: |
|
2024-03-04 22:07:07 -05:00
|
|
|
cd /workspace/refringe/Build/server-core/project/assets/configs
|
2024-03-08 15:01:14 -05:00
|
|
|
SPT_VERSION=$(jq -r '.akiVersion' core.json)
|
2024-03-03 18:29:54 -05:00
|
|
|
FULL_VERSION=$(jq -r '.compatibleTarkovVersion' core.json)
|
|
|
|
CLIENT_VERSION=${FULL_VERSION##*.}
|
2024-03-03 16:41:12 -05:00
|
|
|
echo "Extracted Client Version: $CLIENT_VERSION"
|
2024-03-06 17:50:45 -05:00
|
|
|
echo "::set-output name=client_version::${CLIENT_VERSION}"
|
2024-03-08 15:01:14 -05:00
|
|
|
echo "::set-output name=spt_version::${SPT_VERSION}"
|
2024-03-03 13:21:07 -05:00
|
|
|
shell: bash
|
|
|
|
|
2024-03-03 18:29:54 -05:00
|
|
|
- name: Download Client Module Package
|
|
|
|
run: |
|
2024-03-04 22:07:07 -05:00
|
|
|
DIR_MANAGED="/workspace/refringe/Build/modules/project/Shared/Managed"
|
2024-03-03 18:37:06 -05:00
|
|
|
DOWNLOAD_PATH="$DIR_MANAGED/${{ steps.extract-client-version.outputs.client_version }}.zip"
|
|
|
|
DOWNLOAD_URL="$MODULE_DOMAIN/${{ steps.extract-client-version.outputs.client_version }}.zip"
|
2024-03-03 18:29:54 -05:00
|
|
|
echo "Downloading Client Module Package from $DOWNLOAD_URL to $DOWNLOAD_PATH"
|
|
|
|
mkdir -p "$DIR_MANAGED"
|
2024-03-03 18:37:06 -05:00
|
|
|
wget -q -O "$DOWNLOAD_PATH" "$DOWNLOAD_URL" || {
|
2024-03-03 18:29:54 -05:00
|
|
|
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
|
|
|
|
env:
|
|
|
|
MODULE_DOMAIN: ${{ secrets.MODULE_DOMAIN }}
|
|
|
|
|
2024-03-03 18:44:40 -05:00
|
|
|
- name: Decompress Client Module Package
|
|
|
|
run: |
|
2024-03-04 22:07:07 -05:00
|
|
|
cd /workspace/refringe/Build/modules/project/Shared/Managed
|
2024-03-03 18:44:40 -05:00
|
|
|
7z x ${{ steps.extract-client-version.outputs.client_version }}.zip -aoa
|
2024-03-04 21:09:03 -05:00
|
|
|
echo "Client module package decompressed."
|
2024-03-03 18:44:40 -05:00
|
|
|
shell: bash
|
|
|
|
|
|
|
|
- name: Delete Client Module Package
|
|
|
|
run: |
|
2024-03-04 22:07:07 -05:00
|
|
|
cd /workspace/refringe/Build/modules/project/Shared/Managed
|
2024-03-03 18:44:40 -05:00
|
|
|
rm -f ${{ steps.extract-client-version.outputs.client_version }}.zip
|
|
|
|
echo "Client module package deleted."
|
|
|
|
shell: bash
|
|
|
|
|
2024-03-03 18:50:55 -05:00
|
|
|
- name: Build Modules
|
|
|
|
run: |
|
2024-03-04 22:07:07 -05:00
|
|
|
cd /workspace/refringe/Build/modules/project
|
2024-03-03 18:50:55 -05:00
|
|
|
dotnet build
|
2024-03-04 22:17:07 -05:00
|
|
|
printf "\nBuilt!\n\n"
|
2024-03-04 22:07:07 -05:00
|
|
|
tree /workspace/refringe/Build/modules/project/Build
|
2024-03-03 18:50:55 -05:00
|
|
|
shell: bash
|
|
|
|
|
2024-03-05 22:28:59 -05:00
|
|
|
- name: Archive Build
|
2024-03-09 00:04:53 -05:00
|
|
|
uses: actions/upload-artifact@v3
|
2024-03-04 21:12:10 -05:00
|
|
|
with:
|
|
|
|
name: modules-build
|
2024-03-05 22:28:59 -05:00
|
|
|
path: /workspace/refringe/Build/modules/project/Build
|
2024-03-08 23:58:24 -05:00
|
|
|
compression-level: 0
|
|
|
|
retention-days: 1
|
2024-03-04 21:12:10 -05:00
|
|
|
overwrite: true
|
|
|
|
|
2024-03-02 22:46:27 -05:00
|
|
|
build-launcher:
|
|
|
|
needs: check-tag-exists
|
|
|
|
if: needs.check-tag-exists.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:
|
|
|
|
- name: Clone
|
|
|
|
run: |
|
2024-03-08 15:05:10 -05:00
|
|
|
TARGET_TAG=${{ needs.check-tag-exists.outputs.target_tag }}
|
2024-03-04 22:07:07 -05:00
|
|
|
rm -rf /workspace/refringe/Build/launcher
|
2024-03-08 15:05:10 -05:00
|
|
|
git clone https://dev.sp-tarkov.com/SPT-AKI/Launcher.git --branch "${TARGET_TAG}" --depth 1 /workspace/refringe/Build/launcher
|
2024-03-04 22:24:35 -05:00
|
|
|
|
|
|
|
- name: Build Launcher
|
|
|
|
run: |
|
|
|
|
cd /workspace/refringe/Build/launcher/project
|
|
|
|
dotnet build
|
|
|
|
printf "\nBuilt!\n\n"
|
2024-03-05 11:22:44 -05:00
|
|
|
tree /workspace/refringe/Build/launcher/project/Build
|
2024-03-04 22:24:35 -05:00
|
|
|
shell: bash
|
2024-03-05 11:22:44 -05:00
|
|
|
|
2024-03-05 22:28:59 -05:00
|
|
|
- name: Archive Build
|
2024-03-09 00:04:53 -05:00
|
|
|
uses: actions/upload-artifact@v3
|
2024-03-05 11:22:44 -05:00
|
|
|
with:
|
|
|
|
name: launcher-build
|
2024-03-05 22:28:59 -05:00
|
|
|
path: /workspace/refringe/Build/launcher/project/Build
|
2024-03-08 23:58:24 -05:00
|
|
|
compression-level: 0
|
|
|
|
retention-days: 1
|
2024-03-05 11:22:44 -05:00
|
|
|
overwrite: true
|
2024-03-05 23:05:43 -05:00
|
|
|
|
2024-03-06 13:19:23 -05:00
|
|
|
assemble-release:
|
2024-03-06 16:49:34 -05:00
|
|
|
needs: [check-tag-exists, build-server, build-modules, build-launcher]
|
2024-03-05 23:05:43 -05:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
container:
|
2024-03-09 14:27:29 -05:00
|
|
|
image: refringe/spt-build-node:1.0.3
|
2024-03-05 23:05:43 -05:00
|
|
|
steps:
|
2024-03-06 17:50:45 -05:00
|
|
|
- name: Clean Directory
|
|
|
|
run: |
|
|
|
|
rm -rf /workspace/refringe/Build/release /workspace/refringe/Build/build
|
|
|
|
mkdir -p /workspace/refringe/Build/release
|
2024-03-05 23:05:43 -05:00
|
|
|
|
2024-03-06 13:19:23 -05:00
|
|
|
- name: Download Server Build Artifact
|
2024-03-05 23:05:43 -05:00
|
|
|
uses: actions/download-artifact@v3
|
|
|
|
with:
|
|
|
|
name: server-build
|
2024-03-06 14:18:08 -05:00
|
|
|
path: /workspace/refringe/Build/release/
|
2024-03-05 23:05:43 -05:00
|
|
|
|
2024-03-06 13:19:23 -05:00
|
|
|
- name: Download Modules Build Artifact
|
2024-03-05 23:05:43 -05:00
|
|
|
uses: actions/download-artifact@v3
|
|
|
|
with:
|
|
|
|
name: modules-build
|
2024-03-06 14:18:08 -05:00
|
|
|
path: /workspace/refringe/Build/release/
|
2024-03-05 23:05:43 -05:00
|
|
|
|
2024-03-06 13:19:23 -05:00
|
|
|
- name: Download Launcher Build Artifact
|
2024-03-05 23:05:43 -05:00
|
|
|
uses: actions/download-artifact@v3
|
|
|
|
with:
|
|
|
|
name: launcher-build
|
2024-03-06 14:18:08 -05:00
|
|
|
path: /workspace/refringe/Build/release/
|
2024-03-05 23:05:43 -05:00
|
|
|
|
2024-03-06 13:19:23 -05:00
|
|
|
- name: Clone Build Project
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
with:
|
|
|
|
path: /workspace/refringe/Build/build
|
|
|
|
|
2024-03-08 12:08:52 -05:00
|
|
|
- name: Merge Static Assets and Dynamic Files
|
|
|
|
run: cp -rvf /workspace/refringe/Build/build/static-assets/* /workspace/refringe/Build/release/
|
2024-03-06 13:33:46 -05:00
|
|
|
shell: bash
|
|
|
|
|
2024-03-06 14:18:08 -05:00
|
|
|
- name: List Release Contents
|
|
|
|
run: tree /workspace/refringe/Build/release
|
2024-03-06 13:19:23 -05:00
|
|
|
shell: bash
|
2024-03-06 14:18:08 -05:00
|
|
|
|
2024-03-06 23:08:46 -05:00
|
|
|
- name: Generate Release Filename
|
|
|
|
id: generate-filename
|
2024-03-06 14:18:08 -05:00
|
|
|
run: |
|
2024-03-06 16:49:34 -05:00
|
|
|
BUILD_TYPE=${{ needs.build-server.outputs.build_type }}
|
2024-03-08 15:08:07 -05:00
|
|
|
SPT_VERSION=${{ needs.build-modules.outputs.spt_version }}
|
2024-03-06 16:49:34 -05:00
|
|
|
CLIENT_VERSION=${{ needs.build-modules.outputs.client_version }}
|
|
|
|
DATE=$(date +%Y%m%d)
|
2024-03-06 22:54:43 -05:00
|
|
|
|
|
|
|
# Make BUILD_TYPE uppercase
|
|
|
|
UPPER_BUILD_TYPE=$(echo "$BUILD_TYPE" | tr '[:lower:]' '[:upper:]')
|
|
|
|
|
2024-03-06 23:08:46 -05:00
|
|
|
# Conditionally format the FILENAME based on BUILD_TYPE
|
2024-03-06 22:54:43 -05:00
|
|
|
if [ "$BUILD_TYPE" = "release" ]; then
|
2024-03-08 15:01:14 -05:00
|
|
|
FILENAME="SPT-${SPT_VERSION}-${CLIENT_VERSION}-${DATE}.7z"
|
2024-03-06 22:54:43 -05:00
|
|
|
else
|
2024-03-08 15:01:14 -05:00
|
|
|
FILENAME="SPT-${UPPER_BUILD_TYPE}-${SPT_VERSION}-${CLIENT_VERSION}-${DATE}.7z"
|
2024-03-06 22:54:43 -05:00
|
|
|
fi
|
|
|
|
|
2024-03-06 23:14:02 -05:00
|
|
|
echo "::set-output name=filename::${FILENAME}"
|
2024-03-06 23:08:46 -05:00
|
|
|
shell: bash
|
|
|
|
|
|
|
|
- name: Compress Release
|
|
|
|
run: |
|
2024-03-06 14:18:08 -05:00
|
|
|
cd /workspace/refringe/Build/release
|
2024-03-06 23:08:46 -05:00
|
|
|
7z a -mx=9 -m0=lzma2 "../${{ steps.generate-filename.outputs.filename }}" ./*
|
|
|
|
echo "Release compressed as ${{ steps.generate-filename.outputs.filename }}."
|
2024-03-06 22:54:43 -05:00
|
|
|
shell: bash
|
|
|
|
|
2024-03-09 00:01:56 -05:00
|
|
|
- name: Upload Release to HTTP Source
|
2024-03-09 00:29:52 -05:00
|
|
|
run: |
|
|
|
|
cd /workspace/refringe/Build/
|
|
|
|
echo "${{ secrets.SFTP_HOST_KEY }}" > known_host
|
2024-03-09 00:56:37 -05:00
|
|
|
sshpass -p "${{ secrets.SFTP_PASSWORD }}" scp -v -o "Port=${{ secrets.SFTP_PORT }}" -o "ConnectTimeout=20" -o "UserKnownHostsFile=known_host" -o "StrictHostKeyChecking=yes" "/workspace/refringe/Build/${{ steps.generate-filename.outputs.filename }}" ${{ secrets.SFTP_USERNAME }}@${{ secrets.SFTP_HOST }}:/public
|
2024-03-09 00:29:52 -05:00
|
|
|
shell: bash
|
2024-03-09 00:01:56 -05:00
|
|
|
|
2024-03-09 15:13:02 -05:00
|
|
|
- name: Clean Old HTTP Source Releases
|
2024-03-09 14:10:59 -05:00
|
|
|
run: |
|
2024-03-09 15:00:30 -05:00
|
|
|
cd /workspace/refringe/Build/
|
2024-03-09 14:10:59 -05:00
|
|
|
echo "${{ secrets.SFTP_HOST_KEY }}" > known_hosts
|
2024-03-09 14:38:14 -05:00
|
|
|
|
2024-03-09 15:13:02 -05:00
|
|
|
# Creating a script for sftp to execute
|
|
|
|
echo "cd /public" > sftp_commands.txt
|
|
|
|
echo "ls" >> sftp_commands.txt
|
|
|
|
|
2024-03-09 20:25:42 -05:00
|
|
|
# Fetch a remote list of files
|
2024-03-09 15:13:02 -05:00
|
|
|
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 }})
|
|
|
|
|
|
|
|
echo "Files listed:"
|
|
|
|
echo "$FILE_LIST"
|
|
|
|
|
|
|
|
# Filtering and processing the file list
|
2024-03-09 20:25:42 -05:00
|
|
|
echo "$FILE_LIST" | tr ' ' '\n' | grep -E 'SPT-(DEBUG|BLEEDING).*\.7z$' | while read filename; do
|
2024-03-09 15:13:02 -05:00
|
|
|
echo "Processing file: $filename"
|
|
|
|
# Extract date from filename
|
2024-03-09 15:00:30 -05:00
|
|
|
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)
|
|
|
|
|
|
|
|
current_date=$(date +%s)
|
|
|
|
limit_date=$(date -d "@$((current_date - 30 * 24 * 3600))" +%s)
|
|
|
|
|
|
|
|
if [[ "$file_date_fmt" -lt "$limit_date" ]]; then
|
2024-03-09 20:33:56 -05:00
|
|
|
echo "Marked for deletion: $filename"
|
2024-03-09 20:25:42 -05:00
|
|
|
echo "rm \"/public/$filename\"" >> delete_commands.txt
|
2024-03-09 15:00:30 -05:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2024-03-09 15:13:02 -05:00
|
|
|
# Check if there are files to delete and execute
|
|
|
|
if [ -s delete_commands.txt ]; then
|
2024-03-09 20:33:56 -05:00
|
|
|
echo "Running deletion task..."
|
2024-03-09 15:13:02 -05:00
|
|
|
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 }}
|
2024-03-09 15:00:30 -05:00
|
|
|
else
|
2024-03-09 15:13:02 -05:00
|
|
|
echo "No old files to delete."
|
2024-03-09 15:00:30 -05:00
|
|
|
fi
|
2024-03-09 14:10:59 -05:00
|
|
|
shell: bash
|
|
|
|
|
2024-03-09 00:01:56 -05:00
|
|
|
- name: Upload Release to Mega
|
2024-03-08 16:01:00 -05:00
|
|
|
id: upload-mega
|
|
|
|
run: |
|
|
|
|
mega-https on
|
2024-03-09 00:00:30 -05:00
|
|
|
mega-login "${{ secrets.MEGA_EMAIL }}" "${{ secrets.MEGA_PASSWORD }}"
|
2024-03-08 16:24:35 -05:00
|
|
|
|
2024-03-08 16:01:00 -05:00
|
|
|
mega-put -c "/workspace/refringe/Build/${{ steps.generate-filename.outputs.filename }}" "/spt-release/${{ steps.generate-filename.outputs.filename }}"
|
2024-03-08 16:24:35 -05:00
|
|
|
|
|
|
|
# Generate link and save it.
|
|
|
|
EXPORT_OUTPUT=$(mega-export -a "/spt-release/${{ steps.generate-filename.outputs.filename }}" -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
|
2024-03-08 16:01:00 -05:00
|
|
|
shell: bash
|
2024-03-06 23:41:39 -05:00
|
|
|
|
2024-03-08 16:01:00 -05:00
|
|
|
- name: Clean Old Mega Releases
|
|
|
|
run: |
|
|
|
|
mega-https on
|
|
|
|
mega-login "${{ secrets.MEGA_EMAIL }}" "${{ secrets.MEGA_PASSWORD }}"
|
|
|
|
|
|
|
|
# List files and filter out old DEBUG or BLEEDING files
|
|
|
|
mega-ls /spt-release | grep -E 'SPT-(DEBUG|BLEEDING).*\.7z$' | while read -r filename; do
|
|
|
|
# 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 30 days
|
|
|
|
current_date=$(date +%s)
|
|
|
|
limit_date=$(date -d "@$((current_date - 30 * 24 * 3600))" +%s)
|
|
|
|
|
|
|
|
# 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
|
|
|
|
fi
|
|
|
|
done
|
2024-03-08 16:24:35 -05:00
|
|
|
|
2024-03-09 00:01:21 -05:00
|
|
|
# Remove old file versions to save space.
|
|
|
|
mega-deleteversions -f /spt-release/*
|
|
|
|
|
2024-03-08 16:24:35 -05:00
|
|
|
mega-logout
|
2024-03-08 16:01:00 -05:00
|
|
|
shell: bash
|