mirror of
https://github.com/drewcassidy/KSP-DepthMask
synced 2024-09-01 14:54:35 +00:00
Rework build system to be automated
This commit is contained in:
parent
be4315fabe
commit
ee58bda08a
119
.github/workflows/ksp-publish.yml
vendored
Normal file
119
.github/workflows/ksp-publish.yml
vendored
Normal file
@ -0,0 +1,119 @@
|
||||
name: Build and Release
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
types:
|
||||
- opened
|
||||
- edited
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: '3.x'
|
||||
|
||||
- name: Setup .NET Core SDK
|
||||
uses: actions/setup-dotnet@v1.7.2
|
||||
with:
|
||||
dotnet-version: '6.0.x'
|
||||
|
||||
- name: Install Python Tools
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install -r Tools/requirements.txt
|
||||
|
||||
- name: Download Dependencies
|
||||
run: |
|
||||
mkdir -p DepthMask/dlls
|
||||
mkdir -p GameData
|
||||
wget --user drewcassidy --password ${{ secrets.PILE_OF_ROCKS_PASS }} https://pileof.rocks/Secret/KSP-1.12.3-dlls.zip
|
||||
unzip KSP-*-dlls.zip -d DepthMask/
|
||||
|
||||
- name: Generate Version Info
|
||||
run: |
|
||||
python Tools/version.py
|
||||
|
||||
- name: Validate Version Info
|
||||
uses: DasSkelett/AVC-VersionFileValidator@master
|
||||
with:
|
||||
only: '["./GameData/DepthMask/DepthMask.version"]'
|
||||
|
||||
- name: Build DLL
|
||||
run: |
|
||||
dotnet build --configuration Release DepthMask.sln
|
||||
|
||||
- name: Upload Build
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: DepthMask
|
||||
path: |
|
||||
GameData/DepthMask
|
||||
README.md
|
||||
CHANGELOG.md
|
||||
LICENSE.md
|
||||
|
||||
|
||||
deploy:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: '3.x'
|
||||
|
||||
- name: Install Python Tools
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install yaclog
|
||||
|
||||
- name: Setup SSH keys
|
||||
uses: kielabokkie/ssh-key-and-known-hosts-action@v1
|
||||
with:
|
||||
ssh-private-key: ${{ secrets.PILE_OF_ROCKS_PRIVATE_KEY }}
|
||||
ssh-host: pileof.rocks
|
||||
|
||||
- name: Get version name and body
|
||||
run: |
|
||||
echo "VERSION_TITLE=$(yaclog show -n)" >> $GITHUB_ENV
|
||||
echo "$(yaclog show -mb)" >> RELEASE.md
|
||||
|
||||
- name: Download Build Artifacts
|
||||
uses: actions/download-artifact@v3
|
||||
|
||||
- name: Zip Download Packages
|
||||
run: |
|
||||
mkdir deploy
|
||||
|
||||
zip -r deploy/DepthMask-$GITHUB_REF.zip DepthMask/*
|
||||
cp DepthMask/GameData/DepthMask/DepthMask.version deploy/
|
||||
|
||||
ls deploy
|
||||
|
||||
- name: Publish to Github
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
files: |
|
||||
deploy/Shabby-*.zip
|
||||
deploy/DepthMask.version
|
||||
name: DepthMask Version ${{ env.GITHUB_REF }}
|
||||
body_path: RELEASE.md
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Publish to Server
|
||||
run: |
|
||||
rsync -t deploy/* drewcassidy@pileof.rocks:/var/www/pileof.rocks/html/KSP/
|
||||
|
@ -5,7 +5,7 @@
|
||||
<IsPackable>false</IsPackable>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<NoWarn>1701;1702;CS0649;CS1591</NoWarn>
|
||||
<AssemblyVersion>1.1.2</AssemblyVersion>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@ -36,7 +36,8 @@
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="cp -v '$(TargetPath)' '$(SolutionDir)/Releases/DepthMask/Gamedata'"/>
|
||||
<MakeDir Directories="$(SolutionDir)/GameData/DepthMask"/>
|
||||
<Copy SourceFiles="$(OutDir)DepthMask.dll" DestinationFolder="$(SolutionDir)/GameData/DepthMask"/>
|
||||
</Target>
|
||||
|
||||
</Project>
|
||||
|
14
Templates/DepthMask/Properties/AssemblyInfo.cs
Normal file
14
Templates/DepthMask/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System.Reflection;
|
||||
|
||||
// KSP assembly information
|
||||
|
||||
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
|
||||
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
|
||||
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
|
||||
[assembly: AssemblyVersionAttribute("{{ ver_major }}.{{ ver_minor }}.{{ ver_patch }}")]
|
||||
[assembly: AssemblyInformationalVersionAttribute("{{ ver_major }}.{{ ver_minor }}.{{ ver_patch }}")]
|
||||
[assembly: KSPAssembly("DepthMask", {{ ver_major }}, {{ ver_minor }}, {{ ver_patch }})]
|
||||
|
||||
// Information about this assembly is defined by the following attributes.
|
||||
// Change them to the values specific to your project.
|
||||
[assembly: AssemblyCopyright("2022 Andrew Cassidy")]
|
20
Templates/GameData/DepthMask/DepthMask.version
Normal file
20
Templates/GameData/DepthMask/DepthMask.version
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"NAME":"DepthMask",
|
||||
"URL":"https://github.com/drewcassidy/KSP-DepthMask/releases/latest/download/DepthMask.version",
|
||||
"DOWNLOAD":"https://github.com/drewcassidy/KSP-DepthMask/releases/latest",
|
||||
"CHANGE_LOG_URL":"https://github.com/drewcassidy/KSP-DepthMask/blob/master/CHANGELOG.md"
|
||||
"VERSION": {
|
||||
"MAJOR": {{ ver_major }},
|
||||
"MINOR": {{ ver_minor }},
|
||||
"PATCH": {{ ver_patch }},
|
||||
"BUILD": {{ ver_build }}
|
||||
},
|
||||
"KSP_VERSION_MIN": {
|
||||
"MAJOR":1,
|
||||
"MINOR":11
|
||||
},
|
||||
"KSP_VERSION_MAX": {
|
||||
"MAJOR":1,
|
||||
"MINOR":12
|
||||
}
|
||||
}
|
3
Tools/requirements.txt
Normal file
3
Tools/requirements.txt
Normal file
@ -0,0 +1,3 @@
|
||||
GitPython ~= 3.1.27
|
||||
yaclog ~= 1.0.4
|
||||
jinja2 ~= 3.1.0
|
55
Tools/version.py
Normal file
55
Tools/version.py
Normal file
@ -0,0 +1,55 @@
|
||||
# This file generates versioned files for deploying DepthMask
|
||||
|
||||
import yaclog
|
||||
import yaclog.version
|
||||
import git as gp
|
||||
import os
|
||||
from pathlib import Path
|
||||
from jinja2 import Environment, FileSystemLoader, select_autoescape
|
||||
|
||||
|
||||
def run():
|
||||
basedir = Path(__file__).parent.parent
|
||||
|
||||
g = gp.Git(basedir)
|
||||
|
||||
release = True
|
||||
tag, distance, sha = g.execute(["git", "describe"]).split("-")
|
||||
|
||||
if int(distance) > 0:
|
||||
release = False
|
||||
tag = yaclog.version.increment_version(tag, 2)
|
||||
|
||||
segments = tag.split('.')
|
||||
ver_major, ver_minor, ver_patch = segments[0:3]
|
||||
if len(segments) >= 4:
|
||||
ver_build = segments[3]
|
||||
elif release:
|
||||
ver_build = int(distance)
|
||||
else:
|
||||
ver_build = int("0x" + sha[1:5], 16)
|
||||
|
||||
print(f'Configuring version {ver_major}.{ver_minor}.{ver_patch} build {ver_build}')
|
||||
|
||||
env = Environment(
|
||||
loader=FileSystemLoader(basedir / "Templates"),
|
||||
autoescape=select_autoescape()
|
||||
)
|
||||
|
||||
for template_name in ["GameData/DepthMask/DepthMask.version", "DepthMask/Properties/AssemblyInfo.cs"]:
|
||||
print("Generating " + template_name)
|
||||
template = env.get_template(template_name)
|
||||
with open(basedir / template_name, "w") as fh:
|
||||
fh.write(template.render(
|
||||
ver_major=ver_major,
|
||||
ver_minor=ver_minor,
|
||||
ver_patch=ver_patch,
|
||||
ver_build=ver_build,
|
||||
tag=tag
|
||||
))
|
||||
|
||||
print('Done!')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
run()
|
Loading…
Reference in New Issue
Block a user