Update build-and-package-release.yml #3
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
name: Build-and-package-release-workflow | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- 'v*' | |
jobs: | |
Build-and-package-release: | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set execution policy | |
shell: pwsh | |
run: Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process | |
- name: Infer the version from the GitHub ref | |
id: inferVersion | |
working-directory: src | |
run: | | |
$version = .\BuildVersionNumber.ps1 -suffix alpha | |
Write-Host "Inferred version: $version" | |
echo "::set-output name=version::$version" | |
shell: pwsh | |
- name: Install .NET Core | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: '6.0.x' | |
- name: Update version numbers in project | |
working-directory: src | |
run: | | |
$version = '${{ steps.inferVersion.outputs.version }}' | |
Write-Host "Updating project versions to: $version" | |
.\UpdateProjectVersions.ps1 -version $version | |
shell: pwsh | |
- name: Build for release | |
working-directory: src | |
run: .\BuildForRelease.ps1 | |
shell: pwsh | |
- name: Package the release | |
working-directory: src | |
run: | | |
$version = '${{ steps.inferVersion.outputs.version }}' | |
Write-Host "Packaging for the release version: $version" | |
.\PackageRelease.ps1 -version $version | |
shell: pwsh | |
- name: Rename the release assets | |
working-directory: . | |
run: | | |
$version = '${{ steps.inferVersion.outputs.version }}' | |
$releaseDir = Join-Path $(Get-Location) "artefacts\release\$version" | |
Write-Host "Release directory: $releaseDir" | |
if (!(Test-Path $releaseDir)) { | |
throw "The release directory does not exist: $releaseDir" | |
} | |
$archives = Get-ChildItem $releaseDir -Filter *.zip | |
foreach($archive in $archives) { | |
$path = $archive.FullName | |
Write-Host "The path to the archive is: $path" | |
$nameWoExt = [io.path]::GetFileNameWithoutExtension($path) | |
Write-Host "The name without extension is: $nameWoExt" | |
$target = Join-Path $releaseDir ($nameWoExt + "." + $version + ".zip") | |
Write-Host "Moving: $path -> $target" | |
Move-Item -Path $path -Destination $target | |
} | |
shell: pwsh | |
- name: Verify the release assets | |
working-directory: . | |
run: | | |
$version = '${{ steps.inferVersion.outputs.version }}' | |
$releaseDir = Join-Path $(Get-Location) "artefacts\release\$version" | |
Write-Host "Verifying contents of the release directory: $releaseDir" | |
Get-ChildItem $releaseDir | |
# Use this once we can say when to automatically create a release | |
#- name: Create GitHub Release | |
# id: create_release | |
# uses: actions/create-release@v1 | |
# env: | |
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# with: | |
# tag_name: "v${{ steps.inferVersion.outputs.version }}" | |
# release_name: "Release v${{ steps.inferVersion.outputs.version }}" | |
# draft: false | |
# prerelease: false | |
- name: Upload the release assets | |
uses: actions/upload-release-asset@v1 | |
with: | |
asset_path: artefacts/release/${{ steps.inferVersion.outputs.version }}/*.zip | |
asset_name: ${{ steps.inferVersion.outputs.version }}.zip | |
asset_content_type: application/zip |