0
0
mirror of https://github.com/sp-tarkov/build.git synced 2025-02-13 09:50:45 -05:00

First pass at automated R2 release storage

This commit is contained in:
Refringe 2024-04-25 23:54:08 -04:00
parent 425f924d24
commit 809b6d9c59
Signed by: Refringe
GPG Key ID: 7715B85B4A6306ED
3 changed files with 639 additions and 587 deletions

View File

@ -2,15 +2,15 @@ name: SPT Release Build
on: on:
schedule: schedule:
- cron: '* 19 * * *' # Every day at 3pm ET - cron: "* 19 * * *" # Every day at 3pm ET
push: push:
branches: [ trigger ] branches: [trigger]
jobs: jobs:
prepare: prepare:
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: container:
image: refringe/spt-build-node:1.0.7 image: refringe/spt-build-node:1.0.8
outputs: outputs:
proceed: ${{ steps.check-existence.outputs.proceed }} proceed: ${{ steps.check-existence.outputs.proceed }}
is_nightly: ${{ steps.determine-context.outputs.is_nightly }} is_nightly: ${{ steps.determine-context.outputs.is_nightly }}
@ -207,7 +207,7 @@ jobs:
if: needs.prepare.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.7 image: refringe/spt-build-node:1.0.8
outputs: outputs:
server_commit: ${{ steps.clone-server.outputs.server_commit }} server_commit: ${{ steps.clone-server.outputs.server_commit }}
steps: steps:
@ -429,7 +429,7 @@ jobs:
needs: [prepare, 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.7 image: refringe/spt-build-node:1.0.8
steps: steps:
- name: Clean Directory - name: Clean Directory
run: | run: |
@ -511,10 +511,61 @@ jobs:
shell: bash shell: bash
- name: Compress Release - name: Compress Release
id: compress-release
run: | run: |
cd /workspace/SPT-AKI/Build/release cd /workspace/SPT-AKI/Build/release
7z a -mx=9 -m0=lzma2 "../${{ steps.generate-filename.outputs.build_name }}" ./* 7z a -mx=9 -m0=lzma2 "../${{ steps.generate-filename.outputs.build_name }}" ./*
echo "Release compressed as ${{ steps.generate-filename.outputs.build_name }}." echo "Release compressed as ${{ steps.generate-filename.outputs.build_name }}."
echo "::set-output name=base_name::${BASE_NAME}"
echo "::set-output name=build_name::${BASE_NAME}.7z"
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)
echo "::set-output name=file_size_mb::${FILE_SIZE_MB}"
echo "::set-output name=file_hash::${FILE_HASH}"
shell: bash
- name: R2 Upload
if: steps.determine-build-type.outputs.build_type == 'release'
run: |
SPT_VERSION=${{ needs.prepare.outputs.spt_version }}
CLIENT_VERSION=${{ needs.prepare.outputs.client_version }}
FILE_HASH=${{ steps.compress-release.outputs.file_hash }}
cd /workspace/SPT-AKI/Build/release
# Configure Rclone
echo '[r2]
type = s3
provider = Cloudflare
access_key_id = ${{ secrets.R2_ACCESS_KEY }}
secret_access_key = ${{ secrets.R2_SECRET_ACCESS_KEY }}
region = auto
endpoint = ${{ secrets.R2_ENDPOINT }}
acl = public-read' > rclone.conf
# Generate JSON file
echo '{
"AkiVersion": "${SPT_VERSION}",
"ClientVersion": "${CLIENT_VERSION}",
"Mirrors": [{
"DownloadUrl": "${{ secrets.R2_FRONT }}/${{ steps.generate-filename.outputs.build_name }}",
"Hash": "${FILE_HASH}"
}]
}' > release.json
rclone --version
# Remove old 7z files from the bucket
rclone delete r2:/${{ secrets.R2_BUCKET_NAME }}/*.7z --config rclone.conf
# Upload the file using rclone with the above config
rclone copy "/workspace/SPT-AKI/Build/${{ steps.generate-filename.outputs.build_name }}" r2:/${{ secrets.R2_BUCKET_NAME }} --config rclone.conf
# Upload the JSON file using rclone with the above config
rclone copy "/workspace/SPT-AKI/Build/release.json" r2:/${{ secrets.R2_BUCKET_NAME }} --config rclone.conf
shell: bash shell: bash
- name: Upload Release to HTTPS Source - name: Upload Release to HTTPS Source
@ -618,6 +669,8 @@ jobs:
BUILD_TYPE: ${{ needs.prepare.outputs.build_type }} BUILD_TYPE: ${{ needs.prepare.outputs.build_type }}
BASE_NAME: ${{ steps.generate-filename.outputs.base_name }} BASE_NAME: ${{ steps.generate-filename.outputs.base_name }}
BUILD_NAME: ${{ steps.generate-filename.outputs.build_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_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 }}
MODS_ENABLED_BLEEDING: ${{ needs.prepare.outputs.mod_enabled_bleeding }} MODS_ENABLED_BLEEDING: ${{ needs.prepare.outputs.mod_enabled_bleeding }}
@ -630,8 +683,6 @@ jobs:
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") 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")
FOOTER_MESSAGE="${FOOTER_MESSAGES[$RANDOM % ${#FOOTER_MESSAGES[@]}]}" FOOTER_MESSAGE="${FOOTER_MESSAGES[$RANDOM % ${#FOOTER_MESSAGES[@]}]}"
TIMESTAMP=$(date --iso-8601=seconds) TIMESTAMP=$(date --iso-8601=seconds)
FILE_SIZE_MB=$(stat -c %s "$BUILD_NAME" | awk '{printf "%.2f MB", $1 / 1024 / 1024}')
FILE_HASH=$(md5sum "$BUILD_NAME" | awk '{print $1}' | xxd -r -p | base64)
MODS="" MODS=""
if [[ "${{ needs.prepare.outputs.is_nightly }}" == "true" ]]; then if [[ "${{ needs.prepare.outputs.is_nightly }}" == "true" ]]; then

View File

@ -12,8 +12,9 @@ FROM node:20.11.1-bookworm
# - sshpass (for automated SSH authentication) # - sshpass (for automated SSH authentication)
# - lftp (for automated SFTP commands) # - lftp (for automated SFTP commands)
# - vim-common (for xxd command, for file hash process) # - vim-common (for xxd command, for file hash process)
# - rclone (for R2 uploads)
RUN apt-get update && \ RUN apt-get update && \
apt-get install -y wget git git-lfs zstd tree jq p7zip-full sshpass python3 python3-pip python3-venv vim-common apt-get install -y wget git git-lfs zstd tree jq p7zip-full sshpass python3 python3-pip python3-venv vim-common rclone
# MegaCMD (for uploading to Mega.nz) # MegaCMD (for uploading to Mega.nz)
# - libc-ares2 (MegaCMD dependancy) # - libc-ares2 (MegaCMD dependancy)

View File

@ -65,7 +65,7 @@ Prior to the assembly and distribution of Docker images, it is crucial to increm
``` ```
# Command to build and push the spt-build-node Docker image to Docker Hub # Command to build and push the spt-build-node Docker image to Docker Hub
docker build -t refringe/spt-build-node:1.0.8 -t refringe/spt-build-node:latest -f Dockerfile.node . docker build -t refringe/spt-build-node:1.0.9 -t refringe/spt-build-node:latest -f Dockerfile.node .
docker push refringe/spt-build-node --all-tags docker push refringe/spt-build-node --all-tags
# Command to build and push the spt-build-dotnet Docker image to Docker Hub # Command to build and push the spt-build-dotnet Docker image to Docker Hub