Skip to content

Commit f57da22

Browse files
committed
wohhooo
1 parent 8b92d20 commit f57da22

File tree

4 files changed

+88
-128
lines changed

4 files changed

+88
-128
lines changed

.github/actions/determine-version/action.yml renamed to .github/actions/extract-version/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: 'Determine version'
1+
name: 'Extract version'
22
author: 'Pete Sramek'
33
description: 'Determines versions for the build.'
44
inputs:
@@ -49,7 +49,7 @@ runs:
4949
regex: ${{ inputs.version-format }}
5050
flags: 'g'
5151

52-
- name: 'Set version output'
52+
- name: 'Set extracted version output'
5353
if: steps.regex-match.outputs.match != ''
5454
shell: bash
5555
run: |
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: 'Format version'
2+
author: 'Pete Sramek'
3+
description: 'Formats versions.'
4+
inputs:
5+
# Required
6+
version:
7+
description: 'Version to use.'
8+
required: true
9+
patch:
10+
description: 'Patch version to append to the formatted version.'
11+
required: true
12+
commit-delta:
13+
description: 'Commit delta to append to the formatted version.'
14+
required: true
15+
commit-sha:
16+
description: 'Commit SHA to append to the formatted version.'
17+
required: true
18+
pre-release-tag:
19+
description: 'Pre-release tag to append to the formatted version.'
20+
required: true
21+
# Optional
22+
dotnet_sdk_version:
23+
description: '.NET SDK version. Default: ''9.x'''
24+
required: false
25+
default: '9.x'
26+
27+
outputs:
28+
friendly-version:
29+
description: 'Version extracted from the branch name.'
30+
value: ${{ steps.regex-match.outputs.match }}
31+
assembly-version:
32+
description: 'Formatted version.'
33+
value: ${{ steps.format-version.outputs.assembly-version }}
34+
assembly-informational-version:
35+
description: 'Formatted assembly informational version.'
36+
value: ${{ steps.format-version.outputs.assembly-informational-version }}
37+
file-version:
38+
description: 'Formatted file version.'
39+
value: ${{ steps.format-version.outputs.file-version }}
40+
package-version:
41+
description: 'Formatted package version.'
42+
value: ${{ steps.format-version.outputs.package-version }}
43+
44+
runs:
45+
using: "composite"
46+
steps:
47+
- name: 'Checkout ${{ github.head_ref || github.ref }}'
48+
uses: actions/checkout@v5
49+
50+
- name: 'Setup .NET ${{ inputs.dotnet_sdk_version }}'
51+
uses: actions/setup-dotnet@v4
52+
with:
53+
dotnet-version: ${{ inputs.dotnet_sdk_version }}
54+
- name: 'Format version'
55+
shell: bash
56+
id: format-version
57+
run: |
58+
echo "friendly-version=${{ inputs.version }}" >> $GITHUB_OUTPUT
59+
echo "assembly-version=${{ inputs.version }}.${{ inputs.patch }}.${{ inputs.commit-delta }}" >> $GITHUB_OUTPUT
60+
echo "assembly-informational-version=${{ inputs.version }}.${{ inputs.patch }}+${{ inputs.commit-sha }}" >> $GITHUB_OUTPUT
61+
echo "file-version=${{ inputs.version }}.${{ inputs.patch }}.${{ inputs.commit-delta }}" >> $GITHUB_OUTPUT
62+
if [ -n "${{ inputs.prerelease-tag }}" ]; then
63+
echo "package-version=${{ inputs.version }}.${{ inputs.patch }}-${{ inputs.pre-release-tag }}-${{ inputs.commit-delta }}" >> $GITHUB_OUTPUT
64+
else
65+
echo "package-version=${{ inputs.version }}.${{ inputs.patch }}.${{ inputs.commit-delta }}" >> $GITHUB_OUTPUT
66+
fi

.github/workflows/build.yml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
echo "is-preview:${{ startsWith(github.ref_name, 'preview') }}"
4949
5050
versioning:
51-
name: 'Determine versions (new)'
51+
name: 'Extract version (new)'
5252
needs: [workflow-variables]
5353
runs-on: ubuntu-latest
5454
steps:
@@ -58,11 +58,29 @@ jobs:
5858
uses: actions/setup-dotnet@v4
5959
with:
6060
dotnet-version: ${{ env.dotnet-sdk-version }}
61-
- name: 'Determine versions'
61+
- name: 'Extract version from branch name'
6262
id: versioning
6363
uses: './.github/actions/determine-version'
6464
with:
6565
branch-name: ${{ github.ref_name }}
66+
- name: ''
67+
shell: bash
68+
id: create-pre-release-tag
69+
run: |
70+
if [[ "${{ needs.workflow-variables.outputs.is-release }}" == 'true' ]]; then
71+
echo "pre-release-tag=" >> GITHUB_OUTPUT
72+
else
73+
branch_name='${{ github.ref_name }}'
74+
echo "pre-release-tag=${branch_name//[/]/_}" >> GITHUB_OUTPUT
75+
fi
76+
- name: 'Format version'
77+
uses: ./.github/actions/format-version
78+
with:
79+
version: ${{ steps.versioning.outputs.version }}
80+
patch: ${{ github.run_number }}
81+
build: git rev-list --count ${{ github.ref_name }} ^main
82+
sha: ${{ github.sha }}]
83+
pre-release-tag: ${{ steps.create-pre-release-tag.outputs.pre-release-tag }}
6684

6785
build:
6886
name: 'Compile source code'

.gitversion/version.yml

Lines changed: 0 additions & 124 deletions
This file was deleted.

0 commit comments

Comments
 (0)