-
Notifications
You must be signed in to change notification settings - Fork 2
255 lines (237 loc) · 14.4 KB
/
different-job.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
name: different-job
on: [ push, pull_request, workflow_dispatch ]
jobs:
GitVersion_v5_Job:
name: GitVersion v5 Job
runs-on: ubuntu-latest
outputs:
branchName: ${{ steps.version_step.outputs.branchName }}
major: ${{ steps.version_step.outputs.major }}
minor: ${{ steps.version_step.outputs.minor }}
patch: ${{ steps.version_step.outputs.patch }}
semVer: ${{ steps.version_step.outputs.semVer }}
fullSemVer: ${{ steps.version_step.outputs.fullSemVer }}
GitVersion_BranchName: ${{ steps.version_step.outputs.GitVersion_BranchName }}
GitVersion_Major: ${{ steps.version_step.outputs.GitVersion_Major }}
GitVersion_Minor: ${{ steps.version_step.outputs.GitVersion_Minor }}
GitVersion_Patch: ${{ steps.version_step.outputs.GitVersion_Patch }}
GitVersion_SemVer: ${{ steps.version_step.outputs.GitVersion_SemVer }}
GitVersion_FullSemVer: ${{ steps.version_step.outputs.GitVersion_FullSemVer }}
steps:
- uses: actions/checkout@v4
- name: Fetch all history for all tags and branches
run: |
git fetch --prune --unshallow
- uses: gittools/actions/gitversion/setup@v0.13.4
name: Install GitVersion
with:
versionSpec: '5.x'
includePrerelease: false
- uses: gittools/actions/gitversion/execute@v0.13.4
name: Use GitVersion
with:
useConfigFile: true
configFilePath: 'GitVersion_v5.yml'
overrideConfig: |
update-build-number=false
id: version_step # step id used as reference for output values
Use_GitVersion_v5_without_prefix:
name: Use Output from previous job (without prefix)
runs-on: windows-latest
needs: [ GitVersion_v5_Job ]
if: contains(needs.GitVersion_v5_Job.outputs['branchName'], 'main')
env:
myvar_major: ${{ needs.GitVersion_v5_Job.outputs.major }}
myvar_minor: ${{ needs.GitVersion_v5_Job.outputs.minor }}
myvar_patch: ${{ needs.GitVersion_v5_Job.outputs.patch }}
myvar_semVer: ${{ needs.GitVersion_v5_Job.outputs.semVer }}
myvar_fullSemVer: ${{ needs.GitVersion_v5_Job.outputs.fullSemVer }}
steps:
- run: |
echo "Major (env:myvar_major) : $env:myvar_major"
echo "Minor (env:myvar_minor) : $env:myvar_minor"
echo "Patch (env:myvar_patch) : $env:myvar_patch"
echo "SemVer (env:myvar_semVer) : $env:myvar_semVer"
echo "FullSemVer (env:myvar_fullSemVer) : $env:myvar_fullSemVer"
name: Use job variables (pwsh - outputs without prefix)
shell: pwsh
- run: |
echo "Major (env:localvar_major): $env:localvar_major"
echo "Minor (env:localvar_minor): $env:localvar_minor"
echo "Patch (env:localvar_patch): $env:localvar_patch"
echo "SemVer (env:localvar_semVer): $env:localvar_semVer"
echo "FullSemVer (env:localvar_fullSemVer): $env:localvar_fullSemVer"
name: Use local env mapped from output (pwsh - outputs without prefix)
shell: pwsh
env:
localvar_major: ${{ needs.GitVersion_v5_Job.outputs.major }}
localvar_minor: ${{ needs.GitVersion_v5_Job.outputs.minor }}
localvar_patch: ${{ needs.GitVersion_v5_Job.outputs.patch }}
localvar_semVer: ${{ needs.GitVersion_v5_Job.outputs.semVer }}
localvar_fullSemVer: ${{ needs.GitVersion_v5_Job.outputs.fullSemVer }}
- run: |
echo "Major (env:localvar_major) : $env:localvar_major"
echo "Minor (env:localvar_minor) : $env:localvar_minor"
echo "Patch (env:localvar_patch) : $env:localvar_patch"
echo "SemVer (env:localvar_semVer) : $env:localvar_semVer"
echo "FullSemVer (env:localvar_fullSemVer) : $env:localvar_fullSemVer"
name: Use local env mapped from job variables (pwsh - outputs without prefix)
shell: pwsh
env:
localvar_major: ${{ env.myvar_major }}
localvar_minor: ${{ env.myvar_minor }}
localvar_patch: ${{ env.myvar_patch }}
localvar_semVer: ${{ env.myvar_semVer }}
localvar_fullSemVer: ${{ env.myvar_fullSemVer }}
- run: |
echo "Major (needs.GitVersion_v5_Job.outputs.major) : ${{ needs.GitVersion_v5_Job.outputs.major }}"
echo "Minor (needs.GitVersion_v5_Job.outputs.minor) : ${{ needs.GitVersion_v5_Job.outputs.minor }}"
echo "Patch (needs.GitVersion_v5_Job.outputs.patch) : ${{ needs.GitVersion_v5_Job.outputs.patch }}"
echo "SemVer (needs.GitVersion_v5_Job.outputs.semVer) : ${{ needs.GitVersion_v5_Job.outputs.semVer }}"
echo "FullSemVer (needs.GitVersion_v5_Job.outputs.fullSemVer) : ${{ needs.GitVersion_v5_Job.outputs.fullSemVer }}"
name: Use direct output from previous job (pwsh - outputs without prefix)
shell: pwsh
- run: |
echo "Major (myvar_major) : $myvar_major"
echo "Minor (myvar_minor) : $myvar_minor"
echo "Patch (myvar_patch) : $myvar_patch"
echo "SemVer (myvar_semVer) : $myvar_semVer"
echo "FullSemVer (myvar_fullSemVer) : $myvar_fullSemVer"
name: Use job variables (bash - outputs without prefix)
shell: bash
- run: |
echo "Major (localvar_major): $localvar_major"
echo "Minor (localvar_minor): $localvar_minor"
echo "Patch (localvar_patch): $localvar_patch"
echo "SemVer (localvar_semVer): $localvar_semVer"
echo "FullSemVer (localvar_fullSemVer): $localvar_fullSemVer"
name: Use local env mapped from output (bash - outputs without prefix)
shell: bash
env:
localvar_major: ${{ needs.GitVersion_v5_Job.outputs.major }}
localvar_minor: ${{ needs.GitVersion_v5_Job.outputs.minor }}
localvar_patch: ${{ needs.GitVersion_v5_Job.outputs.patch }}
localvar_semVer: ${{ needs.GitVersion_v5_Job.outputs.semVer }}
localvar_fullSemVer: ${{ needs.GitVersion_v5_Job.outputs.fullSemVer }}
- run: |
echo "Major (localvar_major) : $localvar_major"
echo "Minor (localvar_minor) : $localvar_minor"
echo "Patch (localvar_patch) : $localvar_patch"
echo "SemVer (localvar_semVer) : $localvar_semVer"
echo "FullSemVer (localvar_fullSemVer) : $localvar_fullSemVer"
name: Use local env mapped from job variables (bash - outputs without prefix)
shell: bash
env:
localvar_major: ${{ env.myvar_major }}
localvar_minor: ${{ env.myvar_minor }}
localvar_patch: ${{ env.myvar_patch }}
localvar_semVer: ${{ env.myvar_semVer }}
localvar_fullSemVer: ${{ env.myvar_fullSemVer }}
- run: |
echo "Major (needs.GitVersion_v5_Job.outputs.major) : ${{ needs.GitVersion_v5_Job.outputs.major }}"
echo "Minor (needs.GitVersion_v5_Job.outputs.minor) : ${{ needs.GitVersion_v5_Job.outputs.minor }}"
echo "Patch (needs.GitVersion_v5_Job.outputs.patch) : ${{ needs.GitVersion_v5_Job.outputs.patch }}"
echo "SemVer (needs.GitVersion_v5_Job.outputs.semVer) : ${{ needs.GitVersion_v5_Job.outputs.semVer }}"
echo "FullSemVer (needs.GitVersion_v5_Job.outputs.fullSemVer) : ${{ needs.GitVersion_v5_Job.outputs.fullSemVer }}"
name: Use direct output from previous job (bash - outputs without prefix)
shell: bash
Use_GitVersion_v5_with_prefix:
name: Use Output from previous job (with prefix)
runs-on: windows-latest
needs: [ GitVersion_v5_Job ]
if: contains(needs.GitVersion_v5_Job.outputs['GitVersion_BranchName'], 'main')
env:
myvar_GitVersion_Major: ${{ needs.GitVersion_v5_Job.outputs.GitVersion_Major }}
myvar_GitVersion_Minor: ${{ needs.GitVersion_v5_Job.outputs.GitVersion_Minor }}
myvar_GitVersion_Patch: ${{ needs.GitVersion_v5_Job.outputs.GitVersion_Patch }}
myvar_GitVersion_SemVer: ${{ needs.GitVersion_v5_Job.outputs.GitVersion_SemVer }}
myvar_GitVersion_FullSemVer: ${{ needs.GitVersion_v5_Job.outputs.GitVersion_FullSemVer }}
steps:
- run: |
echo "Major (env:myvar_GitVersion_Major) : $env:myvar_GitVersion_Major"
echo "Minor (env:myvar_GitVersion_Minor) : $env:myvar_GitVersion_Minor"
echo "Patch (env:myvar_GitVersion_Patch) : $env:myvar_GitVersion_Patch"
echo "SemVer (env:myvar_GitVersion_SemVer) : $env:myvar_GitVersion_SemVer"
echo "FullSemVer (env:myvar_GitVersion_FullSemVer) : $env:myvar_GitVersion_FullSemVer"
name: Use job variables (pwsh - outputs with prefix)
shell: pwsh
- run: |
echo "Major (env:localvar_major): $env:localvar_major"
echo "Minor (env:localvar_minor): $env:localvar_minor"
echo "Patch (env:localvar_patch): $env:localvar_patch"
echo "SemVer (env:localvar_semVer): $env:localvar_semVer"
echo "FullSemVer (env:localvar_fullSemVer): $env:localvar_fullSemVer"
name: Use local env mapped from output (pwsh - outputs with prefix)
shell: pwsh
env:
localvar_major: ${{ needs.GitVersion_v5_Job.outputs.GitVersion_Major }}
localvar_minor: ${{ needs.GitVersion_v5_Job.outputs.GitVersion_Minor }}
localvar_patch: ${{ needs.GitVersion_v5_Job.outputs.GitVersion_Patch }}
localvar_semVer: ${{ needs.GitVersion_v5_Job.outputs.GitVersion_SemVer }}
localvar_fullSemVer: ${{ needs.GitVersion_v5_Job.outputs.GitVersion_FullSemVer }}
- run: |
echo "Major (env:localvar_major) : $env:localvar_major"
echo "Minor (env:localvar_minor) : $env:localvar_minor"
echo "Patch (env:localvar_patch) : $env:localvar_patch"
echo "SemVer (env:localvar_semVer) : $env:localvar_semVer"
echo "FullSemVer (env:localvar_fullSemVer) : $env:localvar_fullSemVer"
name: Use local env mapped from job variables (pwsh - outputs with prefix)
shell: pwsh
env:
localvar_major: ${{ env.myvar_GitVersion_Major }}
localvar_minor: ${{ env.myvar_GitVersion_Minor }}
localvar_patch: ${{ env.myvar_GitVersion_Patch }}
localvar_semVer: ${{ env.myvar_GitVersion_SemVer }}
localvar_fullSemVer: ${{ env.myvar_GitVersion_FullSemVer }}
- run: |
echo "Major (needs.GitVersion_v5_Job.outputs.GitVersion_Major) : ${{ needs.GitVersion_v5_Job.outputs.GitVersion_Major }}"
echo "Minor (needs.GitVersion_v5_Job.outputs.GitVersion_Minor) : ${{ needs.GitVersion_v5_Job.outputs.GitVersion_Minor }}"
echo "Patch (needs.GitVersion_v5_Job.outputs.GitVersion_Patch) : ${{ needs.GitVersion_v5_Job.outputs.GitVersion_Patch }}"
echo "SemVer (needs.GitVersion_v5_Job.outputs.GitVersion_SemVer) : ${{ needs.GitVersion_v5_Job.outputs.GitVersion_SemVer }}"
echo "FullSemVer (needs.GitVersion_v5_Job.outputs.GitVersion_FullSemVer) : ${{ needs.GitVersion_v5_Job.outputs.GitVersion_FullSemVer }}"
name: Use direct output from previous job (pwsh - outputs with prefix)
shell: pwsh
- run: |
echo "Major (myvar_GitVersion_Major) : $myvar_GitVersion_Major"
echo "Minor (myvar_GitVersion_Minor) : $myvar_GitVersion_Minor"
echo "Patch (myvar_GitVersion_Patch) : $myvar_GitVersion_Patch"
echo "SemVer (myvar_GitVersion_SemVer) : $myvar_GitVersion_SemVer"
echo "FullSemVer (myvar_GitVersion_FullSemVer) : $myvar_GitVersion_FullSemVer"
name: Use job variables (bash - outputs with prefix)
shell: bash
- run: |
echo "Major (localvar_major): $localvar_major"
echo "Minor (localvar_minor): $localvar_minor"
echo "Patch (localvar_patch): $localvar_patch"
echo "SemVer (localvar_semVer): $localvar_semVer"
echo "FullSemVer (localvar_fullSemVer): $localvar_fullSemVer"
name: Use local env mapped from output (bash - outputs with prefix)
shell: bash
env:
localvar_major: ${{ needs.GitVersion_v5_Job.outputs.GitVersion_Major }}
localvar_minor: ${{ needs.GitVersion_v5_Job.outputs.GitVersion_Minor }}
localvar_patch: ${{ needs.GitVersion_v5_Job.outputs.GitVersion_Patch }}
localvar_semVer: ${{ needs.GitVersion_v5_Job.outputs.GitVersion_SemVer }}
localvar_fullSemVer: ${{ needs.GitVersion_v5_Job.outputs.GitVersion_FullSemVer }}
- run: |
echo "Major (localvar_major) : $localvar_major"
echo "Minor (localvar_minor) : $localvar_minor"
echo "Patch (localvar_patch) : $localvar_patch"
echo "SemVer (localvar_semVer) : $localvar_semVer"
echo "FullSemVer (localvar_fullSemVer) : $localvar_fullSemVer"
name: Use local env mapped from job variables (bash - outputs with prefix)
shell: bash
env:
localvar_major: ${{ env.myvar_GitVersion_Major }}
localvar_minor: ${{ env.myvar_GitVersion_Minor }}
localvar_patch: ${{ env.myvar_GitVersion_Patch }}
localvar_semVer: ${{ env.myvar_GitVersion_SemVer }}
localvar_fullSemVer: ${{ env.myvar_GitVersion_FullSemVer }}
- run: |
echo "Major (needs.GitVersion_v5_Job.outputs.GitVersion_Major) : ${{ needs.GitVersion_v5_Job.outputs.GitVersion_Major }}"
echo "Minor (needs.GitVersion_v5_Job.outputs.GitVersion_Minor) : ${{ needs.GitVersion_v5_Job.outputs.GitVersion_Minor }}"
echo "Patch (needs.GitVersion_v5_Job.outputs.GitVersion_Patch) : ${{ needs.GitVersion_v5_Job.outputs.GitVersion_Patch }}"
echo "SemVer (needs.GitVersion_v5_Job.outputs.GitVersion_SemVer) : ${{ needs.GitVersion_v5_Job.outputs.GitVersion_SemVer }}"
echo "FullSemVer (needs.GitVersion_v5_Job.outputs.GitVersion_FullSemVer) : ${{ needs.GitVersion_v5_Job.outputs.GitVersion_FullSemVer }}"
name: Use direct output from previous job (bash - outputs with prefix)
shell: bash