forked from Valkirie/HandheldCompanion
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f186563
commit aadd3bf
Showing
1 changed file
with
98 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,112 @@ | ||
name: Build and Publish Handheld Companion | ||
name: Build and Release HandheldCompanion | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
inputs: | ||
createRelease: | ||
description: 'Create a release' | ||
default: false | ||
required: false | ||
type: boolean | ||
tagVersion: | ||
description: 'Version (Required if createRelease = true)' | ||
required: false | ||
type: string | ||
|
||
jobs: | ||
|
||
build: | ||
name: Build (Release) | ||
runs-on: windows-latest | ||
name: Build and Release | ||
runs-on: windows-latest | ||
|
||
env: | ||
Solution_Name: ControllerService.sln | ||
INNO_VERSION: 6.2.1 | ||
INNO_VERSION: 6.2.2 | ||
|
||
steps: | ||
|
||
# Checkout project | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
# Checkout project | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Install Innosetup | ||
shell: pwsh | ||
run: | | ||
choco install innosetup --version=${{ env.INNO_VERSION }} --force | ||
# Setup NuGet and run Restore | ||
- name: NuGet Restore | ||
uses: nuget/setup-nuget@v1 | ||
with: | ||
nuget-version: "5.x" | ||
- run: nuget restore ControllerService.sln | ||
|
||
# Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild | ||
- name: Setup MSBuild | ||
uses: microsoft/[email protected] | ||
|
||
# Build ControllerService solution | ||
- name: Build Solution | ||
run: msbuild $env:Solution_Name /p:Configuration=Release | ||
|
||
# Rebuild ControllerService project | ||
- name: Rebuild ControllerService Project | ||
run: msbuild $env:Solution_Name /t:ControllerService:rebuild /p:Configuration="Release" | ||
|
||
# Sets version based off the latest tag in the repo | ||
- name: Get latest tag | ||
if: ${{ ( inputs.createRelease == false) && ( inputs.tagVersion == '') }} | ||
id: previoustag | ||
uses: "WyriHaximus/github-action-get-previous-tag@v1" | ||
|
||
# Set version number for current release | ||
- name: Set non-release version number | ||
if: ${{ ( inputs.createRelease == false) && ( inputs.tagVersion == '') }} | ||
uses: mingjun97/file-regex-replace@v1 | ||
with: | ||
regex: "#define MyAppVersion '\\d+(?:\\.\\d+)+'" | ||
replacement: "#define MyAppVersion '${{ steps.previoustag.outputs.tag }}'" | ||
include: 'ControllerService\.iss|ControllerService-offline\.iss' | ||
|
||
# Set version number for next release | ||
- name: Set release version number | ||
if: ${{ ( inputs.createRelease == true) && ( inputs.tagVersion != '') }} | ||
uses: mingjun97/file-regex-replace@v1 | ||
with: | ||
regex: "#define MyAppVersion '\\d+(?:\\.\\d+)+'" | ||
replacement: "#define MyAppVersion '${{ inputs.tagVersion }}'" | ||
include: 'ControllerService\.iss|ControllerService-offline\.iss' | ||
|
||
# Install the .NET Core workload | ||
- name: Install .NET Core | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: 6.0.x | ||
|
||
# Setup NuGet and run Restore | ||
- name: Setup NuGet | ||
uses: nuget/setup-nuget@v1 | ||
with: | ||
nuget-version: '5.x' | ||
- run: nuget restore ControllerService.sln | ||
# Create Installers | ||
- name: Create Installer | ||
run: | | ||
iscc.exe ControllerService.iss | ||
shell: pwsh | ||
|
||
# Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild | ||
- name: Setup MSBuild.exe | ||
uses: microsoft/[email protected] | ||
- name: Create Offline Installer | ||
run: | | ||
iscc.exe ControllerService-offline.iss | ||
shell: pwsh | ||
|
||
# Build ControllerService solution | ||
- name: Build Entire Solution | ||
run: msbuild $env:Solution_Name /p:Configuration=Release | ||
|
||
# Rebuild ControllerService project | ||
- name: Rebuild ControllerService Project | ||
run: msbuild $env:Solution_Name /t:ControllerService:rebuild /p:Configuration="Release" | ||
|
||
# Download Inno Setup | ||
- name: Download Inno Setup installer | ||
run: curl -L -o ./installer.exe http://files.jrsoftware.org/is/6/innosetup-${{ env.INNO_VERSION }}.exe | ||
|
||
# Install Inno Setup | ||
- name: Install Inno Setup | ||
run: ./installer.exe /verysilent /allusers /dir=inst | ||
|
||
# Create Installers | ||
- name: Create Installer | ||
run: | | ||
"%programfiles(x86)%\Inno Setup 6\iscc.exe" "ControllerService.iss" | ||
shell: cmd | ||
|
||
- name: Create Offline Installer | ||
run: | | ||
"%programfiles(x86)%\Inno Setup 6\iscc.exe" "ControllerService-offline.iss" | ||
shell: cmd | ||
|
||
# Upload install file artifacts | ||
- name: Upload Installs Artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: install-files | ||
path: ./install | ||
# Generate release notes | ||
- uses: johnyherangi/create-release-notes@main | ||
if: ${{ ( inputs.createRelease == true) && ( inputs.tagVersion != '') }} | ||
id: create-release-notes | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Create Release | ||
if: ${{ ( inputs.createRelease == true) && ( inputs.tagVersion != '') }} | ||
uses: softprops/[email protected] | ||
with: | ||
body: ${{ steps.create-release-notes.outputs.release-notes }} | ||
tag_name: ${{ inputs.tagVersion }} | ||
name: "Build ${{ inputs.tagVersion }}" | ||
draft: false | ||
fail_on_unmatched_files: true | ||
files: | | ||
./install/HandheldCompanion-${{ inputs.tagVersion }}.exe | ||
./install/HandheldCompanion-${{ inputs.tagVersion }}-offline.exe |