Skip to content

Commit 465f056

Browse files
authored
Support preview releases (#698)
* Changed set-output * Support beta releases (#26)
1 parent 7d60855 commit 465f056

File tree

5 files changed

+82
-28
lines changed

5 files changed

+82
-28
lines changed

.github/workflows/build-test.yml

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,34 @@ jobs:
4646
- name: Show version
4747
run: echo "Building version ${{ inputs.release-version }}"
4848

49+
- name: Get number version
50+
env:
51+
ReleaseVersion: ${{ inputs.release-version }}
52+
run: |
53+
$numberVersion = .\GetNumberVersion -Version ${{env.ReleaseVersion}}
54+
echo "Setting numberVersion to $numberVersion"
55+
echo "NUMBER_VERSION=$numberVersion" >> $env:GITHUB_ENV
56+
4957
- name: Set fileversion on all .NET Framework assemblies and assembly version on the exe
5058
env:
51-
Version: ${{ inputs.release-version }}
59+
ReleaseVersion: ${{ inputs.release-version }}
5260
run: |
5361
$sbeFileName = "$env:GITHUB_WORKSPACE\src\ServiceBusExplorer\Properties\AssemblyInfo.cs"
54-
.\SetVersion -FileName $sbeFileName -PropertyName 'AssemblyVersion' -Version ${{env.Version}}
55-
.\SetVersion -FileName $sbeFileName -PropertyName 'AssemblyFileVersion' -Version ${{env.Version}}
56-
.\SetVersion -FileName "$env:GITHUB_WORKSPACE\src\Common\Properties\AssemblyInfo.cs" -PropertyName 'AssemblyFileVersion' -Version ${{env.Version}}
57-
.\SetVersion -FileName "$env:GITHUB_WORKSPACE\src\NotificationHubs\Properties\AssemblyInfo.cs" -PropertyName 'AssemblyFileVersion' -Version ${{env.Version}}
62+
.\SetVersion -FileName $sbeFileName -PropertyName 'AssemblyVersion' -Version ${{env.NUMBER_VERSION}}
63+
.\SetVersion -FileName $sbeFileName -PropertyName 'AssemblyFileVersion' -Version ${{env.NUMBER_VERSION}}
64+
.\SetVersion -FileName $sbeFileName -PropertyName 'AssemblyInformationalVersion' -VersionString ${{env.ReleaseVersion}}
65+
66+
$commonInfoFile = "$env:GITHUB_WORKSPACE\src\Common\Properties\AssemblyInfo.cs"
67+
.\SetVersion -FileName $commonInfoFile -PropertyName 'AssemblyFileVersion' -Version ${{env.NUMBER_VERSION}}
68+
.\SetVersion -FileName $commonInfoFile -PropertyName 'AssemblyInformationalVersion' -VersionString ${{env.ReleaseVersion}}
69+
70+
$notificationHubsInfoFile = "$env:GITHUB_WORKSPACE\src\NotificationHubs\Properties\AssemblyInfo.cs"
71+
.\SetVersion -FileName $notificationHubsInfoFile -PropertyName 'AssemblyFileVersion' -Version ${{env.NUMBER_VERSION}}
72+
.\SetVersion -FileName $notificationHubsInfoFile -PropertyName 'AssemblyInformationalVersion' -VersionString ${{env.ReleaseVersion}}
5873
5974
- name: Build
60-
env:
61-
Version: ${{ inputs.release-version }}
6275
run: |
63-
msbuild /m /property:Configuration=${{env.BUILD_CONFIGURATION}},FileVersion=${{env.Version}} ${{env.SOLUTION_FILE_PATH}}
76+
msbuild /m /property:Configuration=${{env.BUILD_CONFIGURATION}},FileVersion=${{env.NUMBER_VERSION}},InformationalVersion=${{inputs.release-version}} ${{env.SOLUTION_FILE_PATH}}
6477
6578
- name: Run tests
6679
run: |
@@ -70,7 +83,7 @@ jobs:
7083
if ($process.ExitCode -ne 0) {throw "Unit tests failed (exit code = $($process.ExitCode))" }
7184
7285
- name: Cache build
73-
uses: actions/[email protected].5
86+
uses: actions/[email protected].11
7487
if: ${{ inputs.cache-build }}
7588
with:
7689
path: src/ServiceBusExplorer/bin/Release

.github/workflows/handle-tag.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Handle tag
33
on:
44
push:
55
tags:
6-
- '[0-9]+.[0-9]+.[0-9]+'
6+
- '[0-9]+.[0-9]+.[0-9]+*'
77
workflow_dispatch:
88

99
jobs:
@@ -15,7 +15,7 @@ jobs:
1515
id: tag-commit-hash
1616
run: |
1717
hash=${{ github.sha }}
18-
echo "::set-output name=tag-hash::${hash}"
18+
echo "{name}=tag-hash::${hash}" >> $GITHUB_OUTPUT
1919
echo $hash
2020
2121
- name: Checkout main
@@ -27,7 +27,7 @@ jobs:
2727
id: main-commit-hash
2828
run: |
2929
hash=$(git log -n1 --format=format:"%H")
30-
echo "::set-output name=main-hash::${hash}"
30+
echo "{name}=main-hash::${hash}" >> $GITHUB_OUTPUT
3131
echo $hash
3232
3333
- name: Verify tag commit matches main commit - exit if they don't match

.github/workflows/publish.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,21 @@ jobs:
2424
2525
- uses: actions/checkout@v3
2626

27+
- name: Verify release version and get just the numbers and the dots
28+
id: get-number-version
29+
run: |
30+
[Version]$numberVersion = .\GetNumberVersion -Version ${{ inputs.release-version }}
31+
[bool]$prerelease = $true
32+
33+
if ("$numberVersion" -eq "${{ inputs.release-version }}") {
34+
$prerelease = $false
35+
}
36+
37+
echo "PRERELEASE=$prerelease" >> $env:GITHUB_ENV
38+
2739
- name: Get cached build
2840
id: get-cached-build
29-
uses: actions/[email protected].5
41+
uses: actions/[email protected].11
3042
with:
3143
path: src/ServiceBusExplorer/bin/Release
3244
key: cached-output-${{ github.sha }}
@@ -80,7 +92,8 @@ jobs:
8092
Start-Sleep 1
8193
gh release upload ${{ env.RELEASE_VERSION }} $env:ZipFilename $env:NupkgFilename
8294
83-
- name: Publish to Chocolatey
95+
- name: Publish to Chocolatey if not prerelease
96+
if: ${{ env.PRERELEASE == 'FALSE' }}
8497
env:
8598
CHOCO_TOKEN: ${{ secrets.CHOCO_TOKEN }}
8699
run: |

GetNumberVersion.ps1

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Verify it is a proper version
2+
param(
3+
[Parameter(Mandatory=$false)]
4+
[string]
5+
$Version
6+
)
7+
8+
Set-StrictMode -Version 3
9+
10+
# RegEx from https://semver.org/
11+
[string]$semanticRegEx = '^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$'
12+
13+
if (-not ($Version -match $semanticRegEx)) {
14+
throw "The version must follow semantic versioning, see https://semver.org/." + `
15+
" For instance 4.3.22-beta."
16+
}
17+
18+
$parts = $Version -split {$_ -eq '-' -or $_ -eq '+'}
19+
20+
return $parts[0]

SetVersion.ps1

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,44 @@
11
param(
2-
[Parameter(Mandatory)]
2+
[Parameter(Mandatory)]
33
[string]
4-
$FileName,
4+
$FileName,
55

6-
[Parameter(Mandatory)]
7-
[string]
8-
$PropertyName,
6+
[Parameter(Mandatory)]
7+
[string]
8+
$PropertyName,
99

10-
[Parameter(Mandatory)]
10+
[Parameter(Mandatory,
11+
ParameterSetName = 'Version')]
1112
[Version]
12-
$Version
13+
$Version,
14+
15+
[Parameter(Mandatory,
16+
ParameterSetName = 'VersionString')]
17+
[string]
18+
$VersionString
1319
)
1420

1521
Set-StrictMode -Version 2
1622

1723
$pattern = "^\[assembly: $PropertyName\(""(.*)""\)\]$"
1824
$found = $false
1925

26+
if ($Version) {
27+
$VersionString = $Version
28+
}
29+
2030
$content = (Get-Content $fileName -Encoding UTF8) | ForEach-Object {
21-
if ($_ -match $pattern)
22-
{
23-
"[assembly: $PropertyName(""{0}"")]" -f $Version
24-
$found = $true
31+
if ($_ -match $pattern) {
32+
"[assembly: $PropertyName(""{0}"")]" -f $VersionString
33+
$found = $true
2534
}
26-
else
27-
{
35+
else {
2836
$_
2937
}
3038
}
3139

3240
if (-not $found) {
33-
$content += "[assembly: $PropertyName(""{0}"")]" -f $Version
41+
$content += "[assembly: $PropertyName(""{0}"")]" -f $VersionString
3442
}
3543

3644
$content | Set-Content $fileName -Encoding UTF8

0 commit comments

Comments
 (0)