]> git.deb.at Git - rhonda/impostor.git/commitdiff
AppVeyor and cake
authorAeonLucid <aeonlucid@gmail.com>
Wed, 14 Oct 2020 14:02:25 +0000 (16:02 +0200)
committerAeonLucid <aeonlucid@gmail.com>
Wed, 14 Oct 2020 14:02:25 +0000 (16:02 +0200)
.config/dotnet-tools.json [new file with mode: 0644]
.github/workflows/deploy.yml [deleted file]
.gitignore
appveyor.yml
build.cake [new file with mode: 0644]

diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json
new file mode 100644 (file)
index 0000000..727dfd7
--- /dev/null
@@ -0,0 +1,12 @@
+{
+  "version": 1,
+  "isRoot": true,
+  "tools": {
+    "cake.tool": {
+      "version": "0.38.5",
+      "commands": [
+        "dotnet-cake"
+      ]
+    }
+  }
+}
\ No newline at end of file
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
deleted file mode 100644 (file)
index d252d4e..0000000
+++ /dev/null
@@ -1,156 +0,0 @@
-name: Deploy
-
-on:
-  push:
-    tags:
-    - 'v*'
-
-jobs:
-  build:
-    name: Build
-    runs-on: windows-latest
-    steps:
-      - name: Checkout
-        uses: actions/checkout@v2
-        with:
-          submodules: true
-      - name: Setup MSBuild.exe
-        uses: microsoft/setup-msbuild@v1.0.1
-      - name: Setup .NET Core
-        uses: actions/setup-dotnet@v1
-        with:
-          dotnet-version: 5.0.100-rc.1.20452.10
-      - name: Install dependencies
-        run: dotnet restore ./src
-      # - name: Build Impostor.Client
-      #   run: msbuild ./src/Impostor.Client/Impostor.Client.csproj /p:Configuration=Release /p:DebugSymbols=false /p:DebugType=None
-      - name: Build Impostor.Server
-        run: dotnet build --no-restore -c Release -f net5.0 ./src/Impostor.Server/Impostor.Server.csproj
-      - name: Test
-        run: dotnet test --no-restore -v normal -f net5.0 ./src
-      # - name: Zip Impostor.Client
-      #   shell: bash
-      #   run: |
-      #     cd ./src/Impostor.Client/bin/Release/net452/win-x64
-      #     7z a -r $GITHUB_WORKSPACE/build/win-x64-client.zip *
-      #     cd $GITHUB_WORKSPACE
-      - 
-        name: Publish Impostor.Server (win-x64)
-        run: dotnet publish -c release -o ./build/win-x64 -f net5.0 -r win-x64 --self-contained --no-restore ./src/Impostor.Server/Impostor.Server.csproj /p:PublishSingleFile=true
-      - name: Zip Impostor.Server (win-x64)
-        shell: bash
-        run: |
-          cd ./build/win-x64
-          7z a -r ../win-x64.zip *
-          cd $GITHUB_WORKSPACE
-      - 
-        name: Publish Impostor.Server (linux-x64)
-        run: dotnet publish -c release -o ./build/linux-x64 -f net5.0 -r linux-x64 --self-contained --no-restore ./src/Impostor.Server/Impostor.Server.csproj /p:PublishSingleFile=true
-      - name: Zip Impostor.Server (linux-x64)
-        shell: bash
-        run: |
-          cd ./build/linux-x64
-          7z a -r ../linux-x64.zip *
-          cd $GITHUB_WORKSPACE
-      - 
-        name: Publish Impostor.Server (linux-arm)
-        run: dotnet publish -c release -o ./build/linux-arm -f net5.0 -r linux-arm --self-contained --no-restore ./src/Impostor.Server/Impostor.Server.csproj /p:PublishSingleFile=true
-      - name: Zip Impostor.Server (linux-arm)
-        shell: bash
-        run: |
-          cd ./build/linux-arm
-          7z a -r ../linux-arm.zip *
-          cd $GITHUB_WORKSPACE
-      - 
-        name: Publish Impostor.Server (linux-arm64)
-        run: dotnet publish -c release -o ./build/linux-arm64 -f net5.0 -r linux-arm64 --self-contained --no-restore ./src/Impostor.Server/Impostor.Server.csproj /p:PublishSingleFile=true
-      - name: Zip Impostor.Server (linux-arm64)
-        shell: bash
-        run: |
-          cd ./build/linux-arm64
-          7z a -r ../linux-arm64.zip *
-          cd $GITHUB_WORKSPACE
-      - 
-        name: Publish Impostor.Server (osx-x64)
-        run: dotnet publish -c release -o ./build/osx-x64 -f net5.0 -r osx-x64 --self-contained --no-restore ./src/Impostor.Server/Impostor.Server.csproj /p:PublishSingleFile=true
-      - name: Zip Impostor.Server (osx-x64)
-        shell: bash
-        run: |
-          cd ./build/osx-x64
-          7z a -r ../osx-x64.zip *
-          cd $GITHUB_WORKSPACE
-      - 
-        name: Create Release
-        id: create_release
-        uses: actions/create-release@v1
-        env:
-          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-        with:
-          tag_name: ${{ github.ref }}
-          release_name: Release ${{ github.ref }}
-          body: |
-            Changes in this Release
-            - First Change
-            - Second Change
-          draft: true
-          prerelease: false
-      # - 
-      #   name: Upload Release Asset (win-x64) Client
-      #   uses: actions/upload-release-asset@v1
-      #   env:
-      #     GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-      #   with:
-      #     upload_url: ${{ steps.create_release.outputs.upload_url }}
-      #     asset_path: ./build/win-x64-client.zip
-      #     asset_name: Impostor-Client-win-x64.zip
-      #     asset_content_type: application/zip
-      - 
-        name: Upload Release Asset (win-x64) Server
-        uses: actions/upload-release-asset@v1
-        env:
-          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-        with:
-          upload_url: ${{ steps.create_release.outputs.upload_url }}
-          asset_path: ./build/win-x64.zip
-          asset_name: Impostor-Server-win-x64.zip
-          asset_content_type: application/zip
-      - 
-        name: Upload Release Asset (linux-x64) Server
-        uses: actions/upload-release-asset@v1
-        env:
-          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-        with:
-          upload_url: ${{ steps.create_release.outputs.upload_url }}
-          asset_path: ./build/linux-x64.zip
-          asset_name: Impostor-Server-linux-x64.zip
-          asset_content_type: application/zip
-      - 
-        name: Upload Release Asset (linux-arm) Server
-        uses: actions/upload-release-asset@v1
-        env:
-          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-        with:
-          upload_url: ${{ steps.create_release.outputs.upload_url }}
-          asset_path: ./build/linux-arm.zip
-          asset_name: Impostor-Server-linux-arm.zip
-          asset_content_type: application/zip
-      - 
-        name: Upload Release Asset (linux-arm64) Server
-        uses: actions/upload-release-asset@v1
-        env:
-          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-        with:
-          upload_url: ${{ steps.create_release.outputs.upload_url }}
-          asset_path: ./build/linux-arm64.zip
-          asset_name: Impostor-Server-linux-arm64.zip
-          asset_content_type: application/zip
-      - 
-        name: Upload Release Asset (osx-x64) Server
-        uses: actions/upload-release-asset@v1
-        env:
-          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-        with:
-          upload_url: ${{ steps.create_release.outputs.upload_url }}
-          asset_path: ./build/osx-x64.zip
-          asset_name: Impostor-Server-osx-x64.zip
-          asset_content_type: application/zip
\ No newline at end of file
index fbb234620980d2addac5bbac6500144c886838ae..e5150c9b83034018fb696206f97e2fa2190572c0 100644 (file)
@@ -1 +1,2 @@
-/.vscode
\ No newline at end of file
+/.vscode
+/build
\ No newline at end of file
index a85d5dec148edc803e0e9ebedd6c8b84e787f2f6..f536b6eb7a5592655cc749766c53c2022ca7b0ab 100644 (file)
@@ -28,34 +28,21 @@ environment:
 
 install:
   - git submodule update --init --recursive
-
-before_build:
-  - dotnet restore "src/Impostor.sln" -v Minimal
+  - ps: .\build\dotnet-install.ps1 -InstallDir 'C:\Program Files\dotnet\'
+  - ps: dotnet tool restore
 
 build_script:
-  # Tests
-  - dotnet build "src/Impostor.Tests/Impostor.Tests.csproj" -c Release
-  # Client
-  - dotnet build "src/Impostor.Client/Impostor.Client.Cli/Impostor.Client.Cli.csproj" --no-restore -c Release -f net5.0
-  - dotnet build "src/Impostor.Client/Impostor.Client.WinForms/Impostor.Client.WinForms.csproj" /p:Configuration=Release /p:DebugSymbols=false /p:DebugType=None
-  # Server win-x64
-  - dotnet publish -c release -o build/win-x64 -f net5.0 -r win-x64 --self-contained --no-restore ./src/Impostor.Server/Impostor.Server.csproj /p:PublishSingleFile=true
-  - ps: 7z a -r build/Impostor-Server-win-x64-$(APPVEYOR_BUILD_VERSION).zip %APPVEYOR_BUILD_FOLDER%/build/win-x64/*
-  # Server linux-x64
-  - dotnet publish -c release -o ./build/linux-x64 -f net5.0 -r linux-x64 --self-contained --no-restore ./src/Impostor.Server/Impostor.Server.csproj /p:PublishSingleFile=true
-  - ps: z a -r build/Impostor-Server-linux-x64-$(APPVEYOR_BUILD_VERSION).zip %APPVEYOR_BUILD_FOLDER%/build/linux-x64/*
-
-test_script:
-  - dotnet test --no-build --no-restore -v normal -f net5.0 -c Release "src/Impostor.Tests"
+  - ps: dotnet cake build.cake --bootstrap
+  - ps: dotnet cake build.cake --pack
+
+test: off
 
 artifacts:
-  - path: build/Impostor-Server-win-x64-$(APPVEYOR_BUILD_VERSION).zip
-    name: Impostor-Server-win-x64-$(APPVEYOR_BUILD_VERSION).zip
-  - path: build/Impostor-Server-linux-x64-$(APPVEYOR_BUILD_VERSION).zip
-    name: Impostor-Server-linux-x64-$(APPVEYOR_BUILD_VERSION).zip
+  - path: ./build/*.zip
 
 only_commits:
   files:
-    - appveyor.yml
-    - src/**/*
+    - ./appveyor.yml
+    - ./build.cake
+    - ./src/**/*
     - .gitmodules
diff --git a/build.cake b/build.cake
new file mode 100644 (file)
index 0000000..8c79c0c
--- /dev/null
@@ -0,0 +1,101 @@
+var buildVersion = EnvironmentVariable("APPVEYOR_BUILD_VERSION") ?? "1.0.0";
+var buildDir = MakeAbsolute(Directory("./build"));
+
+var target = Argument("target", "Deploy");
+var configuration = Argument("configuration", "Release");
+
+//////////////////////////////////////////////////////////////////////
+// UTILS
+//////////////////////////////////////////////////////////////////////
+
+public void ImpostorPublish(string name, string project, string runtime) {
+    var projBuildDir = buildDir.Combine(name + "-" + runtime);
+    var projBuildZip = buildDir.CombineWithFilePath(name + "-" + buildVersion + "-" + runtime + ".zip");
+
+    DotNetCorePublish(project, new DotNetCorePublishSettings {
+        Configuration = configuration,
+        NoRestore = true,
+        Framework = "net5.0",
+        Runtime = runtime,
+        SelfContained = true,
+        PublishSingleFile = true,
+        PublishTrimmed = true,
+        OutputDirectory = projBuildDir
+    });
+
+    Zip(projBuildDir, projBuildZip);
+}
+
+public void ImpostorPublishNF(string name, string project) {
+    var runtime = "win-x64";
+    var projBuildDir = buildDir.Combine(name + "-" + runtime);
+    var projBuildZip = buildDir.CombineWithFilePath(name + "-" + buildVersion + "-" + runtime + ".zip");
+
+    DotNetCorePublish(project, new DotNetCorePublishSettings {
+        Configuration = configuration,
+        NoRestore = true,
+        Framework = "net462",
+        OutputDirectory = projBuildDir
+    });
+
+    Zip(projBuildDir, projBuildZip);
+}
+
+//////////////////////////////////////////////////////////////////////
+// TASKS
+//////////////////////////////////////////////////////////////////////
+
+Task("Clean")
+    .Does(() => {
+        if (DirectoryExists(buildDir)) {
+            DeleteDirectory(buildDir, new DeleteDirectorySettings {
+                Recursive = true
+            });
+        }
+    });
+
+Task("Restore")
+    .Does(() => {
+        DotNetCoreRestore("./src/Impostor.sln");
+    });
+
+Task("Build")
+    .IsDependentOn("Clean")
+    .IsDependentOn("Restore")
+    .Does(() => {
+        // Tests.
+        DotNetCoreBuild("./src/Impostor.Tests/Impostor.Tests.csproj", new DotNetCoreBuildSettings {
+            Configuration = configuration,
+        });
+
+        // Client.
+        ImpostorPublishNF("Impostor-Client", "./src/Impostor.Client/Impostor.Client.WinForms/Impostor.Client.WinForms.csproj");
+        
+        // Server.
+        ImpostorPublish("Impostor-Server", "./src/Impostor.Server/Impostor.Server.csproj", "win-x64");
+        ImpostorPublish("Impostor-Server", "./src/Impostor.Server/Impostor.Server.csproj", "osx-x64");
+        ImpostorPublish("Impostor-Server", "./src/Impostor.Server/Impostor.Server.csproj", "linux-x64");
+        ImpostorPublish("Impostor-Server", "./src/Impostor.Server/Impostor.Server.csproj", "linux-arm");
+        ImpostorPublish("Impostor-Server", "./src/Impostor.Server/Impostor.Server.csproj", "linux-arm64");
+    });
+
+Task("Test")
+    .IsDependentOn("Build")
+    .Does(() => {
+        DotNetCoreTest("./src/Impostor.Tests/Impostor.Tests.csproj", new DotNetCoreTestSettings {
+            Configuration = configuration,
+            NoBuild = true
+        });
+    });
+
+Task("Deploy")
+    .IsDependentOn("Test")
+    .Does(() => {
+        Information("Finished.");
+    });
+
+//////////////////////////////////////////////////////////////////////
+// EXECUTION
+//////////////////////////////////////////////////////////////////////
+
+RunTarget(target);
\ No newline at end of file