Skip to content

Commit b30e9c5

Browse files
author
Petr Sramek
committed
tests
1 parent 0616a85 commit b30e9c5

File tree

3 files changed

+66
-40
lines changed

3 files changed

+66
-40
lines changed

.github/workflows/determine-version.yml

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ on:
88
description: 'Path to the configuration file.'
99
type: string
1010
required: true
11-
prerelease:
12-
description: 'Indicates whether the version should be a pre-release version.'
13-
type: boolean
14-
required: true
1511
run-number:
1612
description: 'The run number of the parent workflow.'
1713
type: number
@@ -27,27 +23,25 @@ on:
2723
required: true
2824
type: string
2925
default: '6.0.x'
26+
prerelease-tag:
27+
description: 'The prerelease tag to use. Default: ''''.'
28+
type: string
29+
required: false
30+
default: ''
3031

3132
jobs:
3233
version:
3334
name: 'Version'
3435
runs-on: ubuntu-latest
3536

3637
outputs:
37-
assembly-version: ${{ steps.gitversion.outputs.AssemblySemVer }}.${{ inputs.run-number }}.${{ steps.gitversion.outputs.CommitsSinceVersionSource }}
38-
assembly-informational-version: ${{ steps.gitversion.outputs.assemblySemVer }}.${{ inputs.run-number }}+${{ steps.gitversion.outputs.sha }}
39-
file-version: ${{ steps.gitversion.outputs.AssemblySemFileVer }}.${{ inputs.run-number }}.${{ steps.gitversion.outputs.CommitsSinceVersionSource }}
40-
package-version: ${{ fromJSON(format('[ "{0}.{1}{2)", "{0}.{1}" ]', steps.gitversion.outputs.AssemblySemVer, inputs.run-number , steps.gitversion.outputs.preReleaseLabelWithDash))[fromJSON(inputs.prerelease)] }}
38+
assembly-version: ${{ env.assembly-version }}
39+
assembly-informational-version: ${{ env.assembly-informational-version }}
40+
file-version: ${{ env.file-version }}
41+
package-version: ${{ env.package-version }}
4142

4243
steps:
4344

44-
- if: ${{ !(inputs.nuget-feed-server == 'NuGet' || inputs.nuget-feed-server == 'AzureArtifacts') }}
45-
name: 'Invalid NuGet feed server type'
46-
shell: bash
47-
run: |
48-
echo 'Invalid NuGet feed server type ${{ inputs.nuget-feed-server }}. Allowed values are 'NuGet' or 'AzureArtifacts'.'
49-
exit 1
50-
5145
- name: 'Checkout ${{ github.head_ref || github.ref }}'
5246
uses: actions/checkout@v4
5347
with:
@@ -65,4 +59,31 @@ jobs:
6559
with:
6660
useConfigFile: true
6761
configFilePath: ${{ inputs.config-file-path }}
62+
63+
- name: 'Set assembky version'
64+
shell: bash
65+
run: echo "assembly-version=${{ steps.gitversion.outputs.AssemblySemFileVer }}.${{ inputs.run-number }}.${{ steps.gitversion.outputs.CommitsSinceVersionSource }}" >> $GITHUB_ENV
66+
67+
- name: 'Set assembky informational version'
68+
shell: bash
69+
run: echo "assembly-informational-version=${{ steps.gitversion.outputs.assemblySemVer }}.${{ inputs.run-number }}+${{ steps.gitversion.outputs.sha }}" >> $GITHUB_ENV
70+
71+
- name: 'Set file version'
72+
shell: bash
73+
run: echo "file-version=${{ steps.gitversion.outputs.AssemblySemFileVer }}.${{ inputs.run-number }}.${{ steps.gitversion.outputs.CommitsSinceVersionSource }}" >> $GITHUB_ENV
74+
75+
- if: ${{ inputs.prerelease-tag == '' }}
76+
name: 'Set package version'
77+
shell: bash
78+
run: echo "package-version=${{ steps.gitversion.outputs.AssemblySemVer }}.${{ inputs.run-number }}" >> $GITHUB_ENV
79+
80+
- if: ${{ inputs.prerelease-tag != '' && startWith('-', inputs.prerelease-tag) }}
81+
name: 'Set package version'
82+
shell: bash
83+
run: echo "package-version=${{ steps.gitversion.outputs.AssemblySemVer }}.${{ inputs.run-number }}${{ inputs.prerelease-tag}}" >> $GITHUB_ENV
84+
85+
- if: ${{ inputs.prerelease-tag != '' && !startWith('-', inputs.prerelease-tag) }}
86+
name: 'Set package version'
87+
shell: bash
88+
run: echo "package-version=${{ steps.gitversion.outputs.AssemblySemVer }}.${{ inputs.run-number }}-${{ inputs.prerelease-tag}}" >> $GITHUB_ENV
6889

.github/workflows/dotnet.yml

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -53,29 +53,36 @@ jobs:
5353
5454
versioning:
5555
name: Versioning with GitVersion
56-
runs-on: ubuntu-latest
57-
outputs:
58-
ASSEMBLY_VERSION: ${{ steps.gitversion.outputs.assemblySemVer }}.${{ github.run_number }}
59-
ASSEMBLY_INFORMATIONAL_VERSION: ${{ steps.gitversion.outputs.assemblySemVer }}.${{ github.run_number }}+${{ steps.gitversion.outputs.sha }}
60-
FILE_VERSION: ${{ steps.gitversion.outputs.assemblySemVer }}.${{ github.run_number }}
61-
PACKAGE_VERSION: ${{ fromJSON(format('[ "{0}{1}", "{0}" ]', steps.gitversion.outputs.assemblySemVer, steps.gitversion.outputs.preReleaseLabelWithDash))[fromJSON(env.is-release)] }}
56+
needs: [variables]
6257

63-
steps:
64-
- name: 'Checkout ${{ github.head_ref || github.ref }}'
65-
uses: actions/checkout@v4
66-
with:
67-
fetch-depth: 0
68-
- name: Install GitVersion ${{ env.git-version }}
69-
uses: gittools/actions/gitversion/[email protected]
70-
with:
71-
versionSpec: ${{ env.git-version }}
72-
preferLatestVersion: true
73-
- name: Determine version with GitVersion ${{ env.git-version }}
74-
id: gitversion
75-
uses: gittools/actions/gitversion/[email protected]
76-
with:
77-
useConfigFile: true
78-
configFilePath: ./.gitversion/version.yml
58+
uses: ./.github/workflows/release-nuget-package.yml
59+
60+
with:
61+
config-file-path: './.gitversion/version.yml'
62+
run-number: ${{ needs.variables.outputs.github-run-number }}
63+
64+
# outputs:
65+
# ASSEMBLY_VERSION: ${{ steps.gitversion.outputs.assemblySemVer }}.${{ github.run_number }}
66+
# ASSEMBLY_INFORMATIONAL_VERSION: ${{ steps.gitversion.outputs.assemblySemVer }}.${{ github.run_number }}+${{ steps.gitversion.outputs.sha }}
67+
# FILE_VERSION: ${{ steps.gitversion.outputs.assemblySemVer }}.${{ github.run_number }}
68+
# PACKAGE_VERSION: ${{ fromJSON(format('[ "{0}{1}", "{0}" ]', steps.gitversion.outputs.assemblySemVer, steps.gitversion.outputs.preReleaseLabelWithDash))[fromJSON(env.is-release)] }}
69+
70+
# steps:
71+
# - name: 'Checkout ${{ github.head_ref || github.ref }}'
72+
# uses: actions/checkout@v4
73+
# with:
74+
# fetch-depth: 0
75+
# - name: Install GitVersion ${{ env.git-version }}
76+
# uses: gittools/actions/gitversion/[email protected]
77+
# with:
78+
# versionSpec: ${{ env.git-version }}
79+
# preferLatestVersion: true
80+
# - name: Determine version with GitVersion ${{ env.git-version }}
81+
# id: gitversion
82+
# uses: gittools/actions/gitversion/[email protected]
83+
# with:
84+
# useConfigFile: true
85+
# configFilePath: ./.gitversion/version.yml
7986

8087
build:
8188
name: Build with .NET

.gitversion/version.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ update-build-number: false
77
semantic-version-format: Loose
88
strategies:
99
- VersionInBranchName
10+
- TrackReleaseBranches
1011
- Fallback
1112
ignore:
1213
sha: []
@@ -40,7 +41,6 @@ branches:
4041
regex: ^develop\/([vV]?\d+.\d+(\.\d+){0,1})$
4142
source-branches:
4243
- feature
43-
is-release-branch: true
4444
preview:
4545
mode: ContinuousDeployment
4646
label: 'preview'
@@ -49,7 +49,6 @@ branches:
4949
source-branches:
5050
- release
5151
- develop
52-
is-release-branch: true
5352
release:
5453
mode: ContinuousDeployment
5554
label: ''
@@ -66,7 +65,6 @@ branches:
6665
regex: ^(support|maintenance)\/(?<BranchName>.+)
6766
source-branches:
6867
- release
69-
is-release-branch: true
7068
hotfix:
7169
mode: ContinuousDelivery
7270
label: 'hotfix'

0 commit comments

Comments
 (0)