Skip to content

Commit

Permalink
Added git workflow build. Updated GitVersionTask. Added script to bui…
Browse files Browse the repository at this point in the history
…ld release zip. Added user file template.
  • Loading branch information
CptMoore committed Mar 29, 2021
1 parent 79a1c9b commit b274f94
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 1 deletion.
78 changes: 78 additions & 0 deletions .github/workflows/ci-release-build.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# DynModLib specific ignores
log.txt
/*.dll
/dist

# User-specific files
*.suo
Expand Down
24 changes: 24 additions & 0 deletions release.sh
Original file line number Diff line number Diff line change
@@ -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
)
2 changes: 1 addition & 1 deletion source/CustomComponents.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="GitVersionTask">
<Version>5.2.4</Version>
<Version>5.5.1</Version>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
Expand Down
7 changes: 7 additions & 0 deletions source/CustomComponents.csproj.user.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ReferencePath>C:\Program Files\Steam\steamapps\common\BATTLETECH\BattleTech_Data\Managed</ReferencePath>
<OutputPath>..\</OutputPath>
</PropertyGroup>
</Project>

0 comments on commit b274f94

Please sign in to comment.