Add script for updating version

hotfix
Andrew Cassidy 2 years ago
parent 5443377bfe
commit 322aaa613e

@ -24,19 +24,25 @@ jobs:
python -m pip install --upgrade pip
python -m pip install yaclog yaclog-ksp
- name: Download Dependencies
- name: Download DLL Dependencies
working-directory: Source
run: |
wget --user drewcassidy --password ${{ secrets.PILE_OF_ROCKS_PASS }} https://pileof.rocks/Secret/conformal-decals-dependencies-1.zip
unzip conformal-decals-dependencies-*.zip -d ConformalDecals/dlls
dotnet build --configuration Release ConformalDecals.sln
- name: Generate version info
run: python Scripts/version.py
- name: Build DLL
working-directory: Source
run: |
mkdir -p ../GameData/ConformalDecals/Plugins
dotnet build --configuration Release ConformalDecals.sln
- name: Validate files
uses: DasSkelett/AVC-VersionFileValidator@master
- name: Upload Unbundled Build
uses: actions/upload-artifact@v3
with:

@ -1,28 +1,26 @@
{
"NAME":"ConformalDecals",
"URL":"https://raw.githubusercontent.com/drewcassidy/KSP-Conformal-Decals/release/GameData/ConformalDecals/Versioning/ConformalDecals.version",
"DOWNLOAD":"https://github.com/drewcassidy/KSP-Conformal-Decals/releases",
"VERSION":
{
"MAJOR":0,
"MINOR":2,
"PATCH":8,
"BUILD":0
"NAME": "ConformalDecals",
"URL": "https://raw.githubusercontent.com/drewcassidy/KSP-Conformal-Decals/release/GameData/ConformalDecals/Versioning/ConformalDecals.version",
"DOWNLOAD": "https://github.com/drewcassidy/KSP-Conformal-Decals/releases",
"VERSION": {
"MAJOR": 9,
"MINOR": 9,
"PATCH": 9,
"BUILD": 100000
},
"KSP_VERSION":
{
"MAJOR":1,
"MINOR":11,
"PATCH":0
"KSP_VERSION": {
"MAJOR": 1,
"MINOR": 11,
"PATCH": 0
},
"KSP_VERSION_MIN":{
"MAJOR":1,
"MINOR":8,
"PATCH":0
"KSP_VERSION_MIN": {
"MAJOR": 1,
"MINOR": 8,
"PATCH": 0
},
"KSP_VERSION_MAX":{
"MAJOR":1,
"MINOR":11,
"PATCH":99
"KSP_VERSION_MAX": {
"MAJOR": 1,
"MINOR": 12,
"PATCH": 99
}
}
}

@ -0,0 +1,58 @@
import yaclog
import yaclog.version
import git as gp
import os
import xml.dom.minidom as minidom
import json
def run():
repo = gp.Repo(os.curdir)
cl = yaclog.Changelog('CHANGELOG.md')
version = str(cl.current_version(released=True).version)
release = False
for tag in repo.tags:
if tag.commit == repo.head.commit:
release = True
build = 100000
version = str(yaclog.version.extract_version(tag.name)[0])
break
if not release:
build = int.from_bytes(repo.head.commit.binsha[0:2], byteorder='big')
version = yaclog.version.increment_version(version, 2)
print(f'Setting up version {version} build {build}')
version_path = 'GameData/ConformalDecals/Versioning/ConformalDecals.version'
with open(version_path, 'r+') as version_file:
segments = version.split('.')
# print(version_file.read())
decoded = json.load(version_file)
decoded['VERSION']['MAJOR'] = int(segments[0])
decoded['VERSION']['MINOR'] = int(segments[1])
decoded['VERSION']['PATCH'] = int(segments[2])
decoded['VERSION']['BUILD'] = build
version_file.seek(0)
json.dump(decoded, version_file, indent=4)
version_file.truncate()
project_path = 'Source/ConformalDecals/ConformalDecals.csproj'
with open(project_path, 'r+') as project_file:
segments = version.split('.')
decoded = minidom.parse(project_file)
version_node = decoded.getElementsByTagName('AssemblyVersion')[0]
if release:
version_node.firstChild.nodeValue = f'{version}'
else:
version_node.firstChild.nodeValue = f'{version}.{build}'
# version_node.value = f'{version}.{build}'
project_file.seek(0)
decoded.writexml(project_file)
project_file.truncate()
if __name__ == '__main__':
run()

@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<?xml version="1.0" ?><Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<LangVersion>8</LangVersion>
<IsPackable>false</IsPackable>
<PlatformTarget>x64</PlatformTarget>
<NoWarn>1701;1702;CS0649;CS1591</NoWarn>
<AssemblyVersion>0.2.8</AssemblyVersion>
<AssemblyVersion>9.9.9</AssemblyVersion>
</PropertyGroup>
<ItemGroup>
@ -36,21 +36,20 @@
</ItemGroup>
<ItemGroup>
<Compile Remove="dlls\**" />
<Compile Remove="dlls\**"/>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Remove="dlls\**" />
<EmbeddedResource Remove="dlls\**"/>
</ItemGroup>
<ItemGroup>
<None Remove="dlls\**" />
<None Remove="dlls\**"/>
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="/bin/cp -v '$(OutDir)ConformalDecals.dll' '$(SolutionDir)../GameData/ConformalDecals/Plugins/ConformalDecals.dll'" IgnoreExitCode="true" />
<Exec Command="/bin/cp -v '$(OutDir)ConformalDecals.dll' '$(SolutionDir)../GameData/ConformalDecals/Plugins/ConformalDecals.dll'" IgnoreExitCode="true"/>
<!--Fuck you MSBuild stop trying to run CMD.exe on macOS-->
</Target>
</Project>
</Project>
Loading…
Cancel
Save