mirror of
https://github.com/drewcassidy/KSP-Conformal-Decals.git
synced 2024-09-01 18:23:54 +00:00
Add script for updating version
This commit is contained in:
parent
5443377bfe
commit
322aaa613e
8
.github/workflows/ksp-publish.yml
vendored
8
.github/workflows/ksp-publish.yml
vendored
@ -24,19 +24,25 @@ jobs:
|
|||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
python -m pip install yaclog yaclog-ksp
|
python -m pip install yaclog yaclog-ksp
|
||||||
|
|
||||||
- name: Download Dependencies
|
- name: Download DLL Dependencies
|
||||||
working-directory: Source
|
working-directory: Source
|
||||||
run: |
|
run: |
|
||||||
wget --user drewcassidy --password ${{ secrets.PILE_OF_ROCKS_PASS }} https://pileof.rocks/Secret/conformal-decals-dependencies-1.zip
|
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
|
unzip conformal-decals-dependencies-*.zip -d ConformalDecals/dlls
|
||||||
dotnet build --configuration Release ConformalDecals.sln
|
dotnet build --configuration Release ConformalDecals.sln
|
||||||
|
|
||||||
|
- name: Generate version info
|
||||||
|
run: python Scripts/version.py
|
||||||
|
|
||||||
- name: Build DLL
|
- name: Build DLL
|
||||||
working-directory: Source
|
working-directory: Source
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ../GameData/ConformalDecals/Plugins
|
mkdir -p ../GameData/ConformalDecals/Plugins
|
||||||
dotnet build --configuration Release ConformalDecals.sln
|
dotnet build --configuration Release ConformalDecals.sln
|
||||||
|
|
||||||
|
- name: Validate files
|
||||||
|
uses: DasSkelett/AVC-VersionFileValidator@master
|
||||||
|
|
||||||
- name: Upload Unbundled Build
|
- name: Upload Unbundled Build
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
|
@ -2,15 +2,13 @@
|
|||||||
"NAME": "ConformalDecals",
|
"NAME": "ConformalDecals",
|
||||||
"URL": "https://raw.githubusercontent.com/drewcassidy/KSP-Conformal-Decals/release/GameData/ConformalDecals/Versioning/ConformalDecals.version",
|
"URL": "https://raw.githubusercontent.com/drewcassidy/KSP-Conformal-Decals/release/GameData/ConformalDecals/Versioning/ConformalDecals.version",
|
||||||
"DOWNLOAD": "https://github.com/drewcassidy/KSP-Conformal-Decals/releases",
|
"DOWNLOAD": "https://github.com/drewcassidy/KSP-Conformal-Decals/releases",
|
||||||
"VERSION":
|
"VERSION": {
|
||||||
{
|
"MAJOR": 9,
|
||||||
"MAJOR":0,
|
"MINOR": 9,
|
||||||
"MINOR":2,
|
"PATCH": 9,
|
||||||
"PATCH":8,
|
"BUILD": 100000
|
||||||
"BUILD":0
|
|
||||||
},
|
},
|
||||||
"KSP_VERSION":
|
"KSP_VERSION": {
|
||||||
{
|
|
||||||
"MAJOR": 1,
|
"MAJOR": 1,
|
||||||
"MINOR": 11,
|
"MINOR": 11,
|
||||||
"PATCH": 0
|
"PATCH": 0
|
||||||
@ -22,7 +20,7 @@
|
|||||||
},
|
},
|
||||||
"KSP_VERSION_MAX": {
|
"KSP_VERSION_MAX": {
|
||||||
"MAJOR": 1,
|
"MAJOR": 1,
|
||||||
"MINOR":11,
|
"MINOR": 12,
|
||||||
"PATCH": 99
|
"PATCH": 99
|
||||||
}
|
}
|
||||||
}
|
}
|
58
Scripts/version.py
Normal file
58
Scripts/version.py
Normal file
@ -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>
|
<PropertyGroup>
|
||||||
<TargetFramework>net48</TargetFramework>
|
<TargetFramework>net48</TargetFramework>
|
||||||
<LangVersion>8</LangVersion>
|
<LangVersion>8</LangVersion>
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
<PlatformTarget>x64</PlatformTarget>
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
<NoWarn>1701;1702;CS0649;CS1591</NoWarn>
|
<NoWarn>1701;1702;CS0649;CS1591</NoWarn>
|
||||||
<AssemblyVersion>0.2.8</AssemblyVersion>
|
<AssemblyVersion>9.9.9</AssemblyVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -53,4 +53,3 @@
|
|||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user