Skip to content

Commit

Permalink
Merge pull request #13 from specklesystems/alan/ci-start
Browse files Browse the repository at this point in the history
CI in cpp connectors
  • Loading branch information
r-wessel authored Nov 11, 2024
2 parents 79570b4 + 84b234f commit 4abf2b5
Show file tree
Hide file tree
Showing 11 changed files with 312 additions and 1 deletion.
11 changes: 11 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version": 1,
"isRoot": true,
"tools": {
"gitversion.tool": {
"version": "6.0.2",
"commands": ["dotnet-gitversion"],
"rollForward": false
}
}
}
91 changes: 91 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: MSBuild

on:
push:
branches: ["main", "develop", "release/*", "alan/*"] # Continuous delivery on every long-lived branch
tags: ["v3.*"] # Manual delivery on every 3.x tag

permissions:
contents: read

jobs:
build:
runs-on: windows-latest
outputs:
version: ${{ steps.set-version.outputs.version }}
file_version: ${{ steps.set-info-version.outputs.file_version }}
steps:
- uses: actions/checkout@v4
with:
path: speckle-cpp-connectors
fetch-depth: 0
- uses: actions/checkout@v4
with:
repository: r-wessel/ActiveLib
path: ActiveLib
ref: develop

- name: Download zip file
run: |
New-Item -ItemType Directory -Path "Archicad 27" -Force
Invoke-WebRequest -Uri "https://github.com/GRAPHISOFT/archicad-api-devkit/releases/download/27.3001/API.Development.Kit.WIN.27.3001.zip" -OutFile "file.zip"
- name: Extract zip file to Archicad 27 folder
run: |
Add-Type -AssemblyName System.IO.Compression.FileSystem
[System.IO.Compression.ZipFile]::ExtractToDirectory("file.zip", "Archicad 27")
- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v2

- name: ⚒️ Run GitVersion
working-directory: speckle-cpp-connectors
run: ./build.ps1 build-server-version

- name: Build
working-directory: speckle-cpp-connectors
run: ./build.ps1

- uses: actions/upload-artifact@v4
with:
name: output-${{ env.GitVersion_FullSemVer }}
path: speckle-cpp-connectors/output/*.zip
retention-days: 1

- id: set-version
name: Set version to output
run: echo "version=${{ env.GitVersion_FullSemVer }}" >> "$Env:GITHUB_OUTPUT"

- id: set-info-version
name: Set file version to output
run: echo "file_version=${{ env.GitVersion_AssemblySemVer}}" >> "$Env:GITHUB_OUTPUT" # version will be retrieved from tag?
deploy-installers:
runs-on: ubuntu-latest
needs: build
env:
IS_TAG_BUILD: ${{ github.ref_type == 'tag' }}
IS_RELEASE_BRANCH: true
steps:
- name: 🔫 Trigger Build Installers
uses: ALEEF02/[email protected]
continue-on-error: true
with:
workflow: build-cpp-installers
repo: specklesystems/connector-installers
token: ${{ secrets.CONNECTORS_GH_TOKEN }}
inputs: '{ "run_id": "${{ github.run_id }}", "version": "${{ needs.build.outputs.version }}", "file_version": "${{needs.build.outputs.file_version}}", "public_release": ${{ env.IS_TAG_BUILD }}, "store_artifacts": ${{ env.IS_RELEASE_BRANCH }} }'
ref: main
wait-for-completion: true
wait-for-completion-interval: 10s
wait-for-completion-timeout: 10m
display-workflow-run-url: true
display-workflow-run-url-interval: 10s

- uses: geekyeggo/delete-artifact@v5
with:
name: output-*
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,7 @@ XCBuildData/
*.log
.idea
*.mui
*.aps
*.aps
**/obj
**/bin
output/
6 changes: 6 additions & 0 deletions GitVersion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
workflow: GitFlow/v1
next-version: 3.0.0
branches:
release:
prevent-increment:
when-current-commit-tagged: true
36 changes: 36 additions & 0 deletions SpeckleConnector/Connector.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ActiveLib17", "..\..\Active
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SpeckleLib17", "..\SpeckleLib\SpeckleLib17.vcxproj", "{942743B7-B3CB-4F91-BE46-28937F5E3FD1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Build", "..\ci-build\Build.csproj", "{702DE13A-1CCF-485D-A50D-846F645F07D3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug16|x64 = Debug16|x64
Expand Down Expand Up @@ -143,6 +145,40 @@ Global
{942743B7-B3CB-4F91-BE46-28937F5E3FD1}.ReleaseVS2022|x64.Build.0 = ReleaseAC27|x64
{942743B7-B3CB-4F91-BE46-28937F5E3FD1}.ReleaseVS2022|x86.ActiveCfg = ReleaseAC27|Win32
{942743B7-B3CB-4F91-BE46-28937F5E3FD1}.ReleaseVS2022|x86.Build.0 = ReleaseAC27|Win32
{702DE13A-1CCF-485D-A50D-846F645F07D3}.Debug16|x64.ActiveCfg = Debug|Any CPU
{702DE13A-1CCF-485D-A50D-846F645F07D3}.Debug16|x64.Build.0 = Debug|Any CPU
{702DE13A-1CCF-485D-A50D-846F645F07D3}.Debug16|x86.ActiveCfg = Debug|Any CPU
{702DE13A-1CCF-485D-A50D-846F645F07D3}.Debug16|x86.Build.0 = Debug|Any CPU
{702DE13A-1CCF-485D-A50D-846F645F07D3}.Debug17|x64.ActiveCfg = Debug|Any CPU
{702DE13A-1CCF-485D-A50D-846F645F07D3}.Debug17|x64.Build.0 = Debug|Any CPU
{702DE13A-1CCF-485D-A50D-846F645F07D3}.Debug17|x86.ActiveCfg = Debug|Any CPU
{702DE13A-1CCF-485D-A50D-846F645F07D3}.Debug17|x86.Build.0 = Debug|Any CPU
{702DE13A-1CCF-485D-A50D-846F645F07D3}.DebugAC27|x64.ActiveCfg = Debug|Any CPU
{702DE13A-1CCF-485D-A50D-846F645F07D3}.DebugAC27|x86.ActiveCfg = Debug|Any CPU
{702DE13A-1CCF-485D-A50D-846F645F07D3}.DebugAC27|x86.Build.0 = Debug|Any CPU
{702DE13A-1CCF-485D-A50D-846F645F07D3}.DebugVS2022|x64.ActiveCfg = Debug|Any CPU
{702DE13A-1CCF-485D-A50D-846F645F07D3}.DebugVS2022|x64.Build.0 = Debug|Any CPU
{702DE13A-1CCF-485D-A50D-846F645F07D3}.DebugVS2022|x86.ActiveCfg = Debug|Any CPU
{702DE13A-1CCF-485D-A50D-846F645F07D3}.DebugVS2022|x86.Build.0 = Debug|Any CPU
{702DE13A-1CCF-485D-A50D-846F645F07D3}.Release16|x64.ActiveCfg = Debug|Any CPU
{702DE13A-1CCF-485D-A50D-846F645F07D3}.Release16|x64.Build.0 = Debug|Any CPU
{702DE13A-1CCF-485D-A50D-846F645F07D3}.Release16|x86.ActiveCfg = Debug|Any CPU
{702DE13A-1CCF-485D-A50D-846F645F07D3}.Release16|x86.Build.0 = Debug|Any CPU
{702DE13A-1CCF-485D-A50D-846F645F07D3}.Release17|x64.ActiveCfg = Debug|Any CPU
{702DE13A-1CCF-485D-A50D-846F645F07D3}.Release17|x64.Build.0 = Debug|Any CPU
{702DE13A-1CCF-485D-A50D-846F645F07D3}.Release17|x86.ActiveCfg = Debug|Any CPU
{702DE13A-1CCF-485D-A50D-846F645F07D3}.Release17|x86.Build.0 = Debug|Any CPU
{702DE13A-1CCF-485D-A50D-846F645F07D3}.ReleaseAC27|x86.ActiveCfg = Debug|Any CPU
{702DE13A-1CCF-485D-A50D-846F645F07D3}.ReleaseAC27|x86.Build.0 = Debug|Any CPU
{702DE13A-1CCF-485D-A50D-846F645F07D3}.ReleaseVS2019|x64.ActiveCfg = Debug|Any CPU
{702DE13A-1CCF-485D-A50D-846F645F07D3}.ReleaseVS2019|x64.Build.0 = Debug|Any CPU
{702DE13A-1CCF-485D-A50D-846F645F07D3}.ReleaseVS2019|x86.ActiveCfg = Debug|Any CPU
{702DE13A-1CCF-485D-A50D-846F645F07D3}.ReleaseVS2019|x86.Build.0 = Debug|Any CPU
{702DE13A-1CCF-485D-A50D-846F645F07D3}.ReleaseVS2022|x64.ActiveCfg = Debug|Any CPU
{702DE13A-1CCF-485D-A50D-846F645F07D3}.ReleaseVS2022|x64.Build.0 = Debug|Any CPU
{702DE13A-1CCF-485D-A50D-846F645F07D3}.ReleaseVS2022|x86.ActiveCfg = Debug|Any CPU
{702DE13A-1CCF-485D-A50D-846F645F07D3}.ReleaseVS2022|x86.Build.0 = Debug|Any CPU
{702DE13A-1CCF-485D-A50D-846F645F07D3}.ReleaseAC27|x64.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Empty file modified SpeckleConnector/Connector/Connector.cpp
100755 → 100644
Empty file.
3 changes: 3 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$ErrorActionPreference = "Stop";

dotnet run --project ci-build/build.csproj -- $args
4 changes: 4 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
set -euo pipefail

dotnet run --project Build/Build.csproj -- "$@"
16 changes: 16 additions & 0 deletions ci-build/Build.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<Configurations>Debug;Release;Local</Configurations>
<ImplicitUsings>true</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Bullseye" Version="5.0.0" />
<PackageReference Include="Glob" Version="1.1.9"/>
<PackageReference Include="Microsoft.Build" Version="17.10.4"/>
<PackageReference Include="SimpleExec" Version="12.0.0" />
</ItemGroup>
</Project>
18 changes: 18 additions & 0 deletions ci-build/Consts.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace Build;

public static class Consts
{
public static readonly string[] Solutions = ["SpeckleConnector/Connector.sln"];

public static readonly InstallerProject[] InstallerManifests =
{
new("archicad", [new("archicad27", "SpeckleConnector/x64/ReleaseAC27", "*.apx")])
};
}

public readonly record struct InstallerProject(string HostAppSlug, IReadOnlyList<InstallerAsset> Projects)
{
public override string ToString() => $"{HostAppSlug}";
}

public readonly record struct InstallerAsset(string ConnectorVersion, string OutputPath, string GlobPattern = "*");
123 changes: 123 additions & 0 deletions ci-build/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
using System.IO.Compression;
using Build;
using GlobExpressions;
using static Bullseye.Targets;
using static SimpleExec.Command;

const string CLEAN = "clean";
const string BUILD = "build";
const string ZIP = "zip";
const string RESTORE_TOOLS = "restore-tools";
const string BUILD_SERVER_VERSION = "build-server-version";

//need to pass arguments
/*var arguments = new List<string>();
if (args.Length > 1)
{
arguments = args.ToList();
args = new[] { arguments.First() };
//arguments = arguments.Skip(1).ToList();
}*/

Target(
CLEAN,
ForEach("**/output"),
dir =>
{
IEnumerable<string> GetDirectories(string d)
{
return Glob.Directories(".", d);
}

void RemoveDirectory(string d)
{
if (Directory.Exists(d))
{
Console.WriteLine(d);
Directory.Delete(d, true);
}
}

foreach (var d in GetDirectories(dir))
{
RemoveDirectory(d);
}
}
);

Target(
RESTORE_TOOLS,
() =>
{
Run("dotnet", "tool restore");
}
);

Target(
BUILD_SERVER_VERSION,
DependsOn(RESTORE_TOOLS),
() =>
{
Run("dotnet", "tool run dotnet-gitversion /output json /output buildserver");
}
);

Target(
BUILD,
Consts.Solutions,
s =>
{
var version = Environment.GetEnvironmentVariable("GitVersion_FullSemVer") ?? "3.0.0-fakeVersion2";
var fileVersion = Environment.GetEnvironmentVariable("GitVersion_AssemblySemFileVer") ?? "3.0.0.1234";
Console.WriteLine($"Version: {version} & {fileVersion}");
Run("msbuild", $"{s} /p:Configuration=ReleaseAC27 /p:Version={version} /p:FileVersion={fileVersion}");
}
);

Target(
ZIP,
DependsOn(BUILD),
Consts.InstallerManifests,
x =>
{
var outputDir = Path.Combine(".", "output");
var slugDir = Path.Combine(outputDir, x.HostAppSlug);

Directory.CreateDirectory(outputDir);
Directory.CreateDirectory(slugDir);

foreach (var asset in x.Projects)
{
var fullPath = Path.Combine(".", asset.OutputPath);
if (!Directory.Exists(fullPath))
{
throw new InvalidOperationException("Could not find: " + fullPath);
}

var assetName = asset.ConnectorVersion;
var connectorDir = Path.Combine(slugDir, assetName);
Directory.CreateDirectory(connectorDir);
foreach (var directory in Directory.EnumerateDirectories(fullPath, asset.GlobPattern, SearchOption.AllDirectories))
{
Directory.CreateDirectory(directory.Replace(fullPath, connectorDir));
}

foreach (var file in Directory.EnumerateFiles(fullPath, asset.GlobPattern, SearchOption.AllDirectories))
{
Console.WriteLine(file);
var destFileName = file.Replace(fullPath, connectorDir);
File.Copy(file, destFileName, true);
}
}

var outputPath = Path.Combine(outputDir, $"{x.HostAppSlug}.zip");
File.Delete(outputPath);
Console.WriteLine($"Zipping: '{slugDir}' to '{outputPath}'");
ZipFile.CreateFromDirectory(slugDir, outputPath);
// Directory.Delete(slugDir, true);
}
);

Target("default", DependsOn(ZIP), () => Console.WriteLine("Done!"));

await RunTargetsAndExitAsync(args).ConfigureAwait(true);

0 comments on commit 4abf2b5

Please sign in to comment.