diff --git a/.github/workflows/ksp-publish.yml b/.github/workflows/ksp-publish.yml index 0a5afd4..118a6e5 100644 --- a/.github/workflows/ksp-publish.yml +++ b/.github/workflows/ksp-publish.yml @@ -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: diff --git a/GameData/ConformalDecals/Versioning/ConformalDecals.version b/GameData/ConformalDecals/Versioning/ConformalDecals.version index e1f34ae..f9b6f63 100644 --- a/GameData/ConformalDecals/Versioning/ConformalDecals.version +++ b/GameData/ConformalDecals/Versioning/ConformalDecals.version @@ -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 } -} +} \ No newline at end of file diff --git a/Scripts/version.py b/Scripts/version.py new file mode 100644 index 0000000..dbb0b7d --- /dev/null +++ b/Scripts/version.py @@ -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() diff --git a/Source/ConformalDecals/ConformalDecals.csproj b/Source/ConformalDecals/ConformalDecals.csproj index 595055a..7c54b8f 100644 --- a/Source/ConformalDecals/ConformalDecals.csproj +++ b/Source/ConformalDecals/ConformalDecals.csproj @@ -1,11 +1,11 @@ - + net48 8 false x64 1701;1702;CS0649;CS1591 - 0.2.8 + 9.9.9 @@ -36,21 +36,20 @@ - + - + - + - + - - + \ No newline at end of file