mirror of
https://github.com/sp-tarkov/build.git
synced 2025-02-13 08:30:46 -05:00
103 lines
3.2 KiB
YAML
103 lines
3.2 KiB
YAML
name: SPT Release Build
|
|
|
|
on:
|
|
push:
|
|
branches: [ main ]
|
|
pull_request:
|
|
branches: [ main ]
|
|
|
|
jobs:
|
|
Build Server:
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: refringe/spt-build-server:0.0.1
|
|
steps:
|
|
- name: Clone
|
|
run: |
|
|
rm -rf ./server
|
|
git clone https://dev.sp-tarkov.com/SPT-AKI/Server.git --branch 3.8.0-BE --depth 1 ./server
|
|
|
|
- name: Pull LFS Files
|
|
run: |
|
|
cd ./server
|
|
git lfs pull && git lfs ls-files
|
|
|
|
- name: Runner Debug Information
|
|
run: |
|
|
cd ./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
|
|
|
|
- name: Cache Keys
|
|
id: cache-keys
|
|
run: |
|
|
cd ./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: Build Type
|
|
id: build-type
|
|
run: |
|
|
IFS=$'\n' read -r -d '' -a ADDR <<< "${{ steps.cache-keys.outputs.tags }}" || true
|
|
BUILD_TYPE="debug" # Default
|
|
for TAG in "${ADDR[@]}"; do
|
|
RELEASE_BUILD_REGEX='^(v?\d+\.\d+\.\d+)$'
|
|
BLEEDING_BUILD_REGEX='^(v?\d+\.\d+\.\d+-BE(?:-[^-]+)?)$'
|
|
if [[ "$TAG" =~ $RELEASE_BUILD_REGEX ]]; then
|
|
BUILD_TYPE="release"
|
|
break # Stop checking
|
|
elif [[ "$TAG" =~ $BLEEDING_BUILD_REGEX ]]; then
|
|
BUILD_TYPE="bleeding"
|
|
fi
|
|
done
|
|
echo "Build type: $BUILD_TYPE"
|
|
echo "::set-output name=build_type::$BUILD_TYPE"
|
|
shell: bash
|
|
|
|
- name: Build Cache
|
|
id: build-cache
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ./server/project/build
|
|
key: build-${{ steps.cache-keys.outputs.commit_hash }}-${{ steps.cache-keys.outputs.tags }}-${{ steps.build-type.outputs.build_type }}
|
|
restore-keys: |
|
|
build-${{ steps.cache-keys.outputs.commit_hash }}-${{ steps.cache-keys.outputs.tags }}-
|
|
build-${{ steps.cache-keys.outputs.commit_hash }}-
|
|
build-
|
|
|
|
- name: Install Dependencies
|
|
if: steps.build-cache.outputs.cache-hit != 'true'
|
|
run: |
|
|
cd ./server/project
|
|
npm install
|
|
|
|
- name: Build Server
|
|
if: steps.build-cache.outputs.cache-hit != 'true'
|
|
run: |
|
|
cd ./server/project
|
|
BUILD_TYPE="${{ steps.build-type.outputs.build_type }}"
|
|
echo "Running build for $BUILD_TYPE"
|
|
npm run build:$BUILD_TYPE
|
|
|
|
- name: Archive Build
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: server-build
|
|
path: ./server/project/build/
|
|
|
|
overwrite: true
|