Skip to content

Commit

Permalink
Add automatic assembly versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
siimav committed Jul 14, 2024
1 parent ef45ee1 commit 0fb1adc
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 30 deletions.
58 changes: 32 additions & 26 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,16 @@ name: build

on:
push:
branches: [ master ]
branches: [ master, CI ]
pull_request:
branches: [ master ]
workflow_dispatch:

jobs:
check-secret:
runs-on: ubuntu-latest
outputs:
has-password: ${{ steps.has-password.outputs.defined }}
steps:
- id: has-password
if: "${{ env.KSP_ZIP_PASSWORD != '' }}"
run: echo "::set-output name=defined::true"
env:
KSP_ZIP_PASSWORD: ${{ secrets.KSP_ZIP_PASSWORD }}
uses: KSP-RO/BuildTools/.github/workflows/check-secret.yml@master
secrets:
KSP_ZIP_PASSWORD: ${{ secrets.KSP_ZIP_PASSWORD }}
validate-cfg-files:
runs-on: ubuntu-latest
steps:
Expand All @@ -28,45 +22,57 @@ jobs:
- name: Validate config files
uses: KSP-CKAN/KSPMMCfgParser@master
build:
runs-on: windows-latest
runs-on: ubuntu-latest
needs: [check-secret]
if: needs.check-secret.outputs.has-password == 'true'
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 100

- name: Download required assemblies
id: download-assemblies
shell: pwsh
env:
uses: KSP-RO/BuildTools/download-assemblies@master
with:
KSP_ZIP_PASSWORD: ${{ secrets.KSP_ZIP_PASSWORD }}
run: |
Invoke-WebRequest https://ksp-ro.s3-us-west-2.amazonaws.com/KSPAssemblies-1.12.zip -OutFile KSP_Assemblies.zip
$KSP_DLL_PATH="${env:GITHUB_WORKSPACE}/KSP_Assemblies"
echo "::set-output name=ksp-dll-path::${KSP_DLL_PATH}"
mkdir -p "${KSP_DLL_PATH}"
7z.exe x "-p${env:KSP_ZIP_PASSWORD}" 'KSP_Assemblies.zip' "-o${KSP_DLL_PATH}"
rm 'KSP_Assemblies.zip'

# Install .NET SDKs
- name: Setup .NET Core 3.1
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.x
- name: Setup .NET 5.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x

- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2
- name: Update AssemblyInfo
uses: KSP-RO/BuildTools/update-assembly-info@master
with:
path: ${GITHUB_WORKSPACE}/src/RealAntennasProject/Properties/AssemblyInfo.cs
tag: "2.99.0.0"

- name: Build mod solution
run: |
msbuild /p:Configuration=Release /p:ReferencePath="${{ steps.download-assemblies.outputs.ksp-dll-path }}" ${env:GITHUB_WORKSPACE}/src/RealAntennasProject.sln
msbuild ${GITHUB_WORKSPACE}/src/RealAntennasProject.sln /t:build /restore /p:RestorePackagesConfig=true /p:Configuration=Release /p:ReferencePath="${{ steps.download-assemblies.outputs.ksp-dll-path }}"
- name: Remove excess DLLs
uses: KSP-RO/BuildTools/remove-excess-dlls@master
with:
path: ${GITHUB_WORKSPACE}/GameData/

- name: Assemble release
id: assemble-release
run: |
$RELEASE_DIR="${env:RUNNER_TEMP}/release"
$RELEASE_DIR="${RUNNER_TEMP}/release"
echo "Release dir: ${RELEASE_DIR}"
mkdir "${RELEASE_DIR}"
echo "::set-output name=release-dir::${RELEASE_DIR}"
cp "${env:GITHUB_WORKSPACE}/GameData/RealAntennas" "${RELEASE_DIR}" -Recurse
cp "${GITHUB_WORKSPACE}/GameData/RealAntennas" "${RELEASE_DIR}" -Recurse
- name: Upload artifacts
uses: actions/upload-artifact@v1
with:
name: RealAntennas
path: ${{ steps.assemble-release.outputs.release-dir }}
path: ${{ steps.assemble-release.outputs.release-dir }}
13 changes: 9 additions & 4 deletions src/RealAntennasProject/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Reflection;
using System.Runtime.CompilerServices;
#define CIBUILD_disabled
using System.Reflection;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
Expand Down Expand Up @@ -33,7 +33,12 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.4.0.0")]
[assembly: AssemblyFileVersion("2.4.0.0")]
[assembly: KSPAssembly("RealAntennas", 2, 4)]
#if CIBUILD
[assembly: AssemblyFileVersion("@MAJOR@.@MINOR@.@PATCH@.@BUILD@")]
[assembly: KSPAssembly("RealAntennas", @MAJOR@, @MINOR@)]
#else
[assembly: AssemblyFileVersion("2.99.0.0")]
[assembly: KSPAssembly("RealAntennas", 2, 99)]
#endif

[assembly: KSPAssemblyDependency("ClickThroughBlocker", 1, 8)]

0 comments on commit 0fb1adc

Please sign in to comment.