-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from specklesystems/alan/ci-start
CI in cpp connectors
- Loading branch information
Showing
11 changed files
with
312 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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-* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,4 +26,7 @@ XCBuildData/ | |
*.log | ||
.idea | ||
*.mui | ||
*.aps | ||
*.aps | ||
**/obj | ||
**/bin | ||
output/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
$ErrorActionPreference = "Stop"; | ||
|
||
dotnet run --project ci-build/build.csproj -- $args |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 -- "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = "*"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |