Skip to content

Commit

Permalink
automate version stamping in GHA
Browse files Browse the repository at this point in the history
- define version in GHA based on tag name and SHA
- inject version into assemblyInfo.cs
- inject version into installer
  • Loading branch information
megahirt committed Jun 18, 2024
1 parent 2f0b2d4 commit 889af46
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
32 changes: 28 additions & 4 deletions .github/workflows/installer-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ jobs:
runs-on: windows-2019

steps:
- name: Set VERSION (e.g. 1.0.0) and FULL_VERSION (e.g. 1.0.0-abcdef4)
run: |
VERSION="${GITHUB_REF#refs/tags/v}"
SHORT_SHA=$(git rev-parse --short HEAD)
FULL_VERSION="${VERSION}-${SHORT_SHA}"
echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "FULL_VERSION=${FULL_VERSION}" >> $GITHUB_ENV
shell: bash

- name: Checkout
uses: actions/checkout@v4
with:
Expand All @@ -28,7 +37,22 @@ jobs:
- name: Restore
run: dotnet restore src/solid.sln

- name: Build
- name: Update AssemblyInfo.cs
run: |
$filePath = "C:\src\solid\src\SolidGui\Properties\AssemblyInfo.cs"
(Get-Content $filePath) -replace 'AssemblyVersion\(".*\)', "AssemblyVersion\(\"${{ env.VERSION }}.0\"\)" |
Set-Content $filePath
(Get-Content $filePath) -replace 'AssemblyFileVersion\(".*\)', "AssemblyFileVersion\(\"${{ env.VERSION }}.0\"\)" |
Set-Content $filePath
(Get-Content $filePath) -replace 'AssemblyInformationalVersion\(".*\)', "AssemblyInformationalVersion\(\"${{ env.FULL_VERSION }}\"\)" |
Set-Content $filePath
shell: powershell

- name: Verify Update
run: Get-Content "C:\src\solid\src\SolidGui\Properties\AssemblyInfo.cs"
shell: powershell

- name: Build version ${{ env.VERSION }}
run: dotnet build -c Release src/solid.sln --no-restore

- name: List files and subdirectories
Expand All @@ -38,12 +62,12 @@ jobs:
shell: powershell

- name: Build Installer
run: iscc installer/setup.iss
run: iscc /DMyAppVersion=${{ env.VERSION }} installer/setup.iss

- uses: actions/upload-artifact@v4
with:
name: SolidInstaller.exe
path: installer\Output\SolidInstaller.exe
path: installer\Output\SolidInstaller*.exe
if-no-files-found: error

sign-installer:
Expand All @@ -68,7 +92,7 @@ jobs:
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: SolidInstaller.exe
files: SolidInstaller*.exe
body: |
Release for version ${{ github.ref }}
draft: true
6 changes: 5 additions & 1 deletion installer/setup.iss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
EnableISX=true

#define MyAppName "Solid"

#ifndef MyAppVersion
#define MyAppVersion "1.0.0"
#endif

#define MyAppPublisher "SIL International"
#define MyAppURL "http://software.sil.org/solid"
#define MyAppExeName "Solid.exe"
Expand All @@ -25,7 +29,7 @@ DisableReadyPage=yes
DefaultGroupName={#MyAppName}
DisableProgramGroupPage=yes
LicenseFile=license.rtf
OutputBaseFilename=SolidInstaller
OutputBaseFilename=SolidInstaller-{AppVersion}
Compression=lzma
SolidCompression=yes
;WizardImageFile=compiler:WIZMODERNIMAGE-IS.BMP
Expand Down

0 comments on commit 889af46

Please sign in to comment.