Add build types to build script; enable CI for all branches

This commit is contained in:
ghorsington committed 2022-08-14 17:19:09 +03:00
1 parent 27016a3680
commit add17f1fe8
3 files changed
+51 -22

No files matched your search

@@ -1,15 +1,12 @@
name: Build Bleeding Edge
name: Build
on:
push:
branches:
- master
on: push
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.5
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Need to fetch all for proper history
- name: Collect build info
@@ -17,12 +14,22 @@ jobs:
uses: actions/github-script@v6
with:
script: |
core.setOutput("is_be", context.repo.owner == "BepInEx");
core.setOutput("sha_short", await exec.exec("git", ["rev-parse", "--short", "HEAD"]));
core.setOutput("build_id", context.run.runNumber + 500); // builds.bepinex.dev build numbers start at 500
let buildType = "Development";
if (context.ref == "refs/heads/master" && context.repo.owner == "BepInEx") {
buildType = "BleedingEdge";
}
core.setOutput("build_type", buildType);
let shortHash = "";
await exec.exec("git", ["rev-parse", "--short", "HEAD"], {
listeners: {
stdout: d => shortHash += d.toString().trim(),
}
});
core.setOutput("sha_short", shortHash);
core.setOutput("build_id", context.runNumber + 600); // builds.bepinex.dev build numbers start at 500
- uses: nrwl/last-successful-commit-action@v1
id: last_successful_commit
if: ${{ steps.info.outputs.is_be == 'true' && env.GITHUB_TOKEN != null }}
if: ${{ steps.info.outputs.build_type == 'BleedingEdge' && env.GITHUB_TOKEN != null }}
with:
branch: master
workflow_id: build_be.yml
@@ -32,15 +39,17 @@ jobs:
dotnet-version: "6.0.x"
- name: Build
run: |
./build.sh --target Publish --bleeding-edge ${{ steps.info.outputs.is_be }} --build-id ${{ steps.info.outputs.build_id }} --last-build-commit \"${{ steps.last_successful_commit.outputs.commit_hash }}\" --nuget-api-key \"${{ secrets.BEPIN_DEV_NUGET_KEY }}\"
./build.sh --target Publish --build-type ${{ steps.info.outputs.build_type }} --build-id ${{ steps.info.outputs.build_id }} --last-build-commit \"${{ steps.last_successful_commit.outputs.commit_hash }}\" --nuget-api-key \"${{ secrets.BEPIN_DEV_NUGET_KEY }}\"
- name: Upload to BepinBuilds
if: ${{ steps.info.outputs.is_be == 'true' && secrets.BEPISBUILDS_HOST != null }}
env:
BEPISBUILDS_HOST: ${{ secrets.BEPISBUILDS_HOST }}
if: ${{ steps.info.outputs.build_type == 'BleedingEdge' && env.BEPISBUILDS_HOST != null }}
run: |
artifacts_list=$(ls ./bin/dist/*.* | tr '\n' ','); artifacts_list=${artifacts_list::-1};
curl --upload-file "{${artifacts_list}}" --ftp-pasv --ftp-skip-pasv-ip --ftp-create-dirs --ftp-method singlecwd --disable-epsv "ftp://${{ secrets.BEPISBUILDS_AUTH }}@${{ secrets.BEPISBUILDS_HOST }}:${{ secrets.BEPISBUILDS_PORT }}/bepinex_be/artifacts/${{ steps.info.outputs.build_id }}/"
- name: Generate changelog
id: generate_changelog
if: ${{ steps.info.outputs.is_be == 'true' }}
if: ${{ steps.info.outputs.build_type == 'BleedingEdge' }}
run: |
changelog=$(git --no-pager log --no-merges --pretty="format:- (\`%h\`) [%an] %s" ${{ steps.last_successful_commit.outputs.commit_hash }}..HEAD | sed ':a;N;$!ba;s/"/\"/g' | sed ':a;N;$!ba;s/\n/\\n/g')
echo "::set-output name=changelog::$changelog"
@@ -48,7 +57,7 @@ jobs:
uses: joelwmale/webhook-action@2.1.0
env:
BEPINEX_DISCORD_WEBHOOK: ${{ secrets.BEPINEX_DISCORD_WEBHOOK }}
if: ${{ steps.info.outputs.is_be == 'true' && env.BEPINEX_DISCORD_WEBHOOK != null }}
if: ${{ steps.info.outputs.build_type == 'BleedingEdge' && env.BEPINEX_DISCORD_WEBHOOK != null }}
with:
url: ${{ secrets.BEPINEX_DISCORD_WEBHOOK }}
body: |
@@ -66,5 +75,5 @@ jobs:
uses: actions/upload-artifact@v2.2.4
with:
path: "./bin/dist/*.zip"
name: "BepInEx_CI_${{ steps.info.outputs.sha_short }}_${{ steps.info.outputs.build_id || 0 }}"
name: "BepInEx_CI_${{ steps.info.outputs.build_type }}_${{ steps.info.outputs.sha_short }}_${{ steps.info.outputs.build_id || 0 }}"
+1 -1
View File
@@ -21,6 +21,6 @@
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>
<ItemGroup>
<None Include="$(SolutionDir)\Assets\logos\logo.png" Pack="true" Visible="false" PackagePath=""/>
<None Include="$(SolutionDir)\assets\logos\logo.png" Pack="true" Visible="false" PackagePath=""/>
</ItemGroup>
</Project>
+26 -6
View File
@@ -25,6 +25,13 @@ return new CakeHost()
public class BuildContext : FrostingContext
{
public enum ProjectBuildType
{
Release,
Development,
BleedingEdge
}
public const string DoorstopVersion = "4.0.0-rc.5";
public const string DotnetRuntimeVersion = "6.0.6-test";
public const string DobbyVersion = "1.0.0";
@@ -60,14 +67,14 @@ public class BuildContext : FrostingContext
VersionPrefix = props.GetPropertyValue("VersionPrefix");
CurrentCommit = ctx.GitLogTip(RootDirectory);
BleedingEdge = ctx.Argument("bleeding-edge", false);
BuildType = ctx.Argument("build-type", ProjectBuildType.Development);
BuildId = ctx.Argument("build-id", -1);
LastBuildCommit = ctx.Argument("last-build-commit", "");
NugetApiKey = ctx.Argument("nuget-api-key", "");
NugetSource = ctx.Argument("nuget-source", "https://nuget.bepinex.dev/v3/index.json");
}
public bool BleedingEdge { get; }
public ProjectBuildType BuildType { get; }
public int BuildId { get; }
public string LastBuildCommit { get; }
public string NugetApiKey { get; }
@@ -81,8 +88,20 @@ public class BuildContext : FrostingContext
public string VersionPrefix { get; }
public GitCommit CurrentCommit { get; }
public string VersionSuffix => BuildType switch
{
ProjectBuildType.Release => "",
ProjectBuildType.Development => "dev",
ProjectBuildType.BleedingEdge => $"be.{BuildId}",
var _ => throw new ArgumentOutOfRangeException()
};
public string BuildPackageVersion =>
$"{VersionPrefix}{(BleedingEdge ? $"-be.{BuildId}+{this.GitShortenSha(RootDirectory, CurrentCommit)}" : "")}";
VersionPrefix + BuildType switch
{
ProjectBuildType.Release => "",
var _ => $"-{VersionSuffix}+{this.GitShortenSha(RootDirectory, CurrentCommit)}",
};
public static string DoorstopZipUrl(string arch) =>
$"https://github.com/NeighTools/UnityDoorstop/releases/download/v{DoorstopVersion}/doorstop_{arch}_release_{DoorstopVersion}.zip";
@@ -116,11 +135,11 @@ public sealed class CompileTask : FrostingTask<BuildContext>
{
Configuration = "Release"
};
if (ctx.BleedingEdge)
if (ctx.BuildType != BuildContext.ProjectBuildType.Release)
{
buildSettings.MSBuildSettings = new()
{
VersionSuffix = $"be.{ctx.BuildId}",
VersionSuffix = ctx.VersionSuffix,
Properties =
{
["SourceRevisionId"] = new[] { ctx.CurrentCommit.Sha },
@@ -272,7 +291,8 @@ public sealed class MakeDistTask : FrostingTask<BuildContext>
[TaskName("PushNuGet")]
public sealed class PushNuGetTask : FrostingTask<BuildContext>
{
public override bool ShouldRun(BuildContext ctx) => !string.IsNullOrWhiteSpace(ctx.NugetApiKey);
public override bool ShouldRun(BuildContext ctx) => !string.IsNullOrWhiteSpace(ctx.NugetApiKey) &&
ctx.BuildType != BuildContext.ProjectBuildType.Development;
public override void Run(BuildContext ctx)
{