Skip to content

Commit 823337a

Browse files
authored
BE-803 feat: use git-version instead of self-written action (#58)
1 parent a9c61d1 commit 823337a

File tree

3 files changed

+34
-64
lines changed

3 files changed

+34
-64
lines changed

.gflows/libs/job_version.lib.yml

Lines changed: 15 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,59 +4,42 @@
44
#@ load("steps.lib.yml", "steps")
55
#@ load("common.lib.yml", "common")
66
---
7-
#@ def set_version(context):
8-
#@ if getattr(getattr(context,"versioning",None),"use_branch_slug", False):
9-
#@ return "none"
10-
#@ end
11-
#@ return "${{ steps.issue-key.outputs.issue_id_slug }}"
12-
#@ end
13-
---
147
#@ def set_build_number(context):
158
#@ if getattr(getattr(context,"versioning",None),"use_build_number", False):
169
#@ return "${{ github.run_number }}"
1710
#@ end
1811
#@ return "none"
1912
#@ end
2013
---
21-
#@ def get_release_candidate_version_flag(context):
22-
#@ if getattr(getattr(context,"versioning",None),"release_candidate_version", True):
23-
#@ return True
24-
#@ end
25-
#@ return False
26-
#@ end
27-
---
2814
#@ def generate_version_job(sections):
2915
runs-on: ubuntu-latest
3016
name: Get version from git tag
3117
outputs:
32-
app_version: ${{ steps.version.outputs.app_version }}
18+
app_version: ${{ steps.version.outputs.semVer }}
3319
is_production: ${{ steps.is_production_check.outputs.is_production }}
34-
file_version: ${{ steps.version.outputs.file_version }}
35-
information_version: ${{ steps.version.outputs.information_version }}
36-
issue_id_slug: ${{ steps.issue-key.outputs.issue_id_slug }}
20+
file_version: ${{ steps.version.outputs.assemblySemFileVer }}
21+
information_version: ${{ steps.steps.version.outputs.informationalVersion }}
22+
issue_id_slug: ${{ steps.version.outputs.preReleaseLabel }}
3723
steps:
3824
- name: Checkout repository
3925
uses: actions/checkout@v3
4026
with:
4127
fetch-depth: 0
42-
- #@ steps.checkout_private_actions()
43-
- name: Get jira Ticket slug
44-
id: issue-key
45-
uses: ./.github/actions/get-issue-key
46-
- name: Get version from git tags
47-
id: version
48-
uses: ./.github/actions/get-version
28+
- name: Install GitVersion
29+
uses: gittools/actions/gitversion/setup@v0
4930
with:
50-
build-number: #@ set_build_number(sections)
51-
pre-release-version: #@ set_version(sections)
52-
production-branches: #@ "\n".join(getattr(getattr(sections,"versioning",None),"production_branches",["master","main"]))
53-
release-candidate-version: #@ get_release_candidate_version_flag(sections)
54-
- name: Is production check
31+
versionSpec: '5.x'
32+
- name: Determine Version
33+
id: version
34+
uses: gittools/actions/gitversion/execute@v0
35+
with:
36+
useConfigFile: true
37+
- name: Is production check
5538
shell: bash
5639
id: is_production_check
5740
run: |
58-
if [[ ${{ steps.version.outputs.app_version }} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
41+
if [[ ${{ steps.version.outputs.semVer }} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
5942
echo ::set-output name=is_production::true
6043
fi
6144
#@ end
62-
---
45+
---

.gflows/libs/steps.lib.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ name: Checkout GitHub Action Repos
4848
uses: daspn/private-actions-checkout@v2
4949
with:
5050
actions_list: '[
51-
"covergo/[email protected]",
52-
"covergo/[email protected]",
5351
"covergo/[email protected]",
5452
"covergo/[email protected]",
5553
"covergo/[email protected]",

github-sample/workflows/build-publish.yml

Lines changed: 19 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -17,41 +17,30 @@ jobs:
1717
runs-on: ubuntu-latest
1818
name: Get version from git tag
1919
outputs:
20-
app_version: ${{ steps.version.outputs.app_version }}
20+
app_version: ${{ steps.version.outputs.semVer }}
2121
is_production: ${{ steps.is_production_check.outputs.is_production }}
22-
file_version: ${{ steps.version.outputs.file_version }}
23-
information_version: ${{ steps.version.outputs.information_version }}
24-
issue_id_slug: ${{ steps.issue-key.outputs.issue_id_slug }}
22+
file_version: ${{ steps.version.outputs.assemblySemFileVer }}
23+
information_version: ${{ steps.steps.version.outputs.informationalVersion }}
24+
issue_id_slug: ${{ steps.version.outputs.preReleaseLabel }}
2525
steps:
2626
- name: Checkout repository
2727
uses: actions/checkout@v3
2828
with:
2929
fetch-depth: 0
30-
- name: Checkout GitHub Action Repos
31-
uses: daspn/private-actions-checkout@v2
30+
- name: Install GitVersion
31+
uses: gittools/actions/gitversion/setup@v0
3232
with:
33-
actions_list: '[ "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]" ]'
34-
checkout_base_path: ./.github/actions
35-
app_id: ${{ secrets.PRIVATE_ACTION_APP_ID }}
36-
app_private_key: ${{ secrets.PRIVATE_ACTION_APP_PRIVATE_KEY }}
37-
- name: Get jira Ticket slug
38-
id: issue-key
39-
uses: ./.github/actions/get-issue-key
40-
- name: Get version from git tags
33+
versionSpec: 5.x
34+
- name: Determine Version
4135
id: version
42-
uses: ./.github/actions/get-version
43-
with:
44-
build-number: none
45-
pre-release-version: none
46-
production-branches: |-
47-
master
48-
main
49-
release-candidate-version: false
36+
uses: gittools/actions/gitversion/execute@v0
37+
with:
38+
useConfigFile: true
5039
- name: Is production check
5140
shell: bash
5241
id: is_production_check
5342
run: |
54-
if [[ ${{ steps.version.outputs.app_version }} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
43+
if [[ ${{ steps.version.outputs.semVer }} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
5544
echo ::set-output name=is_production::true
5645
fi
5746
scan-code-net:
@@ -154,7 +143,7 @@ jobs:
154143
- name: Checkout GitHub Action Repos
155144
uses: daspn/private-actions-checkout@v2
156145
with:
157-
actions_list: '[ "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]" ]'
146+
actions_list: '[ "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]" ]'
158147
checkout_base_path: ./.github/actions
159148
app_id: ${{ secrets.PRIVATE_ACTION_APP_ID }}
160149
app_private_key: ${{ secrets.PRIVATE_ACTION_APP_PRIVATE_KEY }}
@@ -232,7 +221,7 @@ jobs:
232221
- name: Checkout GitHub Action Repos
233222
uses: daspn/private-actions-checkout@v2
234223
with:
235-
actions_list: '[ "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]" ]'
224+
actions_list: '[ "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]" ]'
236225
checkout_base_path: ./.github/actions
237226
app_id: ${{ secrets.PRIVATE_ACTION_APP_ID }}
238227
app_private_key: ${{ secrets.PRIVATE_ACTION_APP_PRIVATE_KEY }}
@@ -439,7 +428,7 @@ jobs:
439428
- name: Checkout GitHub Action Repos
440429
uses: daspn/private-actions-checkout@v2
441430
with:
442-
actions_list: '[ "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]" ]'
431+
actions_list: '[ "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]" ]'
443432
checkout_base_path: ./.github/actions
444433
app_id: ${{ secrets.PRIVATE_ACTION_APP_ID }}
445434
app_private_key: ${{ secrets.PRIVATE_ACTION_APP_PRIVATE_KEY }}
@@ -519,7 +508,7 @@ jobs:
519508
- name: Checkout GitHub Action Repos
520509
uses: daspn/private-actions-checkout@v2
521510
with:
522-
actions_list: '[ "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]" ]'
511+
actions_list: '[ "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]" ]'
523512
checkout_base_path: ./.github/actions
524513
app_id: ${{ secrets.PRIVATE_ACTION_APP_ID }}
525514
app_private_key: ${{ secrets.PRIVATE_ACTION_APP_PRIVATE_KEY }}
@@ -647,7 +636,7 @@ jobs:
647636
- name: Checkout GitHub Action Repos
648637
uses: daspn/private-actions-checkout@v2
649638
with:
650-
actions_list: '[ "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]" ]'
639+
actions_list: '[ "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]" ]'
651640
checkout_base_path: ./.github/actions
652641
app_id: ${{ secrets.PRIVATE_ACTION_APP_ID }}
653642
app_private_key: ${{ secrets.PRIVATE_ACTION_APP_PRIVATE_KEY }}
@@ -801,7 +790,7 @@ jobs:
801790
- name: Checkout GitHub Action Repos
802791
uses: daspn/private-actions-checkout@v2
803792
with:
804-
actions_list: '[ "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]" ]'
793+
actions_list: '[ "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]" ]'
805794
checkout_base_path: ./.github/actions
806795
app_id: ${{ secrets.PRIVATE_ACTION_APP_ID }}
807796
app_private_key: ${{ secrets.PRIVATE_ACTION_APP_PRIVATE_KEY }}
@@ -1145,7 +1134,7 @@ jobs:
11451134
- name: Checkout GitHub Action Repos
11461135
uses: daspn/private-actions-checkout@v2
11471136
with:
1148-
actions_list: '[ "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]" ]'
1137+
actions_list: '[ "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]", "covergo/[email protected]" ]'
11491138
checkout_base_path: ./.github/actions
11501139
app_id: ${{ secrets.PRIVATE_ACTION_APP_ID }}
11511140
app_private_key: ${{ secrets.PRIVATE_ACTION_APP_PRIVATE_KEY }}

0 commit comments

Comments
 (0)