Skip to content

Commit 436154d

Browse files
authored
Use PreRelease GitVersion Indices (#28)
* use pre release indices instead of build meta data * format * add message for updated version number * Update action.yml Try to use environment variables instead for the linux systems * Update action.yml remove quotations from version variable * rename
1 parent d3a46e6 commit 436154d

4 files changed

Lines changed: 25 additions & 13 deletions

File tree

CollectReleaseArtifacts/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ inputs:
1818
runs:
1919
using: composite
2020
steps:
21-
- run: ${{ github.action_path }}\script.py "${{ inputs.version }}" "${{inputs.artifacts}}" "${{ inputs.destination }}"
21+
- run: ${{ github.action_path }}\script.py ${{ inputs.version }} "${{inputs.artifacts}}" "${{ inputs.destination }}"
2222
shell: powershell
2323
if: runner.os != 'Linux'
24-
- run: python3 ${GITHUB_ACTION_PATH}/script.py "${{ inputs.version }}" "${{inputs.artifacts}}" "${{ inputs.destination }}"
24+
- run: python3 ${GITHUB_ACTION_PATH}/script.py ${{ inputs.version }} "${{inputs.artifacts}}" "${{ inputs.destination }}"
2525
if: runner.os == 'Linux'
2626
shell: bash

ExecuteGitVersion/action.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ outputs:
99
value: ${{ steps.gitversion.outputs.minor }}
1010
patch:
1111
value: ${{ steps.gitversion.outputs.patch }}
12-
build:
12+
preReleaseTag:
1313
value: ${{ steps.gitversion.outputs.PreReleaseTag }}
14+
preReleaseNumber:
15+
value: ${{ steps.gitversion.outputs.PreReleaseNumber }}
1416
fullSemVer:
1517
value: ${{ steps.gitversion.outputs.fullSemVer }}
1618

WriteBuildVersion/action.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,22 @@ inputs:
1515
patch_version:
1616
description: The Patch version
1717
required: true
18-
build_version:
19-
description: The Build version
18+
pre_release_tag:
19+
description: The pre-release tag
20+
required: true
21+
pre_release_number:
22+
description: The pre-release number
2023
required: true
2124

2225
runs:
2326
using: composite
2427
steps:
25-
- run: ${{ github.action_path }}\script.py ${{inputs.filepath}} ${{inputs.major_version}} ${{inputs.minor_version}} ${{inputs.patch_version}} ${{inputs.build_version}}
28+
- run: ${{ github.action_path }}\script.py ${{inputs.filepath}} ${{inputs.major_version}} ${{inputs.minor_version}} ${{inputs.patch_version}} ${{inputs.pre_release_tag}} ${{inputs.pre_release_number}}
2629
shell: powershell
2730
if: runner.os != 'Linux'
2831
- run: ls -al ${GITHUB_ACTION_PATH}
2932
shell: bash
3033
if: runner.os == 'Linux'
31-
- run: python3 ${GITHUB_ACTION_PATH}/script.py ${{inputs.filepath}} ${{inputs.major_version}} ${{inputs.minor_version}} ${{inputs.patch_version}} ${{inputs.build_version}}
34+
- run: python3 ${GITHUB_ACTION_PATH}/script.py ${{inputs.filepath}} ${{inputs.major_version}} ${{inputs.minor_version}} ${{inputs.patch_version}} ${{inputs.pre_release_tag}} ${{inputs.pre_release_number}}
3235
if: runner.os == 'Linux'
3336
shell: bash

WriteBuildVersion/script.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,16 @@
77
import sys
88
import os
99

10-
def main(filepath, major, minor, patch, build):
10+
def main(filepath, major, minor, patch, pre_release_tag, pre_release_number):
11+
# Figure out which pre-release index to use
12+
if(pre_release_tag.isnumeric()):
13+
build = pre_release_tag
14+
else:
15+
build = pre_release_number
16+
1117
# We first check to see if the file exists
1218
if (os.path.isfile(filepath)):
13-
print("Updating BuildVersion.h")
19+
print("Updating BuildVersion.h with "+major+"."+minor+"."+patch+"+"+build)
1420

1521
for line in fileinput.input(filepath, inplace = 1):
1622
if "major" in line:
@@ -30,13 +36,14 @@ def main(filepath, major, minor, patch, build):
3036

3137
if __name__ == '__main__':
3238
# Get major, minor, and patch versions from inputs
33-
if len(sys.argv) < 5:
34-
sys.exit("Correct usage: script.py <file_path> <major version> <minor number> <patch number> <build number>")
39+
if len(sys.argv) < 6:
40+
sys.exit("Correct usage: script.py <file_path> <major version> <minor number> <patch number> <PreRelease Tag> <PreRelease Number>")
3541

3642
filepath = sys.argv[1]
3743
major = sys.argv[2]
3844
minor = sys.argv[3]
3945
patch = sys.argv[4]
40-
build = sys.argv[5] if len(sys.argv) == 6 else '0'
46+
pre_release_tag = sys.argv[5]
47+
pre_release_number = sys.argv[6]
4148

42-
main(filepath, major, minor, patch, build)
49+
main(filepath, major, minor, patch, pre_release_tag, pre_release_number)

0 commit comments

Comments
 (0)