Use upstream deploy scripts in CI

This commit is contained in:
peelz
2023-05-26 15:04:39 -04:00
committed by Evil Factory
parent 8890607c53
commit be178715a8
4 changed files with 270 additions and 71 deletions

51
.github/workflows/build.yml vendored Normal file
View File

@@ -0,0 +1,51 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Build
on:
workflow_dispatch:
workflow_call:
inputs:
ref:
required: true
type: string
env:
CI_DIR: 717a3c49-f5dc-42eb-b332-fcf2988d00e3
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout branch
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
with:
ref: ${{ inputs.ref }}
submodules: recursive
- name: Setup .NET
uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # v3.0.3
with:
dotnet-version: |
6.0.x
- name: Run deploy script
run: |
set -e
shopt -s globstar nullglob
shopt -u dotglob
cd Deploy
git apply < ./patches/disable-interactivity.diff
git apply < ./patches/prevent-crash-on-missing-dir.diff
./DeployAll.sh
- name: Create tarball
run: |
mkdir -p "$CI_DIR"
tar -czf "$CI_DIR/build.tar.gz" -C Deploy/bin/content .
- name: Upload tarball
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: build
path: ${{ env.CI_DIR }}/build.tar.gz

View File

@@ -7,11 +7,14 @@ on:
workflow_call:
env:
ARTIFACTS_DIR: 2049ef39-42a2-46d2-b513-ee6d2e3a7b15
CI_DIR: 2049ef39-42a2-46d2-b513-ee6d2e3a7b15
RELEASES: |
windows:Barotrauma/bin/ReleaseWindows/net6.0/win-x64/publish
linux:Barotrauma/bin/ReleaseLinux/net6.0/linux-x64/publish
mac:Barotrauma/bin/ReleaseMac/net6.0/osx-x64/publish
windows:client:Windows/Client
windows:server:Windows/Server
linux:client:Linux/Client
linux:server:Linux/Server
mac:client:Mac/Client/Barotrauma.app/Contents/MacOS
mac:server:Mac/Server
ARCHIVE_BASE_NAME: luacsforbarotrauma
# XXX: these file names are subject to shell expansion.
# Be careful when using special characters.
@@ -51,34 +54,26 @@ env:
jobs:
build:
uses: ./.github/workflows/build.yml
with:
ref: ${{ github.event.ref }}
publish-release:
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Checkout branch
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- name: Download build artifacts
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
submodules: recursive
name: build
path: ${{ env.CI_DIR }}
- name: Setup .NET
uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # v3.0.3
with:
dotnet-version: |
6.0.x
- name: "Build: WindowsServer"
run: dotnet publish Barotrauma/BarotraumaServer/WindowsServer.csproj -c Release -clp:"ErrorsOnly;Summary" --self-contained -r win-x64 \/p:Platform="x64"
- name: "Build: WindowsClient"
run: dotnet publish Barotrauma/BarotraumaClient/WindowsClient.csproj -c Release -clp:"ErrorsOnly;Summary" --self-contained -r win-x64 \/p:Platform="x64"
- name: "Build: LinuxServer"
run: dotnet publish Barotrauma/BarotraumaServer/LinuxServer.csproj -c Release -clp:"ErrorsOnly;Summary" --self-contained -r linux-x64 \/p:Platform="x64"
- name: "Build: LinuxClient"
run: dotnet publish Barotrauma/BarotraumaClient/LinuxClient.csproj -c Release -clp:"ErrorsOnly;Summary" --self-contained -r linux-x64 \/p:Platform="x64"
- name: "Build: MacServer"
run: dotnet publish Barotrauma/BarotraumaServer/MacServer.csproj -c Release -clp:"ErrorsOnly;Summary" --self-contained -r osx-x64 \/p:Platform="x64"
- name: "Build: MacClient"
run: dotnet publish Barotrauma/BarotraumaClient/MacClient.csproj -c Release -clp:"ErrorsOnly;Summary" --self-contained -r osx-x64 \/p:Platform="x64"
- 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: |
@@ -98,46 +93,53 @@ jobs:
lines_to_array ARCHIVE_FILES_SERVER
lines_to_array RELEASES
artifacts_dir="$(realpath -m "$ARTIFACTS_DIR")"
artifacts_dir="$(realpath -m "$CI_DIR/artifacts")"
mkdir -p "$artifacts_dir"
for i in "${!RELEASES[@]}"; do
[[ -z "${RELEASES[i]}" ]] && continue
(
IFS=':' read platform publish_dir _rest <<< "${RELEASES[i]}"
cd "$publish_dir"
echo "Creating build_${platform}.zip"
zip --must-match -qr "${artifacts_dir}/${ARCHIVE_BASE_NAME}_build_${platform}.zip" *
echo "Creating patch_${platform}_client.zip"
zip --must-match -qr "${artifacts_dir}/${ARCHIVE_BASE_NAME}_patch_${platform}_client.zip" \
${ARCHIVE_FILES_SHARED[@]} \
${ARCHIVE_FILES_CLIENT[@]}
echo "Creating patch_${platform}_server.zip"
zip --must-match -qr "${artifacts_dir}/${ARCHIVE_BASE_NAME}_patch_${platform}_server.zip" \
${ARCHIVE_FILES_SHARED[@]} \
${ARCHIVE_FILES_SERVER[@]}
)
done
archives_dir="$(realpath -m "$CI_DIR/archives")"
mkdir -p "$archives_dir"
for i in "${!RELEASES[@]}"; do
[[ -z "${RELEASES[i]}" ]] && continue
(
IFS=':' read platform publish_dir _rest <<< "${RELEASES[i]}"
cd "$publish_dir"
echo "Creating build_${platform}.tar.gz"
tar -czf "${artifacts_dir}/${ARCHIVE_BASE_NAME}_build_${platform}.tar.gz" \
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 \
*
echo "Creating patch_${platform}_client.tar.gz"
tar -czf "${artifacts_dir}/${ARCHIVE_BASE_NAME}_patch_${platform}_client.tar.gz" \
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 \
${ARCHIVE_FILES_SHARED[@]} \
${ARCHIVE_FILES_CLIENT[@]}
echo "Creating patch_${platform}_server.tar.gz"
tar -czf "${artifacts_dir}/${ARCHIVE_BASE_NAME}_patch_${platform}_server.tar.gz" \
--owner=0 --group=0 \
${ARCHIVE_FILES_SHARED[@]} \
${ARCHIVE_FILES_SERVER[@]}
"${files[@]}"
)
done
@@ -150,15 +152,5 @@ jobs:
title: "Automatic build"
body: "Automatic build"
files: |
${{ env.ARTIFACTS_DIR }}/${{ env.ARCHIVE_BASE_NAME }}_build_windows.zip
${{ env.ARTIFACTS_DIR }}/${{ env.ARCHIVE_BASE_NAME }}_patch_windows_client.zip
${{ env.ARTIFACTS_DIR }}/${{ env.ARCHIVE_BASE_NAME }}_patch_windows_server.zip
${{ env.ARTIFACTS_DIR }}/${{ env.ARCHIVE_BASE_NAME }}_build_linux.zip
${{ env.ARTIFACTS_DIR }}/${{ env.ARCHIVE_BASE_NAME }}_build_linux.tar.gz
${{ env.ARTIFACTS_DIR }}/${{ env.ARCHIVE_BASE_NAME }}_patch_linux_client.zip
${{ env.ARTIFACTS_DIR }}/${{ env.ARCHIVE_BASE_NAME }}_patch_linux_client.tar.gz
${{ env.ARTIFACTS_DIR }}/${{ env.ARCHIVE_BASE_NAME }}_patch_linux_server.zip
${{ env.ARTIFACTS_DIR }}/${{ env.ARCHIVE_BASE_NAME }}_patch_linux_server.tar.gz
${{ env.ARTIFACTS_DIR }}/${{ env.ARCHIVE_BASE_NAME }}_build_mac.zip
${{ env.ARTIFACTS_DIR }}/${{ env.ARCHIVE_BASE_NAME }}_patch_mac_client.zip
${{ env.ARTIFACTS_DIR }}/${{ env.ARCHIVE_BASE_NAME }}_patch_mac_server.zip
${{ env.CI_DIR }}/archives/${{ env.ARCHIVE_BASE_NAME }}_{build,patch}_{windows,linux,mac}_{client,server}.zip
${{ env.CI_DIR }}/archives/${{ env.ARCHIVE_BASE_NAME }}_{build,patch}_linux_{client,server}.tar.gz

View File

@@ -0,0 +1,43 @@
diff --git a/Deploy/DeployAll/Program.cs b/Deploy/DeployAll/Program.cs
index 3de060435..6e199b4d4 100644
--- a/Deploy/DeployAll/Program.cs
+++ b/Deploy/DeployAll/Program.cs
@@ -22,37 +22,9 @@ string gitBranch = GitCmd.GetBranch();
Console.WriteLine($"DEPLOYALL - Barotrauma v{gameVersion}, branch {gitBranch}, revision {gitRevision}");
-if (GitCmd.HasUncommittedChanges())
-{
- if (Util.AskQuestion("The repo currently has some uncommitted changes. Do you still wish to proceed? [y/n]")
- .AnsweredNo()) { return; }
-}
-else if (GitCmd.IsRepoOutOfSync())
-{
- if (Util.AskQuestion("The repo is currently out of sync. Do you still wish to proceed? [y/n]")
- .AnsweredNo()) { return; }
-}
-
var sdkVersion = DotnetCmd.GetSdkVersion();
Console.WriteLine($"Using .NET SDK {sdkVersion}");
-string configuration = Util.AskQuestion("Type 1 for Release, 2 for Unstable, enter nothing to cancel") switch
-{
- "1" => "Release",
- "2" => "Unstable",
- _ => ""
-};
-if (string.IsNullOrWhiteSpace(configuration)) { return; }
+const string configuration = "Release";
Deployables.Generate(configuration, gameVersion, gitBranch, gitRevision);
-
-if (Util.AskQuestion("Would you like to upload the generated builds to Steam? [y/n]")
- .AnsweredNo()) { return; }
-
-SteamPipeAssistant.PrepareSteamCmd();
-SteamPipeAssistant.PrepareScripts(configuration, gameVersion, gitBranch, gitRevision);
-
-string userName = Util.AskQuestion("Type your Steam username to upload to Steamworks, enter nothing to skip uploading");
-if (string.IsNullOrWhiteSpace(userName)) { return; }
-
-SteamPipeAssistant.Upload(userName, configuration);

View File

@@ -0,0 +1,113 @@
diff --git a/Deploy/DeployAll/Util.cs b/Deploy/DeployAll/Util.cs
index 6962ac512..d700c7f8e 100644
--- a/Deploy/DeployAll/Util.cs
+++ b/Deploy/DeployAll/Util.cs
@@ -10,97 +10,106 @@ namespace DeployAll;
public static class Util
{
public static void DeleteFiles(string path, params string[] patterns)
{
foreach (var file in patterns.SelectMany(p => Directory.GetFiles(path, p, SearchOption.AllDirectories)))
{
File.Delete(file);
string dir = file;
do
{
dir = Path.GetDirectoryName(dir) ?? "";
if (Directory.GetFiles(dir, "*", SearchOption.AllDirectories).Length == 0)
{
Directory.Delete(dir, recursive: false);
}
else
{
break;
}
} while (dir.LastIndexOf('/') > 0);
}
}
public static void CopyDirectory(string sourceDir, string destinationDir)
{
var dir = new DirectoryInfo(sourceDir);
- DirectoryInfo[] dirs = dir.GetDirectories();
+ DirectoryInfo[] dirs;
+ try
+ {
+ dirs = dir.GetDirectories();
+ }
+ catch (DirectoryNotFoundException ex)
+ {
+ Console.WriteLine($"WARNING: attempted to copy non-existing directory: {ex}");
+ return;
+ }
Directory.CreateDirectory(destinationDir);
foreach (FileInfo file in dir.GetFiles())
{
string targetFilePath = Path.Combine(destinationDir, file.Name);
file.CopyTo(targetFilePath);
}
foreach (DirectoryInfo subDir in dirs)
{
string newDestinationDir = Path.Combine(destinationDir, subDir.Name);
CopyDirectory(subDir.FullName, newDestinationDir);
}
}
public static void DeleteDirectory(string path)
{
if (Directory.Exists(path))
{
Directory.Delete(path, recursive: true);
}
}
public static void RecreateDirectory(string path)
{
DeleteDirectory(path);
Directory.CreateDirectory(path);
}
public static IReadOnlyList<byte> DownloadFile(string url)
{
var httpClient = new HttpClient();
var response = httpClient.Send(new HttpRequestMessage(
HttpMethod.Get,
new Uri(url)));
using var stream = response.Content.ReadAsStream();
using var reader = new BinaryReader(stream);
var contents = new List<byte>();
while (true)
{
byte[] bytesRead = reader.ReadBytes(1024);
if (bytesRead.Length == 0) { break; }
contents.AddRange(bytesRead);
}
return contents;
}
public static string AskQuestion(string question)
{
Console.WriteLine(question);
Console.Write("> ");
string answer = Console.ReadLine() ?? "";
Console.WriteLine("");
return answer;
}
public static bool AnsweredYes(this string answer)
=> answer.Equals("y", StringComparison.InvariantCulture);
public static bool AnsweredNo(this string answer)
=> !answer.AnsweredYes();
public static Process StartProcess(ProcessStartInfo info)
=> Process.Start(info)
?? throw new Exception($"Failed to start process \"{info.FileName}\"");
}
\ No newline at end of file