Build and release #62
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
# This is a basic workflow to help you get started with Actions | |
name: Build and release | |
# Controls when the workflow will run | |
# Allows you to run this workflow manually from the Actions tab | |
on: [workflow_dispatch] | |
jobs: | |
build-console: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
target: [win-x64, win-arm64, osx-x64, osx-arm64, linux-x64, linux-arm, linux-arm64] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set version and tag | |
shell: pwsh | |
run: | | |
"BUILD_VERSION=1.2.{0}" -f (git rev-list --count $env:GITHUB_REF) >> $env:GITHUB_ENV | |
"BUILD_VERSION_SHA={0}" -f (git log --pretty=format:'%h' -n 1 $env:GITHUB_REF) >> $env:GITHUB_ENV | |
- name: Write version and tag | |
shell: pwsh | |
run: | | |
"BUILD_VERSION: ${{ env.BUILD_VERSION }}" | |
"BUILD_VERSION_SHA: ${{ env.BUILD_VERSION_SHA }}" | |
"${{ env.BUILD_VERSION }}" > hst-imager.release-tag.txt | |
"hst-imager_v${{ env.BUILD_VERSION }}-${{ env.BUILD_VERSION_SHA }}" > hst-imager.release-version.txt | |
- name: Upload release tag artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: hst-imager.release-tag | |
path: hst-imager.release-tag.txt | |
retention-days: 3 | |
if: matrix.target == 'win-x64' | |
- name: Upload release version artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: hst-imager.release-version | |
path: hst-imager.release-version.txt | |
retention-days: 3 | |
if: matrix.target == 'win-x64' | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: | | |
8.0.x | |
- name: Restore tool | |
working-directory: ./src | |
shell: pwsh | |
run: dotnet tool restore | |
- name: Update version | |
shell: pwsh | |
working-directory: ./src | |
run: | | |
[System.IO.File]::WriteAllText('Directory.Build.props', ([System.IO.File]::ReadAllText('Directory.Build.props') -replace '0.1.0', '${{ env.BUILD_VERSION }}')) | |
- name: Build console app | |
working-directory: src/Hst.Imager.ConsoleApp | |
shell: pwsh | |
run: | | |
dotnet publish --configuration Release -p:PublishSingleFile=True -p:SelfContained=True -p:RuntimeIdentifier=${{ matrix.target }} -p:PublishReadyToRun=True -p:IncludeNativeLibrariesForSelfExtract=true -p:PublishDir=publish/${{ matrix.target }} | |
- name: List console app output | |
working-directory: src/Hst.Imager.ConsoleApp/publish | |
shell: pwsh | |
run: | | |
Get-ChildItem -recurse | |
- name: Build console app artifact | |
id: build_console_app_artifact | |
working-directory: ./src | |
shell: pwsh | |
run: | | |
cd "Hst.Imager.ConsoleApp/publish/${{ matrix.target }}" | |
$artifactName='hst-imager.console.${{ matrix.target }}.zip' | |
Remove-Item -Path *.pdb | |
Remove-Item -Path *.so | |
$exeFileName=((Get-ChildItem -Filter 'Hst.Imager.ConsoleApp*') | Select -First 1).Name | |
Rename-Item -Path $exeFileName -NewName ($exeFileName -replace 'Hst.Imager.ConsoleApp', 'hst.imager') | |
zip -r $artifactName * | |
$artifactPath=((Get-ChildItem -Filter $artifactName) | Select -First 1).FullName | |
"::set-output name=artifact_name::$artifactName" | |
"::set-output name=artifact_path::$artifactPath" | |
- name: Upload console app artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: "${{ steps.build_console_app_artifact.outputs.artifact_name }}" | |
path: "${{ steps.build_console_app_artifact.outputs.artifact_path }}" | |
retention-days: 3 | |
build-gui: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [windows-latest, macos-latest, ubuntu-latest] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set version and tag | |
shell: pwsh | |
run: | | |
"BUILD_VERSION=1.2.{0}" -f (git rev-list --count $env:GITHUB_REF) >> $env:GITHUB_ENV | |
"BUILD_VERSION_SHA={0}" -f (git log --pretty=format:'%h' -n 1 $env:GITHUB_REF) >> $env:GITHUB_ENV | |
"${{ env.BUILD_VERSION }}" > hst-imager.release-tag.txt | |
"hst-imager_v${{ env.BUILD_VERSION }}-${{ env.BUILD_VERSION_SHA }}" > hst-imager.release-version.txt | |
- name: Show version | |
shell: pwsh | |
run: | | |
"BUILD_VERSION: ${{ env.BUILD_VERSION }}" | |
"BUILD_VERSION_SHA: ${{ env.BUILD_VERSION_SHA }}" | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: | | |
6.0.x | |
8.0.x | |
- name: Restore tool | |
working-directory: ./src | |
shell: pwsh | |
run: dotnet tool restore | |
- name: Update version | |
shell: pwsh | |
working-directory: ./src | |
run: | | |
[System.IO.File]::WriteAllText('Directory.Build.props', ([System.IO.File]::ReadAllText('Directory.Build.props') -replace '0.1.0', '${{ env.BUILD_VERSION }}')) | |
[System.IO.File]::WriteAllText('Hst.Imager.GuiApp/electron.manifest.json', ([System.IO.File]::ReadAllText('Hst.Imager.GuiApp/electron.manifest.json') -replace '0.1.0', '${{ env.BUILD_VERSION }}')) | |
[System.IO.File]::WriteAllText('Hst.Imager.GuiApp/ClientApp/package.json', ([System.IO.File]::ReadAllText('Hst.Imager.GuiApp/ClientApp/package.json') -replace '0.1.0', '${{ env.BUILD_VERSION }}')) | |
[System.IO.File]::WriteAllText('Hst.Imager.GuiApp/ClientApp/public/index.html', ([System.IO.File]::ReadAllText('Hst.Imager.GuiApp/ClientApp/public/index.html') -replace '0.1.0', '${{ env.BUILD_VERSION }}-${{ env.BUILD_VERSION_SHA }}')) | |
[System.IO.File]::WriteAllText('Hst.Imager.GuiApp/ClientApp/src/Constants.js', ([System.IO.File]::ReadAllText('Hst.Imager.GuiApp/ClientApp/src/Constants.js') -replace '0.1.0', '${{ env.BUILD_VERSION }}-${{ env.BUILD_VERSION_SHA }}')) | |
- name: Build gui app for Windows | |
working-directory: ./src | |
shell: pwsh | |
run: | | |
cd Hst.Imager.GuiApp | |
dotnet electronize build /target win /p:DefineConstants=ELECTRON | |
if: matrix.os == 'windows-latest' | |
- name: Build gui app for macOS | |
working-directory: ./src | |
shell: pwsh | |
run: | | |
cd Hst.Imager.GuiApp | |
dotnet electronize build /target osx /p:DefineConstants=ELECTRON | |
if: matrix.os == 'macos-latest' | |
- name: Build gui app for Linux | |
working-directory: ./src | |
shell: pwsh | |
run: | | |
cd Hst.Imager.GuiApp | |
dotnet electronize build /target linux /p:DefineConstants=ELECTRON | |
if: matrix.os == 'ubuntu-latest' | |
- name: List gui app output | |
shell: pwsh | |
run: | | |
Get-ChildItem './src/Hst.Imager.GuiApp/bin/Desktop' -recurse -name | |
- name: Set Windows 64-bit setup artifact | |
id: windows_x64_setup | |
shell: pwsh | |
run: | | |
$artifactName='hst-imager.gui.win-x64-setup.exe' | |
$artifactFile=(gci './src/Hst.Imager.GuiApp/bin/Desktop' -Recurse -Filter 'Hst Imager Setup ${{ env.BUILD_VERSION }}.exe' | Select-Object -First 1).FullName | |
Rename-Item $artifactFile -NewName $artifactName | |
$artifactPath=(Join-Path (Split-Path $artifactFile -Parent) -ChildPath $artifactName) | |
"::set-output name=artifact_name::$artifactName" | |
"::set-output name=artifact_path::$artifactPath" | |
if: matrix.os == 'windows-latest' | |
- name: Upload Windows 64-bit setup artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: "${{ steps.windows_x64_setup.outputs.artifact_name }}" | |
path: "${{ steps.windows_x64_setup.outputs.artifact_path }}" | |
retention-days: 3 | |
if: matrix.os == 'windows-latest' | |
- name: Set Windows 64-bit portable artifact | |
id: windows_x64_portable | |
shell: pwsh | |
run: | | |
$artifactName='hst-imager.gui.win-x64-portable.exe' | |
$artifactFile=(gci './src/Hst.Imager.GuiApp/bin/Desktop' -Recurse -Filter 'Hst Imager ${{ env.BUILD_VERSION }}.exe' | Select-Object -First 1).FullName | |
Rename-Item $artifactFile -NewName $artifactName | |
$artifactPath=(Join-Path (Split-Path $artifactFile -Parent) -ChildPath $artifactName) | |
"::set-output name=artifact_name::$artifactName" | |
"::set-output name=artifact_path::$artifactPath" | |
if: matrix.os == 'windows-latest' | |
- name: Upload Windows 64-bit portable artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: "${{ steps.windows_x64_portable.outputs.artifact_name }}" | |
path: "${{ steps.windows_x64_portable.outputs.artifact_path }}" | |
retention-days: 3 | |
if: matrix.os == 'windows-latest' | |
- name: Set Windows 64-bit zip artifact | |
id: windows_x64_zip | |
shell: pwsh | |
run: | | |
$artifactName='hst-imager.gui.win-x64.zip' | |
$artifactFile=(gci './src/Hst.Imager.GuiApp/bin/Desktop' -Recurse -Filter 'Hst Imager-${{ env.BUILD_VERSION }}-win.zip' | Select-Object -First 1).FullName | |
Rename-Item $artifactFile -NewName $artifactName | |
$artifactPath=(Join-Path (Split-Path $artifactFile -Parent) -ChildPath $artifactName) | |
"::set-output name=artifact_name::$artifactName" | |
"::set-output name=artifact_path::$artifactPath" | |
if: matrix.os == 'windows-latest' | |
- name: Upload Windows 64-bit zip artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: "${{ steps.windows_x64_zip.outputs.artifact_name }}" | |
path: "${{ steps.windows_x64_zip.outputs.artifact_path }}" | |
retention-days: 3 | |
if: matrix.os == 'windows-latest' | |
# - name: Set macOS 64-bit dmg artifact | |
# id: macos_x64_dmg | |
# shell: pwsh | |
# run: | | |
# $artifactName='hst-imager.gui.osx-x64.dmg' | |
# $artifactFile=(gci './src/Hst.Imager.GuiApp/bin/Desktop' -Recurse -Filter '*${{ env.BUILD_VERSION }}.dmg' | Select-Object -First 1).FullName | |
# Rename-Item $artifactFile -NewName $artifactName | |
# $artifactPath=(Join-Path (Split-Path $artifactFile -Parent) -ChildPath $artifactName) | |
# "::set-output name=artifact_name::$artifactName" | |
# "::set-output name=artifact_path::$artifactPath" | |
# if: matrix.os == 'macos-latest' | |
# - name: Upload macOS 64-bit dmg artifact | |
# uses: actions/upload-artifact@v4 | |
# with: | |
# name: "${{ steps.macos_x64_dmg.outputs.artifact_name }}" | |
# path: "${{ steps.macos_x64_dmg.outputs.artifact_path }}" | |
# retention-days: 3 | |
# if: matrix.os == 'macos-latest' | |
- name: Set Linux 64-bit appimage artifact | |
id: linux_x64_appimage | |
shell: pwsh | |
run: | | |
$artifactName='hst-imager.gui.linux-x64.AppImage' | |
$artifactFile=(gci './src/Hst.Imager.GuiApp/bin/Desktop' -Recurse -Filter '*${{ env.BUILD_VERSION }}.AppImage' | Select-Object -First 1).FullName | |
Rename-Item $artifactFile -NewName $artifactName | |
$artifactPath=(Join-Path (Split-Path $artifactFile -Parent) -ChildPath $artifactName) | |
"::set-output name=artifact_name::$artifactName" | |
"::set-output name=artifact_path::$artifactPath" | |
if: matrix.os == 'ubuntu-latest' | |
- name: Upload Linux 64-bit appimage artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: "${{ steps.linux_x64_appimage.outputs.artifact_name }}" | |
path: "${{ steps.linux_x64_appimage.outputs.artifact_path }}" | |
retention-days: 3 | |
if: matrix.os == 'ubuntu-latest' | |
- name: Set Linux arm64 appimage artifact | |
id: linux_arm64_appimage | |
shell: pwsh | |
run: | | |
$artifactName='hst-imager.gui.linux-arm64.AppImage' | |
$artifactFile=(gci './src/Hst.Imager.GuiApp/bin/Desktop' -Recurse -Filter '*${{ env.BUILD_VERSION }}-arm64.AppImage' | Select-Object -First 1).FullName | |
Rename-Item $artifactFile -NewName $artifactName | |
$artifactPath=(Join-Path (Split-Path $artifactFile -Parent) -ChildPath $artifactName) | |
"::set-output name=artifact_name::$artifactName" | |
"::set-output name=artifact_path::$artifactPath" | |
if: matrix.os == 'ubuntu-latest' | |
- name: Upload Linux arm64 appimage artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: "${{ steps.linux_arm64_appimage.outputs.artifact_name }}" | |
path: "${{ steps.linux_arm64_appimage.outputs.artifact_path }}" | |
retention-days: 3 | |
if: matrix.os == 'ubuntu-latest' | |
# - name: Set Linux arm64 deb artifact | |
# id: linux_x64_deb | |
# shell: pwsh | |
# run: | | |
# $artifactName='hst-imager.gui.linux-arm64.deb' | |
# $artifactFile=(gci './src/Hst.Imager.GuiApp/bin/Desktop' -Recurse -Filter '*${{ env.BUILD_VERSION }}_arm64.deb' | Select-Object -First 1).FullName | |
# Rename-Item $artifactFile -NewName $artifactName | |
# $artifactPath=(Join-Path (Split-Path $artifactFile -Parent) -ChildPath $artifactName) | |
# "::set-output name=artifact_name::$artifactName" | |
# "::set-output name=artifact_path::$artifactPath" | |
# if: matrix.os == 'ubuntu-latest' | |
# - name: Upload Linux 64-bit deb artifact | |
# uses: actions/upload-artifact@v4 | |
# with: | |
# name: "${{ steps.linux_x64_deb.outputs.artifact_name }}" | |
# path: "${{ steps.linux_x64_deb.outputs.artifact_path }}" | |
# retention-days: 3 | |
# if: matrix.os == 'ubuntu-latest' | |
publish: | |
needs: [build-console, build-gui] | |
runs-on: windows-latest | |
steps: | |
- name: Download release tag artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: hst-imager.release-tag | |
- name: Download release version artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: hst-imager.release-version | |
- name: Set release tag version | |
shell: pwsh | |
run: | | |
"RELEASE_TAG={0}" -f (gc hst-imager.release-tag.txt) >> $env:GITHUB_ENV | |
"RELEASE_VERSION={0}" -f (gc hst-imager.release-version.txt) >> $env:GITHUB_ENV | |
# windows | |
- name: Download Console Windows 64-bit zip artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: hst-imager.console.win-x64.zip | |
- name: Download Console Windows arm64-bit zip artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: hst-imager.console.win-arm64.zip | |
- name: Download Gui Windows 64-bit setup artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: hst-imager.gui.win-x64-setup.exe | |
- name: Download Gui Windows 64-bit portable artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: hst-imager.gui.win-x64-portable.exe | |
- name: Download Gui Windows 64-bit zip artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: hst-imager.gui.win-x64.zip | |
# macos | |
- name: Download Console macOS 64-bit zip artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: hst-imager.console.osx-x64.zip | |
- name: Download Console macOS arm64-bit zip artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: hst-imager.console.osx-arm64.zip | |
# - name: Download Gui macOS 64-bit dmg artifact | |
# uses: actions/download-artifact@v4 | |
# with: | |
# name: hst-imager.gui.osx-x64.dmg | |
# linux | |
- name: Download Console Linux 64-bit zip artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: hst-imager.console.linux-x64.zip | |
- name: Download Console Linux arm-bit zip artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: hst-imager.console.linux-arm.zip | |
- name: Download Console Linux arm64-bit zip artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: hst-imager.console.linux-arm64.zip | |
- name: Download Gui Linux 64-bit appimage artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: hst-imager.gui.linux-x64.AppImage | |
- name: Download Gui Linux arm64-bit appimage artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: hst-imager.gui.linux-arm64.AppImage | |
# - name: Download Gui Linux arm64-bit deb artifact | |
# uses: actions/download-artifact@v4 | |
# with: | |
# name: hst-imager.gui.linux-arm64.deb | |
- name: Version artifacts | |
shell: pwsh | |
run: | | |
Rename-Item -Path hst-imager.console.win-x64.zip -NewName "${{ env.RELEASE_VERSION }}_console_windows_x64.zip" | |
Rename-Item -Path hst-imager.console.win-arm64.zip -NewName "${{ env.RELEASE_VERSION }}_console_windows_arm64.zip" | |
Rename-Item -Path hst-imager.gui.win-x64-setup.exe -NewName "${{ env.RELEASE_VERSION }}_gui_windows_x64_setup.exe" | |
Rename-Item -Path hst-imager.gui.win-x64-portable.exe -NewName "${{ env.RELEASE_VERSION }}_gui_windows_x64_portable.exe" | |
Rename-Item -Path hst-imager.gui.win-x64.zip -NewName "${{ env.RELEASE_VERSION }}_gui_windows_x64.zip" | |
Rename-Item -Path hst-imager.console.osx-x64.zip -NewName "${{ env.RELEASE_VERSION }}_console_macos_x64.zip" | |
Rename-Item -Path hst-imager.console.osx-arm64.zip -NewName "${{ env.RELEASE_VERSION }}_console_macos_arm64.zip" | |
Rename-Item -Path hst-imager.gui.osx-x64.dmg -NewName "${{ env.RELEASE_VERSION }}_gui_macos_x64.dmg" | |
Rename-Item -Path hst-imager.console.linux-x64.zip -NewName "${{ env.RELEASE_VERSION }}_console_linux_x64.zip" | |
Rename-Item -Path hst-imager.console.linux-arm.zip -NewName "${{ env.RELEASE_VERSION }}_console_linux_arm.zip" | |
Rename-Item -Path hst-imager.console.linux-arm64.zip -NewName "${{ env.RELEASE_VERSION }}_console_linux_arm64.zip" | |
Rename-Item -Path hst-imager.gui.linux-x64.AppImage -NewName "${{ env.RELEASE_VERSION }}_gui_linux_x64.AppImage" | |
Rename-Item -Path hst-imager.gui.linux-arm64.AppImage -NewName "${{ env.RELEASE_VERSION }}_gui_linux_arm64.AppImage" | |
- name: Create release | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: | | |
${{ env.RELEASE_VERSION }}_console_windows_x64.zip | |
${{ env.RELEASE_VERSION }}_console_windows_arm64.zip | |
${{ env.RELEASE_VERSION }}_gui_windows_x64_setup.exe | |
${{ env.RELEASE_VERSION }}_gui_windows_x64_portable.exe | |
${{ env.RELEASE_VERSION }}_gui_windows_x64.zip | |
${{ env.RELEASE_VERSION }}_console_macos_x64.zip | |
${{ env.RELEASE_VERSION }}_console_macos_arm64.zip | |
${{ env.RELEASE_VERSION }}_gui_macos_x64.dmg | |
${{ env.RELEASE_VERSION }}_console_linux_x64.zip | |
${{ env.RELEASE_VERSION }}_console_linux_arm.zip | |
${{ env.RELEASE_VERSION }}_console_linux_arm64.zip | |
${{ env.RELEASE_VERSION }}_gui_linux_x64.AppImage | |
${{ env.RELEASE_VERSION }}_gui_linux_arm64.AppImage | |
tag_name: ${{ env.RELEASE_TAG }} | |
name: ${{ env.RELEASE_VERSION }} | |
body: Prerelease of ${{ env.RELEASE_VERSION }} | |
draft: true | |
prerelease: true |