From 81f0870d3676b9d65634b9eef37dc298391e7247 Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Mon, 2 Dec 2024 12:23:48 +0100 Subject: [PATCH 1/9] Create build.yml Initial CI for archicad, no deployment yet --- .github/workflows/build.yml | 56 +++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..22d5da5 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,56 @@ + +# 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: Build Archicad + +on: + push: + branches: ["main", "dev", "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 + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Add MSBuild to PATH + uses: microsoft/setup-msbuild@v2 + - name: Run CMAKE + run: cmake -G "Visual Studio 17 2022" -T v142 -A "x64" -DAC_ADDON_LANGUAGE="INT" -DAC_API_DEVKIT_DIR="Libs\acapi27" -B build -DCMAKE_BUILD_TYPE=Release + - name: Build solution + run: msbuild build/archicad-speckle.sln /p:Configuration=Release /p:Version=3.0.0-beta /p:FileVersion=3.0.0 + + 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/workflow-dispatch@v3.0.0 + 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-* From a9a8ac55d38bb241f66a890a0a058912626b2c4f Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Mon, 2 Dec 2024 13:19:55 +0100 Subject: [PATCH 2/9] ci: Working config with bullseye build --- .config/dotnet-tools.json | 11 ++++ .github/workflows/build.yml | 28 ++++++--- .gitignore | 5 ++ GitVersion.yml | 6 ++ build.ps1 | 3 + build.sh | 4 ++ ci-build/Build.csproj | 16 +++++ ci-build/Consts.cs | 19 ++++++ ci-build/Program.cs | 121 ++++++++++++++++++++++++++++++++++++ 9 files changed, 206 insertions(+), 7 deletions(-) create mode 100644 .config/dotnet-tools.json create mode 100644 GitVersion.yml create mode 100644 build.ps1 create mode 100644 build.sh create mode 100644 ci-build/Build.csproj create mode 100644 ci-build/Consts.cs create mode 100644 ci-build/Program.cs diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json new file mode 100644 index 0000000..d3c43c2 --- /dev/null +++ b/.config/dotnet-tools.json @@ -0,0 +1,11 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "gitversion.tool": { + "version": "6.0.2", + "commands": ["dotnet-gitversion"], + "rollForward": false + } + } +} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 22d5da5..e843d92 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,14 +21,28 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - - - name: Add MSBuild to PATH - uses: microsoft/setup-msbuild@v2 - - name: Run CMAKE - run: cmake -G "Visual Studio 17 2022" -T v142 -A "x64" -DAC_ADDON_LANGUAGE="INT" -DAC_API_DEVKIT_DIR="Libs\acapi27" -B build -DCMAKE_BUILD_TYPE=Release - - name: Build solution - run: msbuild build/archicad-speckle.sln /p:Configuration=Release /p:Version=3.0.0-beta /p:FileVersion=3.0.0 + - 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: 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 diff --git a/.gitignore b/.gitignore index 697477e..f079e71 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,8 @@ *.bak *.log **/*_svg_source/ + +**/obj +**/bin +**/Thumbs.db +**/output \ No newline at end of file diff --git a/GitVersion.yml b/GitVersion.yml new file mode 100644 index 0000000..e688060 --- /dev/null +++ b/GitVersion.yml @@ -0,0 +1,6 @@ +workflow: GitFlow/v1 +next-version: 3.0.0 +branches: + release: + prevent-increment: + when-current-commit-tagged: true diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 0000000..e63b7aa --- /dev/null +++ b/build.ps1 @@ -0,0 +1,3 @@ +$ErrorActionPreference = "Stop"; + +dotnet run --project ci-build/build.csproj -- $args \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..f75ab37 --- /dev/null +++ b/build.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +set -euo pipefail + +dotnet run --project Build/Build.csproj -- "$@" diff --git a/ci-build/Build.csproj b/ci-build/Build.csproj new file mode 100644 index 0000000..49cf624 --- /dev/null +++ b/ci-build/Build.csproj @@ -0,0 +1,16 @@ + + + + Exe + net8.0 + enable + Debug;Release;Local + true + + + + + + + + diff --git a/ci-build/Consts.cs b/ci-build/Consts.cs new file mode 100644 index 0000000..33cf729 --- /dev/null +++ b/ci-build/Consts.cs @@ -0,0 +1,19 @@ +namespace Build; + +public static class Consts +{ + public static readonly string[] SupportedVersions = new string[] { "27", "28"}; + public static readonly string[] Solutions = ["build_27/speckle-archicad.sln", "build_28/speckle-archicad.sln"]; + + public static readonly InstallerProject[] InstallerManifests = + { + new("archicad", [new("archicad27", "build/27/INT/Release", "*.apx"), new("archicad28", "build/28/INT/Release", "*.apx")]) + }; +} + +public readonly record struct InstallerProject(string HostAppSlug, IReadOnlyList Projects) +{ + public override string ToString() => $"{HostAppSlug}"; +} + +public readonly record struct InstallerAsset(string ConnectorVersion, string OutputPath, string GlobPattern = "*"); diff --git a/ci-build/Program.cs b/ci-build/Program.cs new file mode 100644 index 0000000..e02e645 --- /dev/null +++ b/ci-build/Program.cs @@ -0,0 +1,121 @@ +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"; +const string RUN_CMAKE = "build-cmake"; + +Target( + CLEAN, + ForEach("**/output"), + dir => + { + IEnumerable 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(RUN_CMAKE, Consts.SupportedVersions, s => +{ + Run("cmake", $"-G \"Visual Studio 17 2022\" -T v142 -A \"x64\" -DAC_ADDON_LANGUAGE=\"INT\" -DAC_API_DEVKIT_DIR=\"Libs\\acapi{s}\" -B build\\{s} -DCMAKE_BUILD_TYPE=Release"); +}); + +Target( + BUILD, + DependsOn(RUN_CMAKE), + Consts.SupportedVersions, + s => + { + var version = Environment.GetEnvironmentVariable("GitVersion_FullSemVer") ?? "3.0.0-localBuild"; + var fileVersion = Environment.GetEnvironmentVariable("GitVersion_AssemblySemFileVer") ?? "3.0.0.9999"; + Console.WriteLine($"Version: {version} & {fileVersion}"); + Run("msbuild", $"build/{s}/archicad-speckle.sln /p:Configuration=Release /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); From da3f6d57b4d0b42ece3201d90b7d2c02aa5ef37a Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Mon, 2 Dec 2024 13:22:17 +0100 Subject: [PATCH 3/9] fix: No working dir needed --- .github/workflows/build.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e843d92..3401e4f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,3 @@ - # 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 @@ -23,11 +22,9 @@ jobs: fetch-depth: 0 - 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 From 4d803eb43c303ed7787b6047ad99bb0214234852 Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Mon, 2 Dec 2024 13:30:00 +0100 Subject: [PATCH 4/9] fix: Use specific relative path --- ci-build/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci-build/Program.cs b/ci-build/Program.cs index e02e645..98df13c 100644 --- a/ci-build/Program.cs +++ b/ci-build/Program.cs @@ -68,7 +68,7 @@ void RemoveDirectory(string d) var version = Environment.GetEnvironmentVariable("GitVersion_FullSemVer") ?? "3.0.0-localBuild"; var fileVersion = Environment.GetEnvironmentVariable("GitVersion_AssemblySemFileVer") ?? "3.0.0.9999"; Console.WriteLine($"Version: {version} & {fileVersion}"); - Run("msbuild", $"build/{s}/archicad-speckle.sln /p:Configuration=Release /p:Version={version} /p:FileVersion={fileVersion}"); + Run("msbuild", $"./build/{s}/archicad-speckle.sln /p:Configuration=Release /p:Version={version} /p:FileVersion={fileVersion}"); } ); From 849ddf6d4fbfc06d60566a7432c2ba8b6a237b4f Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Mon, 2 Dec 2024 13:43:59 +0100 Subject: [PATCH 5/9] test: LS on the build folder --- .github/workflows/build.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3401e4f..6564796 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,8 +25,12 @@ jobs: run: ./build.ps1 build-server-version - name: Build - run: ./build.ps1 - + run: ./build.ps1 build-cmake + + - name: LS + run: ls + working-directory: build/27/ + - uses: actions/upload-artifact@v4 with: name: output-${{ env.GitVersion_FullSemVer }} From e7f78486d96d455daad55ea7daa4d800ee161bc5 Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Mon, 2 Dec 2024 13:55:21 +0100 Subject: [PATCH 6/9] test: 2 Step build with working dir set on run --- .github/workflows/build.yml | 5 ++++- ci-build/Program.cs | 3 +-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6564796..447a8c6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,7 +30,10 @@ jobs: - name: LS run: ls working-directory: build/27/ - + + - name: Build sln and zip + run: ./build.ps1 zip + - uses: actions/upload-artifact@v4 with: name: output-${{ env.GitVersion_FullSemVer }} diff --git a/ci-build/Program.cs b/ci-build/Program.cs index 98df13c..b29c8f8 100644 --- a/ci-build/Program.cs +++ b/ci-build/Program.cs @@ -61,14 +61,13 @@ void RemoveDirectory(string d) Target( BUILD, - DependsOn(RUN_CMAKE), Consts.SupportedVersions, s => { var version = Environment.GetEnvironmentVariable("GitVersion_FullSemVer") ?? "3.0.0-localBuild"; var fileVersion = Environment.GetEnvironmentVariable("GitVersion_AssemblySemFileVer") ?? "3.0.0.9999"; Console.WriteLine($"Version: {version} & {fileVersion}"); - Run("msbuild", $"./build/{s}/archicad-speckle.sln /p:Configuration=Release /p:Version={version} /p:FileVersion={fileVersion}"); + Run("msbuild", $"archicad-speckle.sln /p:Configuration=Release /p:Version={version} /p:FileVersion={fileVersion}", $"./build/{s}/"); } ); From 43b573648a8bc2cd9929c9a9ed9fef7f4a29fcd2 Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Mon, 2 Dec 2024 14:00:41 +0100 Subject: [PATCH 7/9] test: Run raw command --- .github/workflows/build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 447a8c6..507f0c8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,14 +26,14 @@ jobs: - name: Build run: ./build.ps1 build-cmake - + - name: LS run: ls working-directory: build/27/ - - name: Build sln and zip - run: ./build.ps1 zip - + - name: Build sln + run: msbuild build/27/archicad-speckle.sln /p:Configuration=Release + - uses: actions/upload-artifact@v4 with: name: output-${{ env.GitVersion_FullSemVer }} From 8bfec02a0048a06b5cbcf6b7955b3012744b5898 Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Mon, 2 Dec 2024 14:31:22 +0100 Subject: [PATCH 8/9] =?UTF-8?q?fix:=20=F0=9F=A4=A6=F0=9F=8F=BC=E2=80=8D?= =?UTF-8?q?=E2=99=82=EF=B8=8F=20missing=20setup=20msbuild?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 12 ++++-------- ci-build/Program.cs | 3 ++- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 507f0c8..14a5c7b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,18 +21,14 @@ jobs: with: fetch-depth: 0 + - name: Add MSBuild to PATH + uses: microsoft/setup-msbuild@v2 + - name: ⚒️ Run GitVersion run: ./build.ps1 build-server-version - name: Build - run: ./build.ps1 build-cmake - - - name: LS - run: ls - working-directory: build/27/ - - - name: Build sln - run: msbuild build/27/archicad-speckle.sln /p:Configuration=Release + run: ./build.ps1 - uses: actions/upload-artifact@v4 with: diff --git a/ci-build/Program.cs b/ci-build/Program.cs index b29c8f8..98df13c 100644 --- a/ci-build/Program.cs +++ b/ci-build/Program.cs @@ -61,13 +61,14 @@ void RemoveDirectory(string d) Target( BUILD, + DependsOn(RUN_CMAKE), Consts.SupportedVersions, s => { var version = Environment.GetEnvironmentVariable("GitVersion_FullSemVer") ?? "3.0.0-localBuild"; var fileVersion = Environment.GetEnvironmentVariable("GitVersion_AssemblySemFileVer") ?? "3.0.0.9999"; Console.WriteLine($"Version: {version} & {fileVersion}"); - Run("msbuild", $"archicad-speckle.sln /p:Configuration=Release /p:Version={version} /p:FileVersion={fileVersion}", $"./build/{s}/"); + Run("msbuild", $"./build/{s}/archicad-speckle.sln /p:Configuration=Release /p:Version={version} /p:FileVersion={fileVersion}"); } ); From b65dd0bb6364239691a274e1e45f3f0f4f573a74 Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Mon, 2 Dec 2024 14:45:01 +0100 Subject: [PATCH 9/9] fix: use outputs and build installer from ref --- .github/workflows/build.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 14a5c7b..0185959 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,6 +16,10 @@ permissions: 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: @@ -58,7 +62,7 @@ jobs: 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 + ref: alan/update-archicad-installer wait-for-completion: true wait-for-completion-interval: 10s wait-for-completion-timeout: 10m