Files

253 lines
9.7 KiB
YAML

name: Publish release
on:
workflow_dispatch:
inputs:
target:
description: "The git ref to checkout, build from and release"
required: true
type: string
tag:
description: "The tag of the release"
required: true
type: string
prerelease:
description: "Prerelease"
required: false
default: false
type: boolean
workflow_call:
inputs:
target:
description: "The git ref to checkout, build from and release"
required: true
type: string
tag:
description: "The tag of the release"
required: true
type: string
prerelease:
description: "Prerelease"
required: false
default: false
type: boolean
env:
CI_DIR: 2049ef39-42a2-46d2-b513-ee6d2e3a7b15
RELEASES: |
windows:server:Windows/Server
linux:server:Linux/Server
mac:server:Mac/Server
windows:client:Windows/Client
linux:client:Linux/Client
mac:client:Mac/Client/Barotrauma.app/Contents/MacOS
ARCHIVE_BASE_NAME: luacsforbarotraumaEP
ARCHIVE_FILES_SERVER: |
DedicatedServer.deps.json
DedicatedServer.dll
DedicatedServer.pdb
Publicized/DedicatedServer.dll
ARCHIVE_FILES_CLIENT: |
Barotrauma.deps.json
Barotrauma.dll
Barotrauma.pdb
DedicatedServer.deps.json
DedicatedServer.dll
DedicatedServer.pdb
Publicized/Barotrauma.dll
Publicized/DedicatedServer.dll
ARCHIVE_FILES_SHARED: |
BarotraumaCore.dll
BarotraumaCore.pdb
Publicized/BarotraumaCore.dll
0Harmony.dll
Sigil.dll
MoonSharp.Interpreter.dll
MoonSharp.VsCodeDebugger.dll
MonoMod.Backports.dll
MonoMod.Core.dll
MonoMod.RuntimeDetour.dll
MonoMod.ILHelpers.dll
MonoMod.Utils.dll
MonoMod.Iced.dll
Mono.Cecil.dll
Mono.Cecil.Mdb.dll
Mono.Cecil.Pdb.dll
Mono.Cecil.Rocks.dll
LightInject.dll
OneOf.dll
FluentResults.dll
Basic.Reference.Assemblies.Net80.dll
Microsoft.Extensions.Logging.Abstractions.dll
Microsoft.Toolkit.Diagnostics.dll
Microsoft.CodeAnalysis.CSharp.dll
Microsoft.CodeAnalysis.dll
System.Collections.Immutable.dll
System.Reflection.Metadata.dll
System.Runtime.CompilerServices.Unsafe.dll
mscordaccore_amd64_amd64_*
LocalMods/LuaCsForBarotrauma
jobs:
build:
uses: ./.gitea/workflows/build.yml
with:
target: ${{ inputs.target }}
publish-release:
runs-on: ubuntu-22.04
needs: [build]
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build
path: ${{ env.CI_DIR }}
- name: Extract build artifacts
run: |
artifacts_dir="$(realpath -m "$CI_DIR/artifacts")"
mkdir -p "$artifacts_dir"
tar -xzf "$CI_DIR/build.tar.gz" -C "$artifacts_dir"
rm "$CI_DIR/build.tar.gz"
- name: Create archives
run: |
set -e
shopt -s globstar nullglob
shopt -u dotglob
lines_to_array() {
IFS=$'\n' readarray -td $'\n' "$1" <<< "${!1}"
}
lines_to_array ARCHIVE_FILES_SHARED
lines_to_array ARCHIVE_FILES_CLIENT
lines_to_array ARCHIVE_FILES_SERVER
lines_to_array RELEASES
artifacts_dir="$(realpath -m "$CI_DIR/artifacts")"
mkdir -p "$artifacts_dir"
archives_dir="$(realpath -m "$CI_DIR/archives")"
mkdir -p "$archives_dir"
refs_dir="$(realpath -m "$CI_DIR/refs")"
mkdir -p "${refs_dir}"
mkdir -p "${refs_dir}/Windows"
mkdir -p "${refs_dir}/Linux"
mkdir -p "${refs_dir}/OSX"
cp "${artifacts_dir}/Windows/Client/Publicized/Barotrauma.dll" "${refs_dir}/Windows/Barotrauma.dll"
cp "${artifacts_dir}/Windows/Client/Publicized/DedicatedServer.dll" "${refs_dir}/Windows/DedicatedServer.dll"
cp "${artifacts_dir}/Windows/Client/Publicized/BarotraumaCore.dll" "${refs_dir}/Windows/BarotraumaCore.dll"
cp "${artifacts_dir}/Linux/Client/Publicized/Barotrauma.dll" "${refs_dir}/Linux/Barotrauma.dll"
cp "${artifacts_dir}/Linux/Client/Publicized/DedicatedServer.dll" "${refs_dir}/Linux/DedicatedServer.dll"
cp "${artifacts_dir}/Linux/Client/Publicized/BarotraumaCore.dll" "${refs_dir}/Linux/BarotraumaCore.dll"
cp "${artifacts_dir}/Mac/Client/Barotrauma.app/Contents/MacOS/Publicized/Barotrauma.dll" "${refs_dir}/OSX/Barotrauma.dll"
cp "${artifacts_dir}/Mac/Client/Barotrauma.app/Contents/MacOS/Publicized/DedicatedServer.dll" "${refs_dir}/OSX/DedicatedServer.dll"
cp "${artifacts_dir}/Mac/Client/Barotrauma.app/Contents/MacOS/Publicized/BarotraumaCore.dll" "${refs_dir}/OSX/BarotraumaCore.dll"
cp "${artifacts_dir}/Windows/Client/Publicized/MonoGame.Framework.Windows.NetStandard.dll" "${refs_dir}/MonoGame.Framework.Windows.NetStandard.dll"
cp "${artifacts_dir}/Linux/Client/Publicized/MonoGame.Framework.Linux.NetStandard.dll" "${refs_dir}/MonoGame.Framework.Linux.NetStandard.dll"
cp "${artifacts_dir}/Mac/Client/Barotrauma.app/Contents/MacOS/Publicized/MonoGame.Framework.MacOS.NetStandard.dll" "${refs_dir}/MonoGame.Framework.MacOS.NetStandard.dll"
cp "${artifacts_dir}/Windows/Client/Publicized/0Harmony.dll" "${refs_dir}/0Harmony.dll"
cp "${artifacts_dir}/Windows/Client/Publicized/MonoMod.Utils.dll" "${refs_dir}/MonoMod.Utils.dll"
cp "${artifacts_dir}/Windows/Client/Publicized/MonoMod.RuntimeDetour.dll" "${refs_dir}/MonoMod.RuntimeDetour.dll"
cp "${artifacts_dir}/Windows/Client/Publicized/MonoMod.ILHelpers.dll" "${refs_dir}/MonoMod.ILHelpers.dll"
cp "${artifacts_dir}/Windows/Client/Publicized/MonoMod.Iced.dll" "${refs_dir}/MonoMod.Iced.dll"
cp "${artifacts_dir}/Windows/Client/Publicized/MonoMod.Backports.dll" "${refs_dir}/MonoMod.Backports.dll"
cp "${artifacts_dir}/Windows/Client/Publicized/Farseer.NetStandard.dll" "${refs_dir}/Farseer.NetStandard.dll"
cp "${artifacts_dir}/Windows/Client/Publicized/Lidgren.NetStandard.dll" "${refs_dir}/Lidgren.NetStandard.dll"
cp "${artifacts_dir}/Windows/Client/Publicized/Mono.Cecil.dll" "${refs_dir}/Mono.Cecil.dll"
cp "${artifacts_dir}/Windows/Client/Publicized/MoonSharp.Interpreter.dll" "${refs_dir}/MoonSharp.Interpreter.dll"
cp "${artifacts_dir}/Windows/Client/Publicized/XNATypes.dll" "${refs_dir}/XNATypes.dll"
cd "${refs_dir}"
zip -r "${archives_dir}/${ARCHIVE_BASE_NAME}_refs.zip" .
for i in "${!RELEASES[@]}"; do
[[ -z "${RELEASES[i]}" ]] && continue
(
IFS=':' read platform side publish_dir _rest <<< "${RELEASES[i]}"
cd "${artifacts_dir}/${publish_dir}"
echo "Creating build_${platform}_${side}.zip"
zip --must-match -qr "${archives_dir}/${ARCHIVE_BASE_NAME}_build_${platform}_${side}.zip" *
echo "Creating build_${platform}_${side}.tar.gz"
tar -czf "${archives_dir}/${ARCHIVE_BASE_NAME}_build_${platform}_${side}.tar.gz" \
--owner=0 --group=0 \
*
if [[ "$side" == "client" ]]; then
files=(
${ARCHIVE_FILES_SHARED[@]}
${ARCHIVE_FILES_CLIENT[@]}
)
elif [[ "$side" == "server" ]]; then
files=(
${ARCHIVE_FILES_SHARED[@]}
${ARCHIVE_FILES_SERVER[@]}
)
else
echo "Invalid side: $side"
exit 1
fi
echo "Creating patch_${platform}_${side}.zip"
zip \
--must-match \
-qr \
"${archives_dir}/${ARCHIVE_BASE_NAME}_patch_${platform}_${side}.zip" \
"${files[@]}"
echo "Creating patch_${platform}_${side}.tar.gz"
tar \
-zcf "${archives_dir}/${ARCHIVE_BASE_NAME}_patch_${platform}_${side}.tar.gz" \
--owner=0 --group=0 \
"${files[@]}"
)
done
- name: Publish release
env:
CI_RELEASE_TOKEN: ${{ secrets.CI_RELEASE_TOKEN }}
run: |
set -e
tag="${{ inputs.tag }}"
target="${{ inputs.target }}"
prerelease=${{ inputs.prerelease || false }}
api_url="${GITEA_API_URL:-https://git.illegalfiles.icu/api/v1}"
repo="${GITEA_REPOSITORY:-vlad.os/LuaCsForBarotraumaEP}"
release_data=$(jq -n \
--arg tag "$tag" \
--arg target "$target" \
--arg title "Automatic build" \
--arg body "Automatic build" \
--argjson prerelease $prerelease \
'{tag_name: $tag, target_commitish: $target, name: $title, body: $body, prerelease: $prerelease}')
release=$(curl -s -X POST \
-H "Authorization: token $CI_RELEASE_TOKEN" \
-H "Content-Type: application/json" \
-d "$release_data" \
"$api_url/repos/$repo/releases")
release_id=$(echo "$release" | jq -r '.id')
if [[ "$release_id" == "null" ]]; then
echo "Failed to create release: $(echo "$release" | jq -r '.message')"
exit 1
fi
archives_dir="$(realpath -m "$CI_DIR/archives")"
for file in "$archives_dir"/*; do
if [[ -f "$file" ]]; then
echo "Uploading $(basename "$file")"
curl -s -X POST \
-H "Authorization: token $CI_RELEASE_TOKEN" \
-F "attachment=@$file" \
"$api_url/repos/$repo/releases/$release_id/assets"
fi
done