Skip to content

Commit bdf14b4

Browse files
committed
Refactor CI workflow to standardize version output variables and update Docker image tagging logic. Changed output variable names to uppercase and introduced a new step for setting the version tag based on input conditions.
1 parent 5e52669 commit bdf14b4

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

.github/workflows/ci.yml

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,8 @@ jobs:
4242
runs-on: ubuntu-latest
4343

4444
outputs:
45-
semVer: ${{ steps.gitversion.outputs.semVer }}
46-
preReleaseLabel: ${{ steps.gitversion.outputs.PreReleaseLabel }}
47-
majorMinorPatch: ${{ steps.gitversion.outputs.MajorMinorPatch }}
48-
nuGetVersionV2: ${{ steps.gitversion.outputs.MajorMinorPatch }}
45+
SEMVER: ${{ steps.gitversion.outputs.semVer }}
46+
VERSION: ${{ steps.version-tag.outputs.VERSION }}
4947

5048
steps:
5149
- uses: actions/checkout@v4
@@ -70,6 +68,15 @@ jobs:
7068
updateAssemblyInfoFilename: src/AssemblyInfo.cs
7169
configFilePath: .github/.gitversion.yml
7270

71+
- name: Set version tag
72+
id: version-tag
73+
run: |
74+
if [ "${{ inputs.ga }}" = "true" ]; then
75+
echo "VERSION=${{ steps.gitversion.outputs.MajorMinorPatch }}" >> $GITHUB_OUTPUT
76+
else
77+
echo "VERSION=${{ steps.gitversion.outputs.AssemblySemVer }}" >> $GITHUB_OUTPUT
78+
fi
79+
7380
- name: Print AssemblyInfo
7481
run: cat src/AssemblyInfo.cs
7582

@@ -317,10 +324,8 @@ jobs:
317324
runs-on: ${{ matrix.os }}
318325
needs: [calc-version]
319326
env:
320-
NUGETVER: ${{ needs.calc-version.outputs.nuGetVersionV2 }}
321-
SEMVER: ${{ needs.calc-version.outputs.semVer }}
322-
PRERELEASELABEL: ${{ needs.calc-version.outputs.PreReleaseLabel }}
323-
MAJORMINORPATCH: ${{ needs.calc-version.outputs.MajorMinorPatch }}
327+
SEMVER: ${{ needs.calc-version.outputs.SEMVER }}
328+
VERSION: ${{ needs.calc-version.outputs.VERSION }}
324329
strategy:
325330
matrix:
326331
os: [ubuntu-latest]
@@ -402,7 +407,7 @@ jobs:
402407
if: ${{ (matrix.os == 'ubuntu-latest') }}
403408
run: |
404409
mkdir ~/nupkg
405-
dotnet pack -c ${{ env.BUILD_CONFIG }} -o ~/nupkg -p:PackageVersion=${{ env.NUGETVER }}
410+
dotnet pack -c ${{ env.BUILD_CONFIG }} -o ~/nupkg -p:PackageVersion=${{ env.VERSION }}
406411
ls -lR ~/nupkg
407412
working-directory: ./src/Api
408413

@@ -429,7 +434,7 @@ jobs:
429434
with:
430435
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
431436
tags: |
432-
type=raw,value=${{ inputs.ga == 'true' ? env.MAJORMINORPATCH : env.NUGETVER }}
437+
type=raw,value=${{ env.VERSION }}
433438
type=raw,value=latest,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }}
434439
435440
- name: Build and push Docker image
@@ -487,7 +492,7 @@ jobs:
487492
runs-on: windows-latest
488493
needs: [calc-version]
489494
env:
490-
SEMVER: ${{ needs.calc-version.outputs.SemVer }}
495+
SEMVER: ${{ needs.calc-version.outputs.SEMVER }}
491496
steps:
492497
- uses: actions/checkout@v4
493498
with:
@@ -568,9 +573,8 @@ jobs:
568573
runs-on: ubuntu-latest
569574
needs: [calc-version, unit-test, docs, integration-test, analyze]
570575
env:
571-
SEMVER: ${{ needs.calc-version.outputs.SemVer }}
572-
PRERELEASELABEL: ${{ needs.calc-version.outputs.PreReleaseLabel }}
573-
MAJORMINORPATCH: ${{ needs.calc-version.outputs.MajorMinorPatch }}
576+
SEMVER: ${{ needs.calc-version.outputs.SEMVER }}
577+
VERSION: ${{ needs.calc-version.outputs.VERSION }}
574578

575579
steps:
576580
- uses: actions/checkout@v4
@@ -630,8 +634,8 @@ jobs:
630634
token: ${{ secrets.GITHUB_TOKEN }}
631635
owner: ${{ steps.repo.outputs._0 }}
632636
repository: ${{ steps.repo.outputs._1 }}
633-
milestone: ${{ env.MAJORMINORPATCH }}
634-
name: "Release v${{ env.MAJORMINORPATCH }}"
637+
milestone: ${{ env.VERSION }}
638+
name: "Release v${{ env.VERSION }}"
635639
assets: |
636640
artifacts-cli/mig-cli-${{ env.SEMVER }}-linux-x64.zip
637641
artifacts-docs/mig-docs-${{ env.SEMVER }}.zip
@@ -642,12 +646,12 @@ jobs:
642646
token: ${{ secrets.GITHUB_TOKEN }}
643647
owner: ${{ steps.repo.outputs._0 }}
644648
repository: ${{ steps.repo.outputs._1 }}
645-
milestone: ${{ env.MAJORMINORPATCH }}
649+
milestone: ${{ env.VERSION }}
646650

647651
- name: Close release with GitReleaseManager
648652
uses: gittools/actions/gitreleasemanager/[email protected]
649653
with:
650654
token: ${{ secrets.GITHUB_TOKEN }}
651655
owner: ${{ steps.repo.outputs._0 }}
652656
repository: ${{ steps.repo.outputs._1 }}
653-
milestone: ${{ env.MAJORMINORPATCH }}
657+
milestone: ${{ env.VERSION }}

0 commit comments

Comments
 (0)