From b274f9448603dd7eb4416d1f975e99330dfaaa24 Mon Sep 17 00:00:00 2001
From: CptMoore <39010654+CptMoore@users.noreply.github.com>
Date: Mon, 29 Mar 2021 22:33:40 +0200
Subject: [PATCH] Added git workflow build. Updated GitVersionTask. Added
script to build release zip. Added user file template.
---
.github/workflows/ci-release-build.yml | 78 ++++++++++++++++++++
.gitignore | 1 +
release.sh | 24 ++++++
source/CustomComponents.csproj | 2 +-
source/CustomComponents.csproj.user.template | 7 ++
5 files changed, 111 insertions(+), 1 deletion(-)
create mode 100644 .github/workflows/ci-release-build.yml
create mode 100644 release.sh
create mode 100644 source/CustomComponents.csproj.user.template
diff --git a/.github/workflows/ci-release-build.yml b/.github/workflows/ci-release-build.yml
new file mode 100644
index 0000000..c93a8e0
--- /dev/null
+++ b/.github/workflows/ci-release-build.yml
@@ -0,0 +1,78 @@
+on: push
+name: Release Build
+jobs:
+ build:
+ runs-on: windows-latest
+ #runs-on: ubuntu-latest # missing .NET 4.6 Framework
+ steps:
+ - name: Download Build Dependencies
+ shell: bash
+ env:
+ MANAGED_ARCHIVE_PW: ${{ secrets.MANAGED_ARCHIVE_PW }}
+ MANAGED_ARCHIVE_URL: ${{ secrets.MANAGED_ARCHIVE_URL }}
+ run: |
+ set -e
+ curl -L -o "$GITHUB_WORKSPACE/Managed.7z" "$MANAGED_ARCHIVE_URL"
+ 7z e -p"$MANAGED_ARCHIVE_PW" -o"$GITHUB_WORKSPACE/deps" "$GITHUB_WORKSPACE/Managed.7z"
+ - name: Checkout CustomComponents
+ uses: actions/checkout@master
+ with:
+ repository: BattletechModders/CustomComponents
+ ref: Experimental
+ path: CustomComponents/
+ - name: Fetch CustomComponents Branches and Tags
+ shell: bash
+ run: |
+ cd CustomComponents/
+ git fetch --prune --unshallow
+ - name: Setup dotnet
+ uses: actions/setup-dotnet@master
+ with:
+ dotnet-version: '5.0.x'
+ - name: Build Release
+ shell: bash
+ env:
+ MSBUILDSINGLELOADCONTEXT: 1 # workaround for GitVersionTask
+ run: |
+ set -e
+ cd "$GITHUB_WORKSPACE/CustomComponents/"
+ ./release.sh "-p:ReferencePath=$GITHUB_WORKSPACE/deps"
+ - name: Upload Build
+ uses: actions/upload-artifact@master
+ with:
+ name: dist
+ path: "./CustomComponents/dist/CustomComponents.zip"
+
+ release:
+ needs: build
+ runs-on: ubuntu-latest
+ if: contains(github.ref, 'refs/tags')
+ steps:
+ - name: Download Build
+ uses: actions/download-artifact@master
+ with:
+ name: dist
+ path: .
+ - name: Create Release
+ id: create_release
+ uses: actions/create-release@master
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ with:
+ tag_name: ${{ github.ref }}
+ release_name: ${{ github.ref }}
+ draft: false
+ prerelease: false
+ body: |
+ Works with ModLoader and ModTek
+ - CustomComponents.zip contains the compiled framework
+ - name: Upload Release Asset
+ id: upload-release-asset
+ uses: actions/upload-release-asset@master
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ with:
+ upload_url: ${{ steps.create_release.outputs.upload_url }}
+ asset_path: CustomComponents.zip
+ asset_name: CustomComponents.zip
+ asset_content_type: application/zip
diff --git a/.gitignore b/.gitignore
index 4768d5e..74e59be 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,6 +4,7 @@
# DynModLib specific ignores
log.txt
/*.dll
+/dist
# User-specific files
*.suo
diff --git a/release.sh b/release.sh
new file mode 100644
index 0000000..505697b
--- /dev/null
+++ b/release.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+export PATH="/c/Program Files/7-Zip/:$PATH"
+
+SEVENZIP="7z"
+
+set -ex
+
+CCZIP="CustomComponents/dist/CustomComponents.zip"
+rm -f "$CCZIP"
+
+cd ..
+
+(
+cd CustomComponents/source
+#git describe --exact-match
+dotnet build --configuration Release --no-incremental -p:OutputPath=../ "$@"
+)
+
+(
+INCLUDES="-i!CustomComponents/CustomComponents.dll -i!CustomComponents/LICENSE -i!CustomComponents/mod.json -i!CustomComponents/mod.minimal.json -i!CustomComponents/README.md"
+
+"$SEVENZIP" a -tzip -mx9 "$CCZIP" $INCLUDES
+)
diff --git a/source/CustomComponents.csproj b/source/CustomComponents.csproj
index f00d6bc..87aaf2a 100644
--- a/source/CustomComponents.csproj
+++ b/source/CustomComponents.csproj
@@ -216,7 +216,7 @@
- 5.2.4
+ 5.5.1
all
diff --git a/source/CustomComponents.csproj.user.template b/source/CustomComponents.csproj.user.template
new file mode 100644
index 0000000..1efec78
--- /dev/null
+++ b/source/CustomComponents.csproj.user.template
@@ -0,0 +1,7 @@
+
+
+
+ C:\Program Files\Steam\steamapps\common\BATTLETECH\BattleTech_Data\Managed
+ ..\
+
+
\ No newline at end of file