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

150 lines
4.7 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:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
check-tag-exists:
runs-on: ubuntu-latest
outputs:
proceed: ${{ steps.check.outputs.proceed }}
steps:
- name: Check Tag Exists in All Repositories
id: check
run: |
2024-03-02 22:51:26 -05:00
TAG=3.8.0-BE
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
echo "::set-output name=proceed::$PROCEED"
shell: bash
- 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-02 13:59:49 -05:00
image: refringe/spt-build-server:0.0.1
2024-02-29 21:25:58 -05:00
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
2024-03-02 14:48:27 -05:00
run: |
cd ./server
git lfs pull && git lfs ls-files
- name: Runner Debug Information
2024-03-02 13:59:49 -05:00
run: |
2024-03-02 14:48:27 -05:00
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
2024-03-01 18:54:44 -05:00
- name: Cache Keys
id: cache-keys
run: |
2024-03-02 14:48:27 -05:00
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: Determine Build Type
id: build-type
run: |
TAGS="${{ steps.cache-keys.outputs.tags }}"
BUILD_TYPE="debug" # Default
if [[ "$TAGS" =~ -BE ]]; then
BUILD_TYPE="bleeding"
elif [[ "$TAGS" =~ ^(v?\d+\.\d+\.\d+)$ ]]; then
BUILD_TYPE="release"
fi
echo "Build type: $BUILD_TYPE"
echo "::set-output name=build_type::$BUILD_TYPE"
shell: bash
- name: Build Cache
id: build-cache
2024-03-01 16:35:27 -05:00
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-
2024-03-02 14:07:51 -05:00
- name: Install Dependencies
if: steps.build-cache.outputs.cache-hit != 'true'
2024-03-02 14:48:27 -05:00
run: |
cd ./server/project
npm install
2024-03-02 13:59:49 -05:00
2024-03-02 14:07:51 -05:00
- name: Build Server
if: steps.build-cache.outputs.cache-hit != 'true'
2024-03-02 14:48:27 -05:00
run: |
cd ./server/project
BUILD_TYPE="${{ steps.build-type.outputs.build_type }}"
echo "Running build for $BUILD_TYPE"
npm run build:$BUILD_TYPE
2024-03-02 13:59:49 -05:00
- name: Archive Build
2024-03-02 15:11:26 -05:00
uses: actions/upload-artifact@v3
with:
name: server-build
path: ./server/project/build/
overwrite: true
build-modules:
needs: check-tag-exists
if: needs.check-tag-exists.outputs.proceed == 'true'
runs-on: ubuntu-latest
container:
image: refringe/spt-build-dotnet:0.0.1
steps:
- name: Clone
run: |
rm -rf ./modules
git clone https://dev.sp-tarkov.com/SPT-AKI/Modules.git --branch 3.8.0-BE --depth 1 ./modules
build-launcher:
needs: check-tag-exists
if: needs.check-tag-exists.outputs.proceed == 'true'
runs-on: ubuntu-latest
container:
image: refringe/spt-build-dotnet:0.0.1
steps:
- name: Clone
run: |
rm -rf ./launcher
git clone https://dev.sp-tarkov.com/SPT-AKI/Launcher.git --branch 3.8.0-BE --depth 1 ./launcher