Skip to content

Commit f12ed94

Browse files
committed
Set version in build.
1 parent d80054e commit f12ed94

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

.github/workflows/main.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,18 @@ jobs:
1010
name: "Build release"
1111
runs-on: windows-latest
1212
steps:
13-
- id: get-ver
13+
- name: get ver from ref_name
14+
id: get-ver
1415
run: |
15-
id=$(echo ${{github.ref_name}} | cut -dv -f2)
16-
echo "::set-output name=id::$ver"
16+
if (("${{github.ref_name}}" -match 'v?(\d+\.\d+\.\d+)') -eq $false) { Write-Host "::error::github.ref_name not in valid format. Expected '0.0.0' or 'v0.0.0' but got '${{github.ref_name}}'." -fore RED; exit 1; }
17+
$ver = $Matches[1]
18+
echo "VER=$ver" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
19+
echo "ver=$ver" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
20+
shell: powershell
21+
1722
- run: echo "${{steps.get-ver.outputs.ver}}"
18-
23+
shell: powershell
24+
1925
- name: Checkout code
2026
uses: actions/checkout@v3
2127

@@ -36,7 +42,7 @@ jobs:
3642
run: dotnet restore
3743

3844
- name: Build
39-
run: dotnet build --configuration Release -p:PackageVersion=${{steps.get-ver.outputs.ver}} -p:RepositoryCommit=${{ github.sha }} -p:RepositoryBranch=${{ github.ref_name }}
45+
run: dotnet build --configuration Release -p:Version=${{steps.get-ver.outputs.ver}} -p:PackageVersion=${{steps.get-ver.outputs.ver}} -p:RepositoryCommit=${{ github.sha }} -p:RepositoryBranch=${{ github.ref_name }}
4046

4147
- name: Test
4248
run: dotnet test --no-build --verbosity normal --configuration Release

0 commit comments

Comments
 (0)