-
Notifications
You must be signed in to change notification settings - Fork 19
95 lines (77 loc) · 2.98 KB
/
build-and-package-release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
name: Build-and-package-release-workflow
on:
push:
tags:
- 'v*'
jobs:
Build-and-package-release:
runs-on: windows-latest
steps:
- uses: actions/checkout@master
- name: Infer the version from the github ref
id: inferVersion
run: |
$prefix = "refs/tags/v"
if (!${env:GITHUB_REF}.StartsWith($prefix))
{
throw "Unexpected GITHUB_REF: ${env:GITHUB_REF}"
}
$version = ${env:GITHUB_REF}.Substring($prefix.Length)
Write-Host "The version is: $version"
if ($version.Contains("'"))
{
throw "Unexpected version containing a single quote: $version"
}
if ($version.Contains('"'))
{
throw "Unexpected version containing a double quote: $version"
}
if ($version.Contains(':'))
{
throw "Unexpected version containing a full colon: $version"
}
Write-Output "::set-output name=version::$version"
- name: Install .NET core 6.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
- name: Install the build dependencies
working-directory: src
run: powershell .\InstallBuildDependencies.ps1
- name: Build for the release
working-directory: src
run: powershell .\BuildForRelease.ps1
- name: Package the release
working-directory: src
run: |
$version = '${{ steps.inferVersion.outputs.version }}'
Write-Host "Packaging for the release version: $version"
powershell .\PackageRelease.ps1 -version $version
- name: Rename the release assets
working-directory: ./
run: |
Write-Host "Current working directory: $(Get-Location)"
$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
}
- name: Upload the release assets
uses: AButler/upload-release-assets@v2.0
with:
files: "artefacts/release/${{ steps.inferVersion.outputs.version }}/*.zip"
repo-token: ${{ secrets.GITHUB_TOKEN }}
release-tag: "v${{ steps.inferVersion.outputs.version }}"