This commit is contained in:
AirryCo
2025-03-19 13:20:20 +08:00
parent 860268fb9c
commit 32cdb0c07a
4 changed files with 42 additions and 90 deletions

View File

@@ -479,7 +479,7 @@ jobs:
- name: Create Github Pre-release - name: Create Github Pre-release
id: create_pre_release id: create_pre_release
if: ${{ contains(needs.prepare.outputs.TARGET_TAG, 'BEM') }} if: ${{ contains(needs.prepare.outputs.TARGET_TAG, 'BE') }}
uses: softprops/action-gh-release@v2 uses: softprops/action-gh-release@v2
with: with:
name: ${{ needs.prepare.outputs.TARGET_TAG }} name: ${{ needs.prepare.outputs.TARGET_TAG }}

View File

@@ -94,7 +94,6 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: env:
OUTPUT_DIR: spt-server OUTPUT_DIR: spt-server
SOURCECODE_DIR: ${{ github.workspace }}/code
DOCKERHUB_USER: stblog DOCKERHUB_USER: stblog
DOCKERHUB_REPOSITORY: spt-server DOCKERHUB_REPOSITORY: spt-server
@@ -110,15 +109,17 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
with:
repository: '${{ env.REPOSITORY_SPT_SERVER_AIRRYCO }}'
ref: '${{ github.ref_name }}'
lfs: 'false'
fetch-depth: '0'
token: '${{ secrets.AIRRYCO_TOKEN }}'
- name: Setup Git Config - name: Setup Git Config
run: | run: |
git config --global user.name "github-actions[bot]" git config --global user.name "github-actions[bot]"
git config --global user.email "bot@github.com" git config --global user.email "bot@github.com"
git config -f .lfsconfig lfs.url https://${{ secrets.GITEA_PUSH_TOKEN }}:@git.rui.he.cn:3000/henry/spt-server.git/info/lfs
- name: Clone AirryCo's Linux Server Code
run: |
git clone -b ${{ github.ref_name }} ${{ env.SERVER_URL }}/${{ env.REPOSITORY_SPT_SERVER_AIRRYCO }} ${{ env.SOURCECODE_DIR }}
cd ${{ env.SOURCECODE_DIR }}
git lfs pull git lfs pull
shell: bash shell: bash
@@ -130,8 +131,6 @@ jobs:
- name: Runner Debug Information - name: Runner Debug Information
id: debug-info id: debug-info
run: | run: |
cp -v ${{ env.SOURCECODE_DIR }}/project/package.json .
cd ${{ env.SOURCECODE_DIR }}
echo "git version: $(git --version)" echo "git version: $(git --version)"
echo "git lfs version: $(git-lfs --version)" echo "git lfs version: $(git-lfs --version)"
echo "node.js version: $(node --version)" echo "node.js version: $(node --version)"
@@ -147,22 +146,22 @@ jobs:
uses: actions/cache@v4 uses: actions/cache@v4
with: with:
path: | path: |
${{ env.SOURCECODE_DIR }}/project/node_modules project/node_modules
key: ${{ runner.os }}-npm-dependencies-${{ hashFiles('package.json') }} key: ${{ runner.os }}-npm-dependencies-${{ hashFiles('project/package.json') }}
restore-keys: | restore-keys: |
${{ runner.os }}-npm-dependencies- ${{ runner.os }}-npm-dependencies-
- name: Install NPM Dependencies - name: Install NPM Dependencies
if: steps.cache-npm-dependencies.outputs.cache-hit != 'true' if: steps.cache-npm-dependencies.outputs.cache-hit != 'true'
run: | run: |
cd ${{ env.SOURCECODE_DIR }}/project cd project
npm install npm install
shell: bash shell: bash
- name: Build Linux Server - name: Build Linux Server
id: build-server id: build-server
run: | run: |
cd ${{ env.SOURCECODE_DIR }}/project cd project
npm run build:release npm run build:release
ls -l build ls -l build
mv build ${{ env.OUTPUT_DIR }} mv build ${{ env.OUTPUT_DIR }}
@@ -182,8 +181,9 @@ jobs:
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: ${{ steps.filename.outputs.LINUX_ARTIFACT }} name: ${{ steps.filename.outputs.LINUX_ARTIFACT }}
path: ${{ env.SOURCECODE_DIR }}/project/${{ env.OUTPUT_DIR }} path: project/${{ env.OUTPUT_DIR }}
overwrite: true overwrite: true
retention-days: 1
build-docker-image-multi-arch: build-docker-image-multi-arch:
needs: [prepare, build-server-linux] needs: [prepare, build-server-linux]
@@ -194,9 +194,16 @@ jobs:
GHCR_USER: airryco GHCR_USER: airryco
GHCR_REPOSITORY: spt-server GHCR_REPOSITORY: spt-server
outputs:
DOCKER_DIGEST: ${{ steps.build-and-push.outputs.digest }}
DOCKER_IMAGEID: ${{ steps.build-and-push.outputs.imageid }}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Git pull
run: |
git pull
# docker # docker
- name: Extract metadata for Docker with release version - name: Extract metadata for Docker with release version
@@ -225,30 +232,6 @@ jobs:
type=semver,pattern={{version}}-fika,value=${{ needs.prepare.outputs.TARGET_TAG }} type=semver,pattern={{version}}-fika,value=${{ needs.prepare.outputs.TARGET_TAG }}
type=semver,pattern={{major}}.{{minor}}-fika,value=${{ needs.prepare.outputs.TARGET_TAG }} type=semver,pattern={{major}}.{{minor}}-fika,value=${{ needs.prepare.outputs.TARGET_TAG }}
type=raw,value=latest-fika type=raw,value=latest-fika
- name: Extract metadata for Docker with bem version
if: ${{ contains(needs.prepare.outputs.TARGET_TAG, 'BE') }}
id: meta-bem
uses: docker/metadata-action@v5
with:
images: |
${{ env.DOCKERHUB_USER }}/${{ env.DOCKERHUB_REPOSITORY }}
ghcr.io/${{ env.GHCR_USER }}/${{ env.GHCR_REPOSITORY }}
registry.cn-shenzhen.aliyuncs.com/spt-server/spt-server
tags: |
type=semver,pattern={{version}},value=${{ needs.prepare.outputs.TARGET_TAG }}
type=semver,pattern={{major}}.{{minor}},value=${{ needs.prepare.outputs.TARGET_TAG }}
- name: Extract metadata for Docker with bem version and fika built-in
if: ${{ contains(needs.prepare.outputs.TARGET_TAG, 'BE') }}
id: meta-bem-fika
uses: docker/metadata-action@v5
with:
images: |
${{ env.DOCKERHUB_USER }}/${{ env.DOCKERHUB_REPOSITORY }}
ghcr.io/${{ env.GHCR_USER }}/${{ env.GHCR_REPOSITORY }}
registry.cn-shenzhen.aliyuncs.com/spt-server/spt-server
tags: |
type=semver,pattern={{version}}-fika,value=${{ needs.prepare.outputs.TARGET_TAG }}
type=semver,pattern={{major}}.{{minor}}-fika,value=${{ needs.prepare.outputs.TARGET_TAG }}
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
@@ -305,41 +288,11 @@ jobs:
org.opencontainers.image.revision=${{ needs.build-server-linux.outputs.LINUX_COMMIT_ID_WHOLE }} org.opencontainers.image.revision=${{ needs.build-server-linux.outputs.LINUX_COMMIT_ID_WHOLE }}
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64
- name: Build and Push For BEM With Fika
if: ${{ contains(needs.prepare.outputs.TARGET_TAG, 'BE') }}
uses: docker/build-push-action@v6
with:
context: ./docker
file: ./docker/Dockerfile-manual-fika
push: true
tags: ${{ steps.meta-bem-fika.outputs.tags }}
labels: |
${{ steps.meta-bem-fika.outputs.labels }}
org.opencontainers.image.source=https://github.com/AirryCo/spt-server
org.opencontainers.image.url=https://github.com/AirryCo/spt-server
org.opencontainers.image.revision=${{ needs.build-server-linux.outputs.LINUX_COMMIT_ID_WHOLE }}
platforms: linux/amd64,linux/arm64
- name: Build and Push For BEM
if: ${{ contains(needs.prepare.outputs.TARGET_TAG, 'BE') }}
uses: docker/build-push-action@v6
with:
context: ./docker
file: ./docker/Dockerfile-manual
push: true
tags: ${{ steps.meta-bem.outputs.tags }}
labels: |
${{ steps.meta-bem.outputs.labels }}
org.opencontainers.image.source=https://github.com/AirryCo/spt-server
org.opencontainers.image.url=https://github.com/AirryCo/spt-server
org.opencontainers.image.revision=${{ needs.build-server-linux.outputs.LINUX_COMMIT_ID_WHOLE }}
platforms: linux/amd64,linux/arm64
build-server-windows: build-server-windows:
needs: [prepare, build-server-linux] needs: [prepare, build-server-linux]
runs-on: windows-latest runs-on: windows-latest
env: env:
OUTPUT_DIR: spt-server OUTPUT_DIR: spt-server
SOURCECODE_DIR: c:/snapshot
outputs: outputs:
WIN_COMMIT_ID: ${{ steps.debug-info.outputs.COMMIT_ID }} WIN_COMMIT_ID: ${{ steps.debug-info.outputs.COMMIT_ID }}
WIN_ARTIFACT: ${{ steps.filename.outputs.WIN_ARTIFACT }} WIN_ARTIFACT: ${{ steps.filename.outputs.WIN_ARTIFACT }}
@@ -349,38 +302,35 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
with:
- name: Clone AirroCo's Server Code repository: '${{ env.REPOSITORY_SPT_SERVER_AIRRYCO }}'
run: | ref: '${{ github.ref_name }}'
git clone -b ${{ github.ref_name }} --depth=1 ${{ env.SERVER_URL }}/${{ env.REPOSITORY_SPT_SERVER_AIRRYCO }} ${{ env.SOURCECODE_DIR }} lfs: 'false'
cd ${{ env.SOURCECODE_DIR }} fetch-depth: '1'
git lfs pull token: '${{ secrets.AIRRYCO_TOKEN }}'
shell: bash
# Modify the JSON file with PowerShell # Modify the JSON file with PowerShell
- name: Modify JSON file with PowerShell - name: Modify JSON file with PowerShell
run: | run: |
cd ${{ env.SOURCECODE_DIR }}/project/assets/configs cd project/assets/configs
$json = Get-Content -Path "core.json" | ConvertFrom-Json $json = Get-Content -Path "core.json" | ConvertFrom-Json
$json.projectName = "AirryCo's SPT Windows" $json.projectName = "AirryCo's SPT Windows"
$json | ConvertTo-Json -Depth 10 | Set-Content -Path "core.json" $json | ConvertTo-Json -Depth 10 | Set-Content -Path "core.json"
shell: pwsh shell: pwsh
- name: Replace serverExeName - name: Replace serverExeName
run: | run: |
cd ${{ env.SOURCECODE_DIR }}/project cd project
sed -i 's/SPT.Server/SPT.Server.exe/g' gulpfile.mjs sed -i 's/SPT.Server/SPT.Server.exe/g' gulpfile.mjs
shell: bash shell: bash
- name: Setup Node - name: Setup Node
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version: 20.11.1 node-version: 22.12.0
- name: Runner Debug Information - name: Runner Debug Information
id: debug-info id: debug-info
run: | run: |
cp -v ${{ env.SOURCECODE_DIR }}/project/package.json .
cd ${{ env.SOURCECODE_DIR }}
echo "git version: $(git --version)" echo "git version: $(git --version)"
echo "git lfs version: $(git-lfs --version)" echo "git lfs version: $(git-lfs --version)"
echo "node.js version: $(node --version)" echo "node.js version: $(node --version)"
@@ -395,22 +345,24 @@ jobs:
uses: actions/cache@v4 uses: actions/cache@v4
with: with:
path: | path: |
${{ env.SOURCECODE_DIR }}/project/node_modules project/node_modules
key: ${{ runner.os }}-npm-dependencies-${{ hashFiles('package.json') }} key: ${{ runner.os }}-npm-dependencies-${{ hashFiles('project/package.json') }}
restore-keys: | restore-keys: |
${{ runner.os }}-npm-dependencies- ${{ runner.os }}-npm-dependencies-
- name: Install NPM Dependencies - name: Install NPM Dependencies
if: steps.cache-npm-dependencies.outputs.cache-hit != 'true' if: steps.cache-npm-dependencies.outputs.cache-hit != 'true'
run: | run: |
cd ${{ env.SOURCECODE_DIR }}/project cd project
npm install npm install
shell: pwsh shell: pwsh
- name: Build Windows Server - name: Build Windows Server
id: build-server id: build-server
run: | run: |
cd ${{ env.SOURCECODE_DIR }}/project git config -f .lfsconfig lfs.url https://${{ secrets.GITEA_PUSH_TOKEN }}:@git.rui.he.cn:3000/henry/spt-server.git/info/lfs
git lfs pull
cd project
npm run build:release npm run build:release
ls -l build ls -l build
mv build ${{ env.OUTPUT_DIR }} mv build ${{ env.OUTPUT_DIR }}
@@ -430,7 +382,7 @@ jobs:
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: ${{ steps.filename.outputs.WIN_ARTIFACT }} name: ${{ steps.filename.outputs.WIN_ARTIFACT }}
path: ${{ env.SOURCECODE_DIR }}/project/${{ env.OUTPUT_DIR }} path: project/${{ env.OUTPUT_DIR }}
overwrite: true overwrite: true
assemble-and-publish: assemble-and-publish:
@@ -479,7 +431,7 @@ jobs:
- name: Create Github Pre-release - name: Create Github Pre-release
id: create_pre_release id: create_pre_release
if: ${{ contains(needs.prepare.outputs.TARGET_TAG, 'BEM') }} if: ${{ contains(needs.prepare.outputs.TARGET_TAG, 'BE') }}
uses: softprops/action-gh-release@v2 uses: softprops/action-gh-release@v2
with: with:
name: ${{ needs.prepare.outputs.TARGET_TAG }} name: ${{ needs.prepare.outputs.TARGET_TAG }}
@@ -528,7 +480,7 @@ jobs:
- name: Create Github Release - name: Create Github Release
id: create_release id: create_release
if: ${{ !contains(needs.prepare.outputs.TARGET_TAG, 'BEM') }} if: ${{ !contains(needs.prepare.outputs.TARGET_TAG, 'BE') }}
uses: softprops/action-gh-release@v2 uses: softprops/action-gh-release@v2
with: with:
name: ${{ needs.prepare.outputs.TARGET_TAG }} name: ${{ needs.prepare.outputs.TARGET_TAG }}

View File

@@ -1,6 +1,6 @@
FROM node:20.11.1-bullseye AS server-builder FROM node:20.11.1-bullseye AS server-builder
RUN apt update && apt install -y git git-lfs p7zip-full && \ RUN apt update && apt install -y git git-lfs p7zip-full && \
git clone -b 3.10.5 --depth=1 https://github.com/AirryCo/spt-server.git /snapshot && \ git clone -b 3.11.1 --depth=1 https://github.com/AirryCo/spt-server.git /snapshot && \
cd /snapshot && git lfs pull && \ cd /snapshot && git lfs pull && \
cd project && \ cd project && \
npm install && npm run build:release && \ npm install && npm run build:release && \

View File

@@ -1,13 +1,13 @@
FROM node:20.11.1-alpine AS fika-builder FROM node:20.11.1-alpine AS fika-builder
RUN apk add --no-cache git unzip && \ RUN apk add --no-cache git unzip && \
git clone -b v2.3.6 --depth=1 https://github.com/project-fika/Fika-Server.git /fika-server && \ git clone -b v2.4.1 --depth=1 https://github.com/project-fika/Fika-Server.git /fika-server && \
cd /fika-server && \ cd /fika-server && \
npm install && npm run build && \ npm install && npm run build && \
mkdir output && cd output && unzip /fika-server/dist/*.zip mkdir output && cd output && unzip /fika-server/dist/*.zip
FROM node:20.11.1-bullseye AS server-builder FROM node:20.11.1-bullseye AS server-builder
RUN apt update && apt install -y git git-lfs p7zip-full && \ RUN apt update && apt install -y git git-lfs p7zip-full && \
git clone -b 3.10.5 --depth=1 https://github.com/AirryCo/spt-server.git /snapshot && \ git clone -b 3.11.1 --depth=1 https://github.com/AirryCo/spt-server.git /snapshot && \
cd /snapshot && git lfs pull && \ cd /snapshot && git lfs pull && \
cd project && \ cd project && \
npm install && npm run build:release && \ npm install && npm run build:release && \