diff --git a/.azure/ci.yml b/.azure/ci.yml
index edfc7d796..ef020df90 100644
--- a/.azure/ci.yml
+++ b/.azure/ci.yml
@@ -71,6 +71,24 @@ jobs:
node gitversion/setup/main.mjs
displayName: gitversion/setup
workingDirectory: dist/vsix
+ - pwsh: |
+ # set the inputs for the 'gitversion/command' action
+ $env:INPUT_TARGETPATH = './'
+ $env:INPUT_ARGUMENTS = '/showvariable FullSemVer'
+
+ # run the 'gitversion/command' action
+ node gitversion/command/main.mjs
+ displayName: gitversion/command (showvariable)
+ workingDirectory: dist/vsix
+ - pwsh: |
+ # set the inputs for the 'gitversion/command' action
+ $env:INPUT_TARGETPATH = './'
+ $env:INPUT_ARGUMENTS = '/format {Major}.{Minor}'
+
+ # run the 'gitversion/command' action
+ node gitversion/command/main.mjs
+ displayName: gitversion/command (format)
+ workingDirectory: dist/vsix
- pwsh: |
# set the inputs for the 'gitversion/execute' action
$env:INPUT_TARGETPATH = './'
diff --git a/.azure/example-10.yml b/.azure/example-10.yml
deleted file mode 100644
index e1e6916f9..000000000
--- a/.azure/example-10.yml
+++ /dev/null
@@ -1,93 +0,0 @@
-trigger: none
-
-variables:
- - name: DOTNET_SKIP_FIRST_TIME_EXPERIENCE
- value: 'true'
- - name: DOTNET_CLI_TELEMETRY_OPTOUT
- value: 'true'
-
-stages:
- - stage: GitVersion_v6_cross_stage
- displayName: GitVersion v6 (cross stage)
- jobs:
- - job: GitVersion_v6_cross_stage_producer
- displayName: GitVersion v6 (cross stage producer)
- pool:
- vmImage: ubuntu-latest
- steps:
- - checkout: self
- fetchDepth: 0
-
- - task: gitversion/setup@2.0.1
- displayName: Install GitVersion
- inputs:
- versionSpec: '6.x'
-
- - task: gitversion/execute@2.0.1
- displayName: Determine Version
- name: version_step # step id used as reference for output values
- inputs:
- overrideConfig: |
- update-build-number=false
- - stage: GitVersion_v6_cross_stage_consumer_without_prefix
- displayName: GitVersion v6 (cross stage consumer) - without prefix
- dependsOn: GitVersion_v6_cross_stage
- condition: and(succeeded(), eq(dependencies.GitVersion_v6_cross_stage.outputs['GitVersion_v6_cross_stage_producer.version_step.branchName'], 'main')) # use in condition
- jobs:
- - job: GitVersion_v6_cross_stage_consumer_without_prefix
- displayName: GitVersion v6 (cross stage consumer) - without prefix
- variables:
- myvar_fullSemVer: $[ stageDependencies.GitVersion_v6_cross_stage.GitVersion_v6_cross_stage_producer.outputs['version_step.fullSemVer'] ]
- pool:
- vmImage: ubuntu-latest
- steps:
- - pwsh: |
- echo "FullSemVer (myvar_fullSemVer) : $(myvar_fullSemVer)"
- displayName: Use mapped job variables (pwsh - outputs without prefix)
-
- - pwsh: |
- echo "FullSemVer (env:localvar_fullSemVer) : $env:localvar_fullSemVer"
- displayName: Use mapped local env from job variables (pwsh - outputs without prefix)
- env:
- localvar_fullSemVer: $(myvar_fullSemVer)
-
- - bash: |
- echo "FullSemVer (myvar_fullSemVer) : $(myvar_fullSemVer)"
- displayName: Use mapped job variables (bash - outputs without prefix)
-
- - bash: |
- echo "FullSemVer (localvar_fullSemVer) : $localvar_fullSemVer"
- displayName: Use mapped local env from job variables (bash - outputs without prefix)
- env:
- localvar_fullSemVer: $(myvar_fullSemVer)
- - stage: GitVersion_v6_cross_stage_consumer_with_prefix
- displayName: GitVersion v6 (cross stage consumer) - with prefix
- dependsOn: GitVersion_v6_cross_stage
- condition: and(succeeded(), eq(dependencies.GitVersion_v6_cross_stage.outputs['GitVersion_v6_cross_stage_producer.version_step.GitVersion_BranchName'], 'main')) # use in condition
- jobs:
- - job: GitVersion_v6_cross_stage_consumer_with_prefix
- displayName: GitVersion v6 (cross stage consumer) - with prefix
- variables:
- myvar_GitVersion_FullSemVer: $[ stageDependencies.GitVersion_v6_cross_stage.GitVersion_v6_cross_stage_producer.outputs['version_step.GitVersion_FullSemVer'] ]
- pool:
- vmImage: ubuntu-latest
- steps:
- - pwsh: |
- echo "FullSemVer (myvar_GitVersion_FullSemVer) : $(myvar_GitVersion_FullSemVer)"
- displayName: Use mapped job variables (pwsh - outputs with prefix)
-
- - pwsh: |
- echo "FullSemVer (env:localvar_GitVersion_FullSemVer) : $env:localvar_GitVersion_FullSemVer"
- displayName: Use mapped local env from job variables (pwsh - outputs with prefix)
- env:
- localvar_GitVersion_FullSemVer: $(myvar_GitVersion_FullSemVer)
-
- - bash: |
- echo "FullSemVer (localvar_GitVersion_FullSemVer) : $localvar_GitVersion_FullSemVer"
- displayName: Use mapped job variables (bash - outputs with prefix)
-
- - bash: |
- echo "FullSemVer (localvar_GitVersion_FullSemVer) : $localvar_GitVersion_FullSemVer"
- displayName: Use mapped local env from job variables (bash - outputs with prefix)
- env:
- localvar_GitVersion_FullSemVer: $(myvar_GitVersion_FullSemVer)
diff --git a/.azure/example-7.yml b/.azure/example-7.yml
new file mode 100644
index 000000000..3e36caf23
--- /dev/null
+++ b/.azure/example-7.yml
@@ -0,0 +1,68 @@
+trigger: none
+
+variables:
+ - name: DOTNET_SKIP_FIRST_TIME_EXPERIENCE
+ value: 'true'
+ - name: DOTNET_CLI_TELEMETRY_OPTOUT
+ value: 'true'
+
+jobs:
+ - job: GitVersion_v6_same_job
+ displayName: GitVersion v6 (same job)
+ pool:
+ vmImage: ubuntu-latest
+ steps:
+ - checkout: self
+ fetchDepth: 0
+
+ - task: gitversion/setup@2.0.1
+ displayName: Install GitVersion
+ inputs:
+ versionSpec: '6.x'
+
+ - task: gitversion/execute@2.0.1
+ displayName: Determine Version
+ name: version_step # step id used as reference for output values
+ inputs:
+ overrideConfig: |
+ update-build-number=false
+
+ - pwsh: |
+ echo "FullSemVer (fullSemVer) : $(fullSemVer)"
+ displayName: Display GitVersion variables (without prefix)
+
+ - pwsh: |
+ echo "FullSemVer (GitVersion_FullSemVer) : $(GitVersion_FullSemVer)"
+ displayName: Display GitVersion variables (with prefix)
+
+ - pwsh: |
+ echo "FullSemVer (version_step.fullSemVer) : $(version_step.fullSemVer)"
+ displayName: Display GitVersion outputs (step output without prefix)
+
+ - pwsh: |
+ echo "FullSemVer (version_step.GitVersion_FullSemVer) : $(version_step.GitVersion_FullSemVer)"
+ displayName: Display GitVersion outputs (step output with prefix)
+
+ - pwsh: |
+ echo "FullSemVer (env:myvar_fullSemVer) : $env:myvar_fullSemVer"
+ displayName: Display mapped local env (pwsh - outputs without prefix)
+ env:
+ myvar_fullSemVer: $(version_step.fullSemVer)
+
+ - pwsh: |
+ echo "FullSemVer (env:myvar_GitVersion_FullSemVer) : $env:myvar_GitVersion_FullSemVer"
+ displayName: Display mapped local env (pwsh - outputs with prefix)
+ env:
+ myvar_GitVersion_FullSemVer: $(version_step.GitVersion_FullSemVer)
+
+ - bash: |
+ echo "FullSemVer (myvar_fullSemVer) : $myvar_fullSemVer"
+ displayName: Display mapped local env (bash - outputs without prefix)
+ env:
+ myvar_fullSemVer: $(version_step.fullSemVer)
+
+ - bash: |
+ echo "FullSemVer (myvar_GitVersion_FullSemVer) : $myvar_GitVersion_FullSemVer"
+ displayName: Display mapped local env (bash - outputs with prefix)
+ env:
+ myvar_GitVersion_FullSemVer: $(version_step.GitVersion_FullSemVer)
diff --git a/.azure/example-8.yml b/.azure/example-8.yml
index 3e36caf23..fac7ca029 100644
--- a/.azure/example-8.yml
+++ b/.azure/example-8.yml
@@ -7,8 +7,8 @@ variables:
value: 'true'
jobs:
- - job: GitVersion_v6_same_job
- displayName: GitVersion v6 (same job)
+ - job: GitVersion_v6_cross_job
+ displayName: GitVersion v6 (cross job)
pool:
vmImage: ubuntu-latest
steps:
@@ -27,42 +27,60 @@ jobs:
overrideConfig: |
update-build-number=false
+ - job: GitVersion_v6_cross_job_consumer_without_prefix
+ displayName: GitVersion v6 (cross job consumer) - without prefix
+ dependsOn: GitVersion_v6_cross_job
+ condition: and(succeeded(), eq(dependencies.GitVersion_v6_cross_job.outputs['version_step.branchName'], 'main')) # use in condition
+ variables:
+ myvar_fullSemVer: $[ dependencies.GitVersion_v6_cross_job.outputs['version_step.fullSemVer'] ]
+ pool:
+ vmImage: ubuntu-latest
+ steps:
- pwsh: |
- echo "FullSemVer (fullSemVer) : $(fullSemVer)"
- displayName: Display GitVersion variables (without prefix)
+ echo "FullSemVer (myvar_fullSemVer) : $(myvar_fullSemVer)"
+ displayName: Use mapped job variables (pwsh - outputs without prefix)
- pwsh: |
- echo "FullSemVer (GitVersion_FullSemVer) : $(GitVersion_FullSemVer)"
- displayName: Display GitVersion variables (with prefix)
+ echo "FullSemVer (env:localvar_fullSemVer) : $env:localvar_fullSemVer"
+ displayName: Use mapped local env from job variables (pwsh - outputs without prefix)
+ env:
+ localvar_fullSemVer: $(myvar_fullSemVer)
- - pwsh: |
- echo "FullSemVer (version_step.fullSemVer) : $(version_step.fullSemVer)"
- displayName: Display GitVersion outputs (step output without prefix)
+ - bash: |
+ echo "FullSemVer (myvar_fullSemVer) : $(myvar_fullSemVer)"
+ displayName: Use mapped job variables (bash - outputs without prefix)
- - pwsh: |
- echo "FullSemVer (version_step.GitVersion_FullSemVer) : $(version_step.GitVersion_FullSemVer)"
- displayName: Display GitVersion outputs (step output with prefix)
+ - bash: |
+ echo "FullSemVer (localvar_fullSemVer) : $localvar_fullSemVer"
+ displayName: Use mapped local env from job variables (bash - outputs without prefix)
+ env:
+ localvar_fullSemVer: $(myvar_fullSemVer)
+ - job: GitVersion_v6_cross_job_consumer_with_prefix
+ displayName: GitVersion v6 (cross job consumer) - with prefix
+ dependsOn: GitVersion_v6_cross_job
+ condition: and(succeeded(), eq(dependencies.GitVersion_v6_cross_job.outputs['version_step.GitVersion_BranchName'], 'main')) # use in condition
+ variables:
+ myvar_GitVersion_FullSemVer: $[ dependencies.GitVersion_v6_cross_job.outputs['version_step.GitVersion_FullSemVer'] ]
+ pool:
+ vmImage: ubuntu-latest
+ steps:
- pwsh: |
- echo "FullSemVer (env:myvar_fullSemVer) : $env:myvar_fullSemVer"
- displayName: Display mapped local env (pwsh - outputs without prefix)
- env:
- myvar_fullSemVer: $(version_step.fullSemVer)
+ echo "FullSemVer (myvar_GitVersion_FullSemVer) : $(myvar_GitVersion_FullSemVer)"
+ displayName: Use mapped job variables (pwsh - outputs with prefix)
- pwsh: |
- echo "FullSemVer (env:myvar_GitVersion_FullSemVer) : $env:myvar_GitVersion_FullSemVer"
- displayName: Display mapped local env (pwsh - outputs with prefix)
+ echo "FullSemVer (env:localvar_GitVersion_FullSemVer) : $env:localvar_GitVersion_FullSemVer"
+ displayName: Use mapped local env from job variables (pwsh - outputs with prefix)
env:
- myvar_GitVersion_FullSemVer: $(version_step.GitVersion_FullSemVer)
+ localvar_GitVersion_FullSemVer: $(myvar_GitVersion_FullSemVer)
- bash: |
- echo "FullSemVer (myvar_fullSemVer) : $myvar_fullSemVer"
- displayName: Display mapped local env (bash - outputs without prefix)
- env:
- myvar_fullSemVer: $(version_step.fullSemVer)
+ echo "FullSemVer (myvar_GitVersion_FullSemVer) : $(myvar_GitVersion_FullSemVer)"
+ displayName: Use mapped job variables (bash - outputs with prefix)
- bash: |
- echo "FullSemVer (myvar_GitVersion_FullSemVer) : $myvar_GitVersion_FullSemVer"
- displayName: Display mapped local env (bash - outputs with prefix)
+ echo "FullSemVer (localvar_GitVersion_FullSemVer) : $localvar_GitVersion_FullSemVer"
+ displayName: Use mapped local env from job variables (bash - outputs with prefix)
env:
- myvar_GitVersion_FullSemVer: $(version_step.GitVersion_FullSemVer)
+ localvar_GitVersion_FullSemVer: $(myvar_GitVersion_FullSemVer)
diff --git a/.azure/example-9.yml b/.azure/example-9.yml
index fac7ca029..e1e6916f9 100644
--- a/.azure/example-9.yml
+++ b/.azure/example-9.yml
@@ -6,81 +6,88 @@ variables:
- name: DOTNET_CLI_TELEMETRY_OPTOUT
value: 'true'
-jobs:
- - job: GitVersion_v6_cross_job
- displayName: GitVersion v6 (cross job)
- pool:
- vmImage: ubuntu-latest
- steps:
- - checkout: self
- fetchDepth: 0
+stages:
+ - stage: GitVersion_v6_cross_stage
+ displayName: GitVersion v6 (cross stage)
+ jobs:
+ - job: GitVersion_v6_cross_stage_producer
+ displayName: GitVersion v6 (cross stage producer)
+ pool:
+ vmImage: ubuntu-latest
+ steps:
+ - checkout: self
+ fetchDepth: 0
- - task: gitversion/setup@2.0.1
- displayName: Install GitVersion
- inputs:
- versionSpec: '6.x'
+ - task: gitversion/setup@2.0.1
+ displayName: Install GitVersion
+ inputs:
+ versionSpec: '6.x'
- - task: gitversion/execute@2.0.1
- displayName: Determine Version
- name: version_step # step id used as reference for output values
- inputs:
- overrideConfig: |
- update-build-number=false
+ - task: gitversion/execute@2.0.1
+ displayName: Determine Version
+ name: version_step # step id used as reference for output values
+ inputs:
+ overrideConfig: |
+ update-build-number=false
+ - stage: GitVersion_v6_cross_stage_consumer_without_prefix
+ displayName: GitVersion v6 (cross stage consumer) - without prefix
+ dependsOn: GitVersion_v6_cross_stage
+ condition: and(succeeded(), eq(dependencies.GitVersion_v6_cross_stage.outputs['GitVersion_v6_cross_stage_producer.version_step.branchName'], 'main')) # use in condition
+ jobs:
+ - job: GitVersion_v6_cross_stage_consumer_without_prefix
+ displayName: GitVersion v6 (cross stage consumer) - without prefix
+ variables:
+ myvar_fullSemVer: $[ stageDependencies.GitVersion_v6_cross_stage.GitVersion_v6_cross_stage_producer.outputs['version_step.fullSemVer'] ]
+ pool:
+ vmImage: ubuntu-latest
+ steps:
+ - pwsh: |
+ echo "FullSemVer (myvar_fullSemVer) : $(myvar_fullSemVer)"
+ displayName: Use mapped job variables (pwsh - outputs without prefix)
- - job: GitVersion_v6_cross_job_consumer_without_prefix
- displayName: GitVersion v6 (cross job consumer) - without prefix
- dependsOn: GitVersion_v6_cross_job
- condition: and(succeeded(), eq(dependencies.GitVersion_v6_cross_job.outputs['version_step.branchName'], 'main')) # use in condition
- variables:
- myvar_fullSemVer: $[ dependencies.GitVersion_v6_cross_job.outputs['version_step.fullSemVer'] ]
- pool:
- vmImage: ubuntu-latest
- steps:
- - pwsh: |
- echo "FullSemVer (myvar_fullSemVer) : $(myvar_fullSemVer)"
- displayName: Use mapped job variables (pwsh - outputs without prefix)
+ - pwsh: |
+ echo "FullSemVer (env:localvar_fullSemVer) : $env:localvar_fullSemVer"
+ displayName: Use mapped local env from job variables (pwsh - outputs without prefix)
+ env:
+ localvar_fullSemVer: $(myvar_fullSemVer)
- - pwsh: |
- echo "FullSemVer (env:localvar_fullSemVer) : $env:localvar_fullSemVer"
- displayName: Use mapped local env from job variables (pwsh - outputs without prefix)
- env:
- localvar_fullSemVer: $(myvar_fullSemVer)
+ - bash: |
+ echo "FullSemVer (myvar_fullSemVer) : $(myvar_fullSemVer)"
+ displayName: Use mapped job variables (bash - outputs without prefix)
- - bash: |
- echo "FullSemVer (myvar_fullSemVer) : $(myvar_fullSemVer)"
- displayName: Use mapped job variables (bash - outputs without prefix)
+ - bash: |
+ echo "FullSemVer (localvar_fullSemVer) : $localvar_fullSemVer"
+ displayName: Use mapped local env from job variables (bash - outputs without prefix)
+ env:
+ localvar_fullSemVer: $(myvar_fullSemVer)
+ - stage: GitVersion_v6_cross_stage_consumer_with_prefix
+ displayName: GitVersion v6 (cross stage consumer) - with prefix
+ dependsOn: GitVersion_v6_cross_stage
+ condition: and(succeeded(), eq(dependencies.GitVersion_v6_cross_stage.outputs['GitVersion_v6_cross_stage_producer.version_step.GitVersion_BranchName'], 'main')) # use in condition
+ jobs:
+ - job: GitVersion_v6_cross_stage_consumer_with_prefix
+ displayName: GitVersion v6 (cross stage consumer) - with prefix
+ variables:
+ myvar_GitVersion_FullSemVer: $[ stageDependencies.GitVersion_v6_cross_stage.GitVersion_v6_cross_stage_producer.outputs['version_step.GitVersion_FullSemVer'] ]
+ pool:
+ vmImage: ubuntu-latest
+ steps:
+ - pwsh: |
+ echo "FullSemVer (myvar_GitVersion_FullSemVer) : $(myvar_GitVersion_FullSemVer)"
+ displayName: Use mapped job variables (pwsh - outputs with prefix)
- - bash: |
- echo "FullSemVer (localvar_fullSemVer) : $localvar_fullSemVer"
- displayName: Use mapped local env from job variables (bash - outputs without prefix)
- env:
- localvar_fullSemVer: $(myvar_fullSemVer)
+ - pwsh: |
+ echo "FullSemVer (env:localvar_GitVersion_FullSemVer) : $env:localvar_GitVersion_FullSemVer"
+ displayName: Use mapped local env from job variables (pwsh - outputs with prefix)
+ env:
+ localvar_GitVersion_FullSemVer: $(myvar_GitVersion_FullSemVer)
- - job: GitVersion_v6_cross_job_consumer_with_prefix
- displayName: GitVersion v6 (cross job consumer) - with prefix
- dependsOn: GitVersion_v6_cross_job
- condition: and(succeeded(), eq(dependencies.GitVersion_v6_cross_job.outputs['version_step.GitVersion_BranchName'], 'main')) # use in condition
- variables:
- myvar_GitVersion_FullSemVer: $[ dependencies.GitVersion_v6_cross_job.outputs['version_step.GitVersion_FullSemVer'] ]
- pool:
- vmImage: ubuntu-latest
- steps:
- - pwsh: |
- echo "FullSemVer (myvar_GitVersion_FullSemVer) : $(myvar_GitVersion_FullSemVer)"
- displayName: Use mapped job variables (pwsh - outputs with prefix)
+ - bash: |
+ echo "FullSemVer (localvar_GitVersion_FullSemVer) : $localvar_GitVersion_FullSemVer"
+ displayName: Use mapped job variables (bash - outputs with prefix)
- - pwsh: |
- echo "FullSemVer (env:localvar_GitVersion_FullSemVer) : $env:localvar_GitVersion_FullSemVer"
- displayName: Use mapped local env from job variables (pwsh - outputs with prefix)
- env:
- localvar_GitVersion_FullSemVer: $(myvar_GitVersion_FullSemVer)
-
- - bash: |
- echo "FullSemVer (myvar_GitVersion_FullSemVer) : $(myvar_GitVersion_FullSemVer)"
- displayName: Use mapped job variables (bash - outputs with prefix)
-
- - bash: |
- echo "FullSemVer (localvar_GitVersion_FullSemVer) : $localvar_GitVersion_FullSemVer"
- displayName: Use mapped local env from job variables (bash - outputs with prefix)
- env:
- localvar_GitVersion_FullSemVer: $(myvar_GitVersion_FullSemVer)
+ - bash: |
+ echo "FullSemVer (localvar_GitVersion_FullSemVer) : $localvar_GitVersion_FullSemVer"
+ displayName: Use mapped local env from job variables (bash - outputs with prefix)
+ env:
+ localvar_GitVersion_FullSemVer: $(myvar_GitVersion_FullSemVer)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 287c89dbf..d87ebe1a0 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -54,6 +54,14 @@ jobs:
uses: ./gitversion/setup
with:
versionSpec: '6.x'
+ - name: gitversion/command (showvariable)
+ uses: ./gitversion/command
+ with:
+ arguments: '/showvariable FullSemVer'
+ - name: gitversion/command (format)
+ uses: ./gitversion/command
+ with:
+ arguments: '/format {Major}.{Minor}'
- name: gitversion/execute
id: gitversion # step id used as reference for output values
uses: ./gitversion/execute
diff --git a/.github/workflows/example-7.yml b/.github/workflows/example-7.yml
new file mode 100644
index 000000000..21893dfec
--- /dev/null
+++ b/.github/workflows/example-7.yml
@@ -0,0 +1,82 @@
+name: example-7
+on:
+ workflow_dispatch:
+
+defaults:
+ run:
+ shell: pwsh
+
+jobs:
+ GitVersion_v6_same_job:
+ name: GitVersion v6 (same job)
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+
+ - name: Install GitVersion
+ uses: gittools/actions/gitversion/setup@v2.0.1
+ with:
+ versionSpec: '6.x'
+
+ - name: Determine Version
+ id: version_step # step id used as reference for output values
+ uses: gittools/actions/gitversion/execute@v2.0.1
+
+ - run: |
+ echo "FullSemVer (env.fullSemVer) : ${{ env.fullSemVer }}"
+ name: Display GitVersion variables (without prefix)
+
+ - run: |
+ echo "FullSemVer (env.GitVersion_FullSemVer) : ${{ env.GitVersion_FullSemVer }}"
+ name: Display GitVersion variables (with prefix)
+
+ - run: |
+ echo "FullSemVer (steps.version_step.outputs.fullSemVer) : ${{ steps.version_step.outputs.fullSemVer }}"
+ name: Display GitVersion outputs (step output without prefix)
+
+ - run: |
+ echo "FullSemVer (steps.version_step.outputs.GitVersion_FullSemVer) : ${{ steps.version_step.outputs.GitVersion_FullSemVer }}"
+ name: Display GitVersion outputs (step output with prefix)
+
+ - run: |
+ echo "FullSemVer (env.myvar_fullSemVer) : ${{ env.myvar_fullSemVer }}"
+ name: Display mapped local env (outputs without prefix)
+ env:
+ myvar_fullSemVer: ${{ steps.version_step.outputs.fullSemVer }}
+
+ - run: |
+ echo "FullSemVer (env.myvar_GitVersion_FullSemVer) : ${{ env.myvar_GitVersion_FullSemVer }}"
+ name: Display mapped local env (outputs with prefix)
+ env:
+ myvar_GitVersion_FullSemVer: ${{ steps.version_step.outputs.GitVersion_FullSemVer }}
+
+ - run: |
+ echo "FullSemVer (env.myvar_fullSemVer) : $env:myvar_fullSemVer"
+ name: Display mapped local env (pwsh - outputs without prefix)
+ shell: pwsh
+ env:
+ myvar_fullSemVer: ${{ steps.version_step.outputs.fullSemVer }}
+
+ - run: |
+ echo "FullSemVer (env.myvar_GitVersion_FullSemVer) : $env:myvar_GitVersion_FullSemVer"
+ name: Display mapped local env (pwsh - outputs with prefix)
+ shell: pwsh
+ env:
+ myvar_GitVersion_FullSemVer: ${{ steps.version_step.outputs.GitVersion_FullSemVer }}
+
+ - run: |
+ echo "FullSemVer (myvar_fullSemVer) : $myvar_fullSemVer"
+ name: Display mapped local env (bash - outputs without prefix)
+ shell: bash
+ env:
+ myvar_fullSemVer: ${{ steps.version_step.outputs.fullSemVer }}
+
+ - run: |
+ echo "FullSemVer (myvar_GitVersion_FullSemVer) : $myvar_GitVersion_FullSemVer"
+ name: Display mapped local env (bash - outputs with prefix)
+ shell: bash
+ env:
+ myvar_GitVersion_FullSemVer: ${{ steps.version_step.outputs.GitVersion_FullSemVer }}
diff --git a/.github/workflows/example-8.yml b/.github/workflows/example-8.yml
index b097b8d2d..aad0eeadd 100644
--- a/.github/workflows/example-8.yml
+++ b/.github/workflows/example-8.yml
@@ -7,9 +7,15 @@ defaults:
shell: pwsh
jobs:
- GitVersion_v6_same_job:
- name: GitVersion v6 (same job)
+ GitVersion_v6_cross_job:
+ name: GitVersion v6 (cross job)
runs-on: ubuntu-latest
+ outputs:
+ branchName: ${{ steps.version_step.outputs.branchName }}
+ fullSemVer: ${{ steps.version_step.outputs.fullSemVer }}
+
+ GitVersion_BranchName: ${{ steps.version_step.outputs.GitVersion_BranchName }}
+ GitVersion_FullSemVer: ${{ steps.version_step.outputs.GitVersion_FullSemVer }}
steps:
- name: Checkout
uses: actions/checkout@v4
@@ -25,58 +31,114 @@ jobs:
id: version_step # step id used as reference for output values
uses: gittools/actions/gitversion/execute@v2.0.1
+ GitVersion_v6_cross_job_consumer_without_prefix:
+ name: GitVersion v6 (cross job consumer) - without prefix
+ needs: GitVersion_v6_cross_job
+ runs-on: ubuntu-latest
+ if: contains(needs.GitVersion_v6_cross_job.outputs['branchName'], 'main')
+ env:
+ myvar_fullSemVer: ${{ needs.GitVersion_v6_cross_job.outputs.fullSemVer }}
+ steps:
+ - run: |
+ echo "FullSemVer (env:myvar_fullSemVer) : $env:myvar_fullSemVer"
+ name: Use job variables (pwsh - outputs without prefix)
+ shell: pwsh
+
- run: |
- echo "FullSemVer (env.fullSemVer) : ${{ env.fullSemVer }}"
- name: Display GitVersion variables (without prefix)
+ echo "FullSemVer (env:localvar_fullSemVer): $env:localvar_fullSemVer"
+ name: Use local env mapped from output (pwsh - outputs without prefix)
+ shell: pwsh
+ env:
+ localvar_fullSemVer: ${{ needs.GitVersion_v6_cross_job.outputs.fullSemVer }}
- run: |
- echo "FullSemVer (env.GitVersion_FullSemVer) : ${{ env.GitVersion_FullSemVer }}"
- name: Display GitVersion variables (with prefix)
+ echo "FullSemVer (env:localvar_fullSemVer) : $env:localvar_fullSemVer"
+ name: Use local env mapped from job variables (pwsh - outputs without prefix)
+ shell: pwsh
+ env:
+ localvar_fullSemVer: ${{ env.myvar_fullSemVer }}
- run: |
- echo "FullSemVer (steps.version_step.outputs.fullSemVer) : ${{ steps.version_step.outputs.fullSemVer }}"
- name: Display GitVersion outputs (step output without prefix)
+ echo "FullSemVer (needs.GitVersion_v6_cross_job.outputs.fullSemVer) : ${{ needs.GitVersion_v6_cross_job.outputs.fullSemVer }}"
+ name: Use direct output from previous job (pwsh - outputs without prefix)
+ shell: pwsh
- run: |
- echo "FullSemVer (steps.version_step.outputs.GitVersion_FullSemVer) : ${{ steps.version_step.outputs.GitVersion_FullSemVer }}"
- name: Display GitVersion outputs (step output with prefix)
+ echo "FullSemVer (myvar_fullSemVer) : $myvar_fullSemVer"
+ name: Use job variables (bash - outputs without prefix)
+ shell: bash
- run: |
- echo "FullSemVer (env.myvar_fullSemVer) : ${{ env.myvar_fullSemVer }}"
- name: Display mapped local env (outputs without prefix)
+ echo "FullSemVer (localvar_fullSemVer): $localvar_fullSemVer"
+ name: Use local env mapped from output (bash - outputs without prefix)
+ shell: bash
env:
- myvar_fullSemVer: ${{ steps.version_step.outputs.fullSemVer }}
+ localvar_fullSemVer: ${{ needs.GitVersion_v6_cross_job.outputs.fullSemVer }}
- run: |
- echo "FullSemVer (env.myvar_GitVersion_FullSemVer) : ${{ env.myvar_GitVersion_FullSemVer }}"
- name: Display mapped local env (outputs with prefix)
+ echo "FullSemVer (localvar_fullSemVer) : $localvar_fullSemVer"
+ name: Use local env mapped from job variables (bash - outputs without prefix)
+ shell: bash
env:
- myvar_GitVersion_FullSemVer: ${{ steps.version_step.outputs.GitVersion_FullSemVer }}
+ localvar_fullSemVer: ${{ env.myvar_fullSemVer }}
- run: |
- echo "FullSemVer (env.myvar_fullSemVer) : $env:myvar_fullSemVer"
- name: Display mapped local env (pwsh - outputs without prefix)
+ echo "FullSemVer (needs.GitVersion_v6_cross_job.outputs.fullSemVer) : ${{ needs.GitVersion_v6_cross_job.outputs.fullSemVer }}"
+ name: Use direct output from previous job (bash - outputs without prefix)
+ shell: bash
+
+ GitVersion_v6_cross_job_consumer_with_prefix:
+ name: GitVersion v6 (cross job consumer) - with prefix
+ needs: GitVersion_v6_cross_job
+ runs-on: ubuntu-latest
+ if: contains(needs.GitVersion_v6_cross_job.outputs['GitVersion_BranchName'], 'main')
+ env:
+ myvar_GitVersion_FullSemVer: ${{ needs.GitVersion_v6_cross_job.outputs.GitVersion_FullSemVer }}
+ steps:
+ - run: |
+ echo "FullSemVer (env:myvar_GitVersion_FullSemVer) : $env:myvar_GitVersion_FullSemVer"
+ name: Use job variables (pwsh - outputs without prefix)
+ shell: pwsh
+
+ - run: |
+ echo "FullSemVer (env:localvar_fullSemVer): $env:localvar_fullSemVer"
+ name: Use local env mapped from output (pwsh - outputs without prefix)
shell: pwsh
env:
- myvar_fullSemVer: ${{ steps.version_step.outputs.fullSemVer }}
+ localvar_fullSemVer: ${{ needs.GitVersion_v6_cross_job.outputs.GitVersion_FullSemVer }}
- run: |
- echo "FullSemVer (env.myvar_GitVersion_FullSemVer) : $env:myvar_GitVersion_FullSemVer"
- name: Display mapped local env (pwsh - outputs with prefix)
+ echo "FullSemVer (env:localvar_fullSemVer) : $env:localvar_fullSemVer"
+ name: Use local env mapped from job variables (pwsh - outputs without prefix)
shell: pwsh
env:
- myvar_GitVersion_FullSemVer: ${{ steps.version_step.outputs.GitVersion_FullSemVer }}
+ localvar_fullSemVer: ${{ env.myvar_GitVersion_FullSemVer }}
- run: |
- echo "FullSemVer (myvar_fullSemVer) : $myvar_fullSemVer"
- name: Display mapped local env (bash - outputs without prefix)
+ echo "FullSemVer (needs.GitVersion_v6_cross_job.outputs.GitVersion_FullSemVer) : ${{ needs.GitVersion_v6_cross_job.outputs.GitVersion_FullSemVer }}"
+ name: Use direct output from previous job (pwsh - outputs without prefix)
+ shell: pwsh
+
+ - run: |
+ echo "FullSemVer (myvar_GitVersion_FullSemVer) : $myvar_GitVersion_FullSemVer"
+ name: Use job variables (bash - outputs without prefix)
+ shell: bash
+
+ - run: |
+ echo "FullSemVer (localvar_fullSemVer): $localvar_fullSemVer"
+ name: Use local env mapped from output (bash - outputs without prefix)
shell: bash
env:
- myvar_fullSemVer: ${{ steps.version_step.outputs.fullSemVer }}
+ localvar_fullSemVer: ${{ needs.GitVersion_v6_cross_job.outputs.GitVersion_FullSemVer }}
- run: |
- echo "FullSemVer (myvar_GitVersion_FullSemVer) : $myvar_GitVersion_FullSemVer"
- name: Display mapped local env (bash - outputs with prefix)
+ echo "FullSemVer (localvar_fullSemVer) : $localvar_fullSemVer"
+ name: Use local env mapped from job variables (bash - outputs without prefix)
shell: bash
env:
- myvar_GitVersion_FullSemVer: ${{ steps.version_step.outputs.GitVersion_FullSemVer }}
+ localvar_fullSemVer: ${{ env.myvar_GitVersion_FullSemVer }}
+
+ - run: |
+ echo "FullSemVer (needs.GitVersion_v6_cross_job.outputs.GitVersion_FullSemVer) : ${{ needs.GitVersion_v6_cross_job.outputs.GitVersion_FullSemVer }}"
+ name: Use direct output from previous job (bash - outputs without prefix)
+ shell: bash
diff --git a/.github/workflows/example-9.yml b/.github/workflows/example-9.yml
deleted file mode 100644
index 9746c0d28..000000000
--- a/.github/workflows/example-9.yml
+++ /dev/null
@@ -1,144 +0,0 @@
-name: example-9
-on:
- workflow_dispatch:
-
-defaults:
- run:
- shell: pwsh
-
-jobs:
- GitVersion_v6_cross_job:
- name: GitVersion v6 (cross job)
- runs-on: ubuntu-latest
- outputs:
- branchName: ${{ steps.version_step.outputs.branchName }}
- fullSemVer: ${{ steps.version_step.outputs.fullSemVer }}
-
- GitVersion_BranchName: ${{ steps.version_step.outputs.GitVersion_BranchName }}
- GitVersion_FullSemVer: ${{ steps.version_step.outputs.GitVersion_FullSemVer }}
- steps:
- - name: Checkout
- uses: actions/checkout@v4
- with:
- fetch-depth: 0
-
- - name: Install GitVersion
- uses: gittools/actions/gitversion/setup@v2.0.1
- with:
- versionSpec: '6.x'
-
- - name: Determine Version
- id: version_step # step id used as reference for output values
- uses: gittools/actions/gitversion/execute@v2.0.1
-
- GitVersion_v6_cross_job_consumer_without_prefix:
- name: GitVersion v6 (cross job consumer) - without prefix
- needs: GitVersion_v6_cross_job
- runs-on: ubuntu-latest
- if: contains(needs.GitVersion_v6_cross_job.outputs['branchName'], 'main')
- env:
- myvar_fullSemVer: ${{ needs.GitVersion_v6_cross_job.outputs.fullSemVer }}
- steps:
- - run: |
- echo "FullSemVer (env:myvar_fullSemVer) : $env:myvar_fullSemVer"
- name: Use job variables (pwsh - outputs without prefix)
- shell: pwsh
-
- - run: |
- echo "FullSemVer (env:localvar_fullSemVer): $env:localvar_fullSemVer"
- name: Use local env mapped from output (pwsh - outputs without prefix)
- shell: pwsh
- env:
- localvar_fullSemVer: ${{ needs.GitVersion_v6_cross_job.outputs.fullSemVer }}
-
- - run: |
- echo "FullSemVer (env:localvar_fullSemVer) : $env:localvar_fullSemVer"
- name: Use local env mapped from job variables (pwsh - outputs without prefix)
- shell: pwsh
- env:
- localvar_fullSemVer: ${{ env.myvar_fullSemVer }}
-
- - run: |
- echo "FullSemVer (needs.GitVersion_v6_cross_job.outputs.fullSemVer) : ${{ needs.GitVersion_v6_cross_job.outputs.fullSemVer }}"
- name: Use direct output from previous job (pwsh - outputs without prefix)
- shell: pwsh
-
- - run: |
- echo "FullSemVer (myvar_fullSemVer) : $myvar_fullSemVer"
- name: Use job variables (bash - outputs without prefix)
- shell: bash
-
- - run: |
- echo "FullSemVer (localvar_fullSemVer): $localvar_fullSemVer"
- name: Use local env mapped from output (bash - outputs without prefix)
- shell: bash
- env:
- localvar_fullSemVer: ${{ needs.GitVersion_v6_cross_job.outputs.fullSemVer }}
-
- - run: |
- echo "FullSemVer (localvar_fullSemVer) : $localvar_fullSemVer"
- name: Use local env mapped from job variables (bash - outputs without prefix)
- shell: bash
- env:
- localvar_fullSemVer: ${{ env.myvar_fullSemVer }}
-
- - run: |
- echo "FullSemVer (needs.GitVersion_v6_cross_job.outputs.fullSemVer) : ${{ needs.GitVersion_v6_cross_job.outputs.fullSemVer }}"
- name: Use direct output from previous job (bash - outputs without prefix)
- shell: bash
-
- GitVersion_v6_cross_job_consumer_with_prefix:
- name: GitVersion v6 (cross job consumer) - with prefix
- needs: GitVersion_v6_cross_job
- runs-on: ubuntu-latest
- if: contains(needs.GitVersion_v6_cross_job.outputs['GitVersion_BranchName'], 'main')
- env:
- myvar_GitVersion_FullSemVer: ${{ needs.GitVersion_v6_cross_job.outputs.GitVersion_FullSemVer }}
- steps:
- - run: |
- echo "FullSemVer (env:myvar_GitVersion_FullSemVer) : $env:myvar_GitVersion_FullSemVer"
- name: Use job variables (pwsh - outputs without prefix)
- shell: pwsh
-
- - run: |
- echo "FullSemVer (env:localvar_fullSemVer): $env:localvar_fullSemVer"
- name: Use local env mapped from output (pwsh - outputs without prefix)
- shell: pwsh
- env:
- localvar_fullSemVer: ${{ needs.GitVersion_v6_cross_job.outputs.GitVersion_FullSemVer }}
-
- - run: |
- echo "FullSemVer (env:localvar_fullSemVer) : $env:localvar_fullSemVer"
- name: Use local env mapped from job variables (pwsh - outputs without prefix)
- shell: pwsh
- env:
- localvar_fullSemVer: ${{ env.myvar_GitVersion_FullSemVer }}
-
- - run: |
- echo "FullSemVer (needs.GitVersion_v6_cross_job.outputs.GitVersion_FullSemVer) : ${{ needs.GitVersion_v6_cross_job.outputs.GitVersion_FullSemVer }}"
- name: Use direct output from previous job (pwsh - outputs without prefix)
- shell: pwsh
-
- - run: |
- echo "FullSemVer (myvar_GitVersion_FullSemVer) : $myvar_GitVersion_FullSemVer"
- name: Use job variables (bash - outputs without prefix)
- shell: bash
-
- - run: |
- echo "FullSemVer (localvar_fullSemVer): $localvar_fullSemVer"
- name: Use local env mapped from output (bash - outputs without prefix)
- shell: bash
- env:
- localvar_fullSemVer: ${{ needs.GitVersion_v6_cross_job.outputs.GitVersion_FullSemVer }}
-
- - run: |
- echo "FullSemVer (localvar_fullSemVer) : $localvar_fullSemVer"
- name: Use local env mapped from job variables (bash - outputs without prefix)
- shell: bash
- env:
- localvar_fullSemVer: ${{ env.myvar_GitVersion_FullSemVer }}
-
- - run: |
- echo "FullSemVer (needs.GitVersion_v6_cross_job.outputs.GitVersion_FullSemVer) : ${{ needs.GitVersion_v6_cross_job.outputs.GitVersion_FullSemVer }}"
- name: Use direct output from previous job (bash - outputs without prefix)
- shell: bash
diff --git a/.run/run_azure_gitversion (command).run.xml b/.run/run_azure_gitversion (command).run.xml
new file mode 100644
index 000000000..1ec8936ae
--- /dev/null
+++ b/.run/run_azure_gitversion (command).run.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.run/run_github_gitversion (command).run.xml b/.run/run_github_gitversion (command).run.xml
new file mode 100644
index 000000000..674f439da
--- /dev/null
+++ b/.run/run_github_gitversion (command).run.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.run/run_local_gitversion (command).run.xml b/.run/run_local_gitversion (command).run.xml
new file mode 100644
index 000000000..5cb8a9fc4
--- /dev/null
+++ b/.run/run_local_gitversion (command).run.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/dist/azure/gitversion/command/icon.png b/dist/azure/gitversion/command/icon.png
new file mode 100644
index 000000000..22b958c98
Binary files /dev/null and b/dist/azure/gitversion/command/icon.png differ
diff --git a/dist/azure/gitversion/command/main.mjs b/dist/azure/gitversion/command/main.mjs
new file mode 100644
index 000000000..7116bee93
--- /dev/null
+++ b/dist/azure/gitversion/command/main.mjs
@@ -0,0 +1,2 @@
+import { run } from './tools/lib.mjs'
+await run('azure', 'gitversion', 'command')
diff --git a/dist/azure/gitversion/command/task.json b/dist/azure/gitversion/command/task.json
new file mode 100644
index 000000000..bdd931097
--- /dev/null
+++ b/dist/azure/gitversion/command/task.json
@@ -0,0 +1,51 @@
+{
+ "id": "41dc3dd2-6a51-4ba5-a889-824274acca8b",
+ "name": "gitversion/command",
+ "friendlyName": "Command GitVersion Task",
+ "description": "Easy Semantic Versioning (https://semver.org) for projects using Git",
+ "author": "GitTools Contributors",
+ "helpMarkDown": "See the [documentation](https://gitversion.net/docs/) for help",
+ "category": "Build",
+ "demands": [],
+ "version": {
+ "Major": 0,
+ "Minor": 0,
+ "Patch": 1
+ },
+ "minimumAgentVersion": "3.224.0",
+ "execution": {
+ "Node20_1": {
+ "target": "main.mjs",
+ "argumentFormat": "",
+ "workingDirectory": "."
+ }
+ },
+ "instanceNameFormat": "gitversion/command",
+ "inputs": [
+ {
+ "name": "targetPath",
+ "type": "string",
+ "label": "Working directory path",
+ "defaultValue": "",
+ "required": false,
+ "helpMarkDown": "Optionally supply the path to the working directory",
+ "groupName": "gitversionDetails"
+ },
+ {
+ "name": "disableShallowCloneCheck",
+ "type": "boolean",
+ "label": "Disable Shallow Clone Check",
+ "defaultValue": "false",
+ "required": false,
+ "helpMarkDown": "Whether to disable GitVersion shallow clone check"
+ },
+ {
+ "name": "arguments",
+ "type": "string",
+ "label": "GitVersion arguments",
+ "defaultValue": "",
+ "required": true,
+ "helpMarkDown": "Arguments to send to GitVersion"
+ }
+ ]
+}
diff --git a/dist/azure/gitversion/execute/task.json b/dist/azure/gitversion/execute/task.json
index 991e18421..22ee7056b 100644
--- a/dist/azure/gitversion/execute/task.json
+++ b/dist/azure/gitversion/execute/task.json
@@ -108,15 +108,6 @@
"required": false,
"helpMarkDown": "Update versions in specified file",
"visibleRule": "updateAssemblyInfo = true"
- },
- {
- "name": "additionalArguments",
- "type": "string",
- "label": "Additional GitVersion arguments",
- "defaultValue": "",
- "required": false,
- "helpMarkDown": "Additional arguments to send to GitVersion",
- "groupName": "additional"
}
]
-}
\ No newline at end of file
+}
diff --git a/dist/azure/manifest.config.cjs b/dist/azure/manifest.config.cjs
index f1510fe27..5489962a8 100644
--- a/dist/azure/manifest.config.cjs
+++ b/dist/azure/manifest.config.cjs
@@ -5,7 +5,8 @@ module.exports = (env) => {
const gitversion = [
{ id: 'setup', path: 'gitversion/setup' },
- { id: 'execute', path: 'gitversion/execute' }
+ { id: 'execute', path: 'gitversion/execute' },
+ { id: 'command', path: 'gitversion/command' }
]
const gitreleasemanager = [
diff --git a/dist/azure/tasks.json b/dist/azure/tasks.json
index 898d764b0..878f70f4d 100644
--- a/dist/azure/tasks.json
+++ b/dist/azure/tasks.json
@@ -7,6 +7,10 @@
"execute": {
"test": "9b58ed30-0deb-4083-b007-5f6ce7787544",
"prod": "9013cf7f-ee8d-49f4-a39b-db244928d391"
+ },
+ "command": {
+ "test": "b5559270-0af3-49c8-bde3-c44847a8503b",
+ "prod": "41dc3dd2-6a51-4ba5-a889-824274acca8b"
}
},
"gitreleasemanager": {
diff --git a/dist/tools/libs/gitversion.mjs b/dist/tools/libs/gitversion.mjs
index ba09ad1a6..6f6b3b687 100644
--- a/dist/tools/libs/gitversion.mjs
+++ b/dist/tools/libs/gitversion.mjs
@@ -15,9 +15,14 @@ var ExecuteFields = /* @__PURE__ */ ((ExecuteFields2) => {
ExecuteFields2["overrideConfig"] = "overrideConfig";
ExecuteFields2["updateAssemblyInfo"] = "updateAssemblyInfo";
ExecuteFields2["updateAssemblyInfoFilename"] = "updateAssemblyInfoFilename";
- ExecuteFields2["additionalArguments"] = "additionalArguments";
return ExecuteFields2;
})(ExecuteFields || {});
+var CommandFields = /* @__PURE__ */ ((CommandFields2) => {
+ CommandFields2["targetPath"] = "targetPath";
+ CommandFields2["disableShallowCloneCheck"] = "disableShallowCloneCheck";
+ CommandFields2["arguments"] = "arguments";
+ return CommandFields2;
+})(CommandFields || {});
class GitVersionSettingsProvider extends SettingsProvider {
getGitVersionExecuteSettings() {
@@ -30,7 +35,6 @@ class GitVersionSettingsProvider extends SettingsProvider {
const overrideConfig = this.buildAgent.getListInput(ExecuteFields.overrideConfig);
const updateAssemblyInfo = this.buildAgent.getBooleanInput(ExecuteFields.updateAssemblyInfo);
const updateAssemblyInfoFilename = this.buildAgent.getInput(ExecuteFields.updateAssemblyInfoFilename);
- const additionalArguments = this.buildAgent.getInput(ExecuteFields.additionalArguments);
return {
targetPath,
disableCache,
@@ -40,8 +44,17 @@ class GitVersionSettingsProvider extends SettingsProvider {
configFilePath,
overrideConfig,
updateAssemblyInfo,
- updateAssemblyInfoFilename,
- additionalArguments
+ updateAssemblyInfoFilename
+ };
+ }
+ getGitVersionCommandSettings() {
+ const targetPath = this.buildAgent.getInput(CommandFields.targetPath);
+ const disableShallowCloneCheck = this.buildAgent.getBooleanInput(CommandFields.disableShallowCloneCheck);
+ const args = this.buildAgent.getInput(CommandFields.arguments);
+ return {
+ targetPath,
+ disableShallowCloneCheck,
+ arguments: args
};
}
}
@@ -70,6 +83,14 @@ class GitVersionTool extends DotnetTool {
await this.setDotnetRoot();
return await this.executeTool(args);
}
+ async executeCommand() {
+ const settings = this.settingsProvider.getGitVersionCommandSettings();
+ const workDir = await this.getRepoDir(settings);
+ await this.checkShallowClone(settings, workDir);
+ const args = await this.getCommandArguments(workDir, settings);
+ await this.setDotnetRoot();
+ return await this.executeTool(args);
+ }
writeGitVersionToAgent(output) {
for (const property of keysOf(output)) {
const name = this.toCamelCase(property);
@@ -91,7 +112,7 @@ class GitVersionTool extends DotnetTool {
return await super.getRepoPath(settings.targetPath);
}
async getExecuteArguments(workDir, options) {
- let args = [workDir, "/output", "json", "/output", "buildserver"];
+ const args = [workDir, "/output", "json", "/output", "buildserver"];
const {
useConfigFile,
disableCache,
@@ -99,8 +120,7 @@ class GitVersionTool extends DotnetTool {
configFilePath,
overrideConfig,
updateAssemblyInfo,
- updateAssemblyInfoFilename,
- additionalArguments
+ updateAssemblyInfoFilename
//
} = options;
if (disableCache) {
@@ -134,8 +154,12 @@ class GitVersionTool extends DotnetTool {
}
}
}
- if (additionalArguments) {
- args = args.concat(this.argStringToArray(additionalArguments));
+ return args;
+ }
+ async getCommandArguments(workDir, options) {
+ let args = [workDir];
+ if (options.arguments) {
+ args = args.concat(this.argStringToArray(options.arguments));
}
return args;
}
@@ -218,6 +242,8 @@ class Runner {
return await this.setup();
case "execute":
return await this.execute();
+ case "command":
+ return await this.command();
}
}
async setup() {
@@ -287,6 +313,38 @@ class Runner {
};
}
}
+ async command() {
+ try {
+ this.disableTelemetry();
+ this.buildAgent.info("Executing GitVersion");
+ const result = await this.gitVersionTool.executeCommand();
+ if (result.code === 0) {
+ this.buildAgent.info("GitVersion executed successfully");
+ const stdout = result.stdout;
+ this.buildAgent.info("GitVersion output:");
+ this.buildAgent.info("-------------------");
+ this.buildAgent.info(stdout);
+ this.buildAgent.info("-------------------");
+ this.buildAgent.setSucceeded("GitVersion executed successfully", true);
+ return result;
+ } else {
+ this.buildAgent.debug("GitVersion failed");
+ const error = result.error;
+ if (error instanceof Error) {
+ this.buildAgent.setFailed(error.message, true);
+ }
+ return result;
+ }
+ } catch (error) {
+ if (error instanceof Error) {
+ this.buildAgent.setFailed(error.message, true);
+ }
+ return {
+ code: -1,
+ error
+ };
+ }
+ }
disableTelemetry() {
this.buildAgent.info(`Running on: '${this.buildAgent.agentName}'`);
this.buildAgent.debug("Disabling telemetry");
diff --git a/dist/tools/libs/gitversion.mjs.map b/dist/tools/libs/gitversion.mjs.map
index b1a63c950..7f425aeb7 100644
--- a/dist/tools/libs/gitversion.mjs.map
+++ b/dist/tools/libs/gitversion.mjs.map
@@ -1 +1 @@
-{"version":3,"file":"gitversion.mjs","sources":["../../../src/tools/gitversion/models.ts","../../../src/tools/gitversion/settings.ts","../../../src/tools/gitversion/tool.ts","../../../src/tools/gitversion/runner.ts"],"sourcesContent":["export type Commands = 'setup' | 'execute'\n\nexport enum ExecuteFields {\n targetPath = 'targetPath',\n disableCache = 'disableCache',\n disableNormalization = 'disableNormalization',\n disableShallowCloneCheck = 'disableShallowCloneCheck',\n useConfigFile = 'useConfigFile',\n configFilePath = 'configFilePath',\n overrideConfig = 'overrideConfig',\n updateAssemblyInfo = 'updateAssemblyInfo',\n updateAssemblyInfoFilename = 'updateAssemblyInfoFilename',\n additionalArguments = 'additionalArguments'\n}\n\nexport type GitVersionExecuteSettings = {\n [ExecuteFields.targetPath]: string\n [ExecuteFields.disableCache]: boolean\n [ExecuteFields.disableNormalization]: boolean\n [ExecuteFields.disableShallowCloneCheck]: boolean\n [ExecuteFields.useConfigFile]: boolean\n [ExecuteFields.configFilePath]: string\n [ExecuteFields.overrideConfig]: string[]\n [ExecuteFields.updateAssemblyInfo]: boolean\n [ExecuteFields.updateAssemblyInfoFilename]: string\n [ExecuteFields.additionalArguments]: string\n}\n\nexport type GitVersionOutput = {\n Major: number\n Minor: number\n Patch: number\n PreReleaseTag: string\n PreReleaseTagWithDash: string\n PreReleaseLabel: string\n PreReleaseNumber: number\n WeightedPreReleaseNumber: number\n BuildMetaData: number\n FullBuildMetaData: string\n MajorMinorPatch: string\n SemVer: string\n AssemblySemVer: string\n AssemblySemFileVer: string\n FullSemVer: string\n InformationalVersion: string\n BranchName: string\n EscapedBranchName: string\n Sha: string\n ShortSha: string\n VersionSourceSha: string\n CommitsSinceVersionSource: number\n UncommittedChanges: number\n CommitDate: string\n}\n","import { type ISettingsProvider, SettingsProvider } from '@tools/common'\nimport { ExecuteFields, type GitVersionExecuteSettings } from './models'\n\nexport interface IGitVersionSettingsProvider extends ISettingsProvider {\n getGitVersionExecuteSettings(): GitVersionExecuteSettings\n}\n\nexport class GitVersionSettingsProvider extends SettingsProvider implements IGitVersionSettingsProvider {\n getGitVersionExecuteSettings(): GitVersionExecuteSettings {\n const targetPath = this.buildAgent.getInput(ExecuteFields.targetPath)\n\n const disableCache = this.buildAgent.getBooleanInput(ExecuteFields.disableCache)\n const disableNormalization = this.buildAgent.getBooleanInput(ExecuteFields.disableNormalization)\n const disableShallowCloneCheck = this.buildAgent.getBooleanInput(ExecuteFields.disableShallowCloneCheck)\n\n const useConfigFile = this.buildAgent.getBooleanInput(ExecuteFields.useConfigFile)\n const configFilePath = this.buildAgent.getInput(ExecuteFields.configFilePath)\n const overrideConfig = this.buildAgent.getListInput(ExecuteFields.overrideConfig)\n\n const updateAssemblyInfo = this.buildAgent.getBooleanInput(ExecuteFields.updateAssemblyInfo)\n const updateAssemblyInfoFilename = this.buildAgent.getInput(ExecuteFields.updateAssemblyInfoFilename)\n\n const additionalArguments = this.buildAgent.getInput(ExecuteFields.additionalArguments)\n\n return {\n targetPath,\n disableCache,\n disableNormalization,\n disableShallowCloneCheck,\n useConfigFile,\n configFilePath,\n overrideConfig,\n updateAssemblyInfo,\n updateAssemblyInfoFilename,\n additionalArguments\n }\n }\n}\n","import { type ExecResult } from '@agents/common'\nimport { DotnetTool, keysOf } from '@tools/common'\nimport { type GitVersionExecuteSettings, type GitVersionOutput } from './models'\nimport { GitVersionSettingsProvider, type IGitVersionSettingsProvider } from './settings'\n\nexport class GitVersionTool extends DotnetTool {\n get packageName(): string {\n return 'GitVersion.Tool'\n }\n\n get toolName(): string {\n return 'dotnet-gitversion'\n }\n\n get toolPathVariable(): string {\n return 'GITVERSION_PATH'\n }\n\n get versionRange(): string | null {\n return '>=5.2.0 <6.1.0'\n }\n\n get settingsProvider(): IGitVersionSettingsProvider {\n return new GitVersionSettingsProvider(this.buildAgent)\n }\n\n async executeJson(): Promise {\n const settings = this.settingsProvider.getGitVersionExecuteSettings()\n const workDir = await this.getRepoDir(settings)\n\n await this.checkShallowClone(settings, workDir)\n\n const args = await this.getExecuteArguments(workDir, settings)\n\n await this.setDotnetRoot()\n return await this.executeTool(args)\n }\n\n writeGitVersionToAgent(output: GitVersionOutput): void {\n for (const property of keysOf(output)) {\n const name = this.toCamelCase(property)\n try {\n let value = output[property]?.toString()\n if (value === '0') {\n value = '0'\n }\n this.buildAgent.setOutput(name, value)\n this.buildAgent.setOutput(`GitVersion_${property}`, value)\n this.buildAgent.setVariable(name, value)\n this.buildAgent.setVariable(`GitVersion_${property}`, value)\n } catch (error) {\n this.buildAgent.error(`Unable to set output/variable for ${property}`)\n }\n }\n }\n\n protected async getRepoDir(settings: GitVersionExecuteSettings): Promise {\n return await super.getRepoPath(settings.targetPath)\n }\n\n protected async getExecuteArguments(workDir: string, options: GitVersionExecuteSettings): Promise {\n let args = [workDir, '/output', 'json', '/output', 'buildserver']\n\n const {\n useConfigFile,\n disableCache,\n disableNormalization,\n configFilePath,\n overrideConfig,\n updateAssemblyInfo,\n updateAssemblyInfoFilename,\n additionalArguments\n //\n } = options\n\n if (disableCache) {\n args.push('/nocache')\n }\n\n if (disableNormalization) {\n args.push('/nonormalize')\n }\n\n if (useConfigFile) {\n if (await this.isValidInputFile('configFilePath', configFilePath)) {\n args.push('/config', configFilePath)\n } else {\n throw new Error(`GitVersion configuration file not found at ${configFilePath}`)\n }\n }\n\n if (overrideConfig) {\n for (let config of overrideConfig) {\n config = config.trim()\n if (config.match(/([a-zA-Z0-9]+(-[a-zA-Z]+)*=[a-zA-Z0-9\\- :.']*)/)) {\n args.push('/overrideconfig', config)\n }\n }\n }\n\n if (updateAssemblyInfo) {\n args.push('/updateassemblyinfo')\n\n // You can specify 'updateAssemblyInfo' without 'updateAssemblyInfoFilename'.\n if (updateAssemblyInfoFilename?.length > 0) {\n if (await this.isValidInputFile('updateAssemblyInfoFilename', updateAssemblyInfoFilename)) {\n args.push(updateAssemblyInfoFilename)\n } else {\n throw new Error(`AssemblyInfoFilename file not found at ${updateAssemblyInfoFilename}`)\n }\n }\n }\n\n if (additionalArguments) {\n args = args.concat(this.argStringToArray(additionalArguments))\n }\n return args\n }\n\n private argStringToArray(argString: string): string[] {\n const args: string[] = []\n\n let inQuotes = false\n let escaped = false\n let lastCharWasSpace = true\n let arg = ''\n\n const append = (c: string): void => {\n // we only escape double quotes.\n if (escaped && c !== '\"') {\n arg += '\\\\'\n }\n\n arg += c\n escaped = false\n }\n\n for (let i = 0; i < argString.length; i++) {\n const c = argString.charAt(i)\n\n if (c === ' ' && !inQuotes) {\n if (!lastCharWasSpace) {\n args.push(arg)\n arg = ''\n }\n lastCharWasSpace = true\n continue\n } else {\n lastCharWasSpace = false\n }\n\n if (c === '\"') {\n if (!escaped) {\n inQuotes = !inQuotes\n } else {\n append(c)\n }\n continue\n }\n\n if (c === '\\\\' && escaped) {\n append(c)\n continue\n }\n\n if (c === '\\\\' && inQuotes) {\n escaped = true\n continue\n }\n\n append(c)\n lastCharWasSpace = false\n }\n\n if (!lastCharWasSpace) {\n args.push(arg.trim())\n }\n\n return args\n }\n\n private async checkShallowClone(settings: GitVersionExecuteSettings, workDir: string): Promise {\n if (!settings.disableShallowCloneCheck) {\n const isShallowResult = await this.execute('git', ['-C', workDir, 'rev-parse', '--is-shallow-repository'])\n if (isShallowResult.code === 0 && isShallowResult.stdout.trim() === 'true') {\n throw new Error(\n 'The repository is shallow. Consider disabling shallow clones. See https://github.com/GitTools/actions/blob/main/docs/cloning.md for more information.'\n )\n }\n }\n }\n\n private toCamelCase(input: string): string {\n return input.replace(/^\\w|[A-Z]|\\b\\w|\\s+/g, function (match, index) {\n if (+match === 0) return '' // or if (/\\s+/.test(match)) for white spaces\n return index === 0 ? match.toLowerCase() : match.toUpperCase()\n })\n }\n}\n","import { type ExecResult, type IBuildAgent } from '@agents/common'\nimport { type IRunner } from '@tools/common'\nimport { type Commands, type GitVersionOutput } from './models'\nimport { GitVersionTool } from './tool'\n\nexport class Runner implements IRunner {\n private readonly gitVersionTool: GitVersionTool\n\n constructor(private readonly buildAgent: IBuildAgent) {\n this.gitVersionTool = new GitVersionTool(this.buildAgent)\n }\n\n async run(command: Commands): Promise {\n switch (command) {\n case 'setup':\n return await this.setup()\n case 'execute':\n return await this.execute()\n }\n }\n\n private async setup(): Promise {\n try {\n this.disableTelemetry()\n\n this.buildAgent.debug('Installing GitVersion')\n const toolPath = await this.gitVersionTool.install()\n\n const pathVariable = this.gitVersionTool.toolPathVariable\n this.buildAgent.info(`Set ${pathVariable} to ${toolPath}`)\n this.buildAgent.setVariable(pathVariable, toolPath)\n\n this.buildAgent.setSucceeded('GitVersion installed successfully', true)\n return {\n code: 0\n }\n } catch (error) {\n if (error instanceof Error) {\n this.buildAgent.setFailed(error.message, true)\n }\n return {\n code: -1,\n error\n }\n }\n }\n\n private async execute(): Promise {\n try {\n this.disableTelemetry()\n\n this.buildAgent.info('Executing GitVersion')\n\n const result = await this.gitVersionTool.executeJson()\n\n if (result.code === 0) {\n this.buildAgent.info('GitVersion executed successfully')\n const stdout: string = result.stdout as string\n\n this.buildAgent.info('GitVersion output:')\n this.buildAgent.info('-------------------')\n this.buildAgent.info(stdout)\n this.buildAgent.info('-------------------')\n this.buildAgent.debug('Parsing GitVersion output')\n\n if (stdout.lastIndexOf('{') === -1 || stdout.lastIndexOf('}') === -1) {\n this.buildAgent.debug('GitVersion output is not valid JSON')\n this.buildAgent.setFailed('GitVersion output is not valid JSON', true)\n return {\n code: -1,\n error: new Error('GitVersion output is not valid JSON')\n }\n } else {\n const jsonOutput = stdout.substring(stdout.lastIndexOf('{'), stdout.lastIndexOf('}') + 1)\n\n const gitVersionOutput = JSON.parse(jsonOutput) as GitVersionOutput\n this.gitVersionTool.writeGitVersionToAgent(gitVersionOutput)\n this.buildAgent.setSucceeded('GitVersion executed successfully', true)\n return result\n }\n } else {\n this.buildAgent.debug('GitVersion failed')\n const error = result.error\n if (error instanceof Error) {\n this.buildAgent.setFailed(error.message, true)\n }\n return result\n }\n } catch (error) {\n if (error instanceof Error) {\n this.buildAgent.setFailed(error.message, true)\n }\n return {\n code: -1,\n error\n }\n }\n }\n\n private disableTelemetry(): void {\n this.buildAgent.info(`Running on: '${this.buildAgent.agentName}'`)\n this.buildAgent.debug('Disabling telemetry')\n this.gitVersionTool.disableTelemetry()\n }\n}\n"],"names":["ExecuteFields"],"mappings":";;;;;;;AAEY,IAAA,aAAA,qBAAAA,cAAL,KAAA;AACH,EAAAA,eAAA,YAAa,CAAA,GAAA,YAAA,CAAA;AACb,EAAAA,eAAA,cAAe,CAAA,GAAA,cAAA,CAAA;AACf,EAAAA,eAAA,sBAAuB,CAAA,GAAA,sBAAA,CAAA;AACvB,EAAAA,eAAA,0BAA2B,CAAA,GAAA,0BAAA,CAAA;AAC3B,EAAAA,eAAA,eAAgB,CAAA,GAAA,eAAA,CAAA;AAChB,EAAAA,eAAA,gBAAiB,CAAA,GAAA,gBAAA,CAAA;AACjB,EAAAA,eAAA,gBAAiB,CAAA,GAAA,gBAAA,CAAA;AACjB,EAAAA,eAAA,oBAAqB,CAAA,GAAA,oBAAA,CAAA;AACrB,EAAAA,eAAA,4BAA6B,CAAA,GAAA,4BAAA,CAAA;AAC7B,EAA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AAW,MAAM,qBAAqB,CAAA,CAAA;AAC3C,IAAA,IAAA,CAAK,eAAe,gBAAiB,EAAA,CAAA;AAAA,GACzC;AACJ;;;;"}
\ No newline at end of file
+{"version":3,"file":"gitversion.mjs","sources":["../../../src/tools/gitversion/models.ts","../../../src/tools/gitversion/settings.ts","../../../src/tools/gitversion/tool.ts","../../../src/tools/gitversion/runner.ts"],"sourcesContent":["export type Commands = 'setup' | 'execute' | 'command'\n\nexport enum ExecuteFields {\n targetPath = 'targetPath',\n disableCache = 'disableCache',\n disableNormalization = 'disableNormalization',\n disableShallowCloneCheck = 'disableShallowCloneCheck',\n useConfigFile = 'useConfigFile',\n configFilePath = 'configFilePath',\n overrideConfig = 'overrideConfig',\n updateAssemblyInfo = 'updateAssemblyInfo',\n updateAssemblyInfoFilename = 'updateAssemblyInfoFilename'\n}\n\nexport enum CommandFields {\n targetPath = 'targetPath',\n disableShallowCloneCheck = 'disableShallowCloneCheck',\n arguments = 'arguments'\n}\n\nexport type GitVersionExecuteSettings = {\n [ExecuteFields.targetPath]: string\n [ExecuteFields.disableCache]: boolean\n [ExecuteFields.disableNormalization]: boolean\n [ExecuteFields.disableShallowCloneCheck]: boolean\n [ExecuteFields.useConfigFile]: boolean\n [ExecuteFields.configFilePath]: string\n [ExecuteFields.overrideConfig]: string[]\n [ExecuteFields.updateAssemblyInfo]: boolean\n [ExecuteFields.updateAssemblyInfoFilename]: string\n}\n\nexport type GitVersionCommandSettings = {\n [CommandFields.targetPath]: string\n [ExecuteFields.disableShallowCloneCheck]: boolean\n [CommandFields.arguments]: string\n}\n\nexport type GitVersionOutput = {\n Major: number\n Minor: number\n Patch: number\n PreReleaseTag: string\n PreReleaseTagWithDash: string\n PreReleaseLabel: string\n PreReleaseNumber: number\n WeightedPreReleaseNumber: number\n BuildMetaData: number\n FullBuildMetaData: string\n MajorMinorPatch: string\n SemVer: string\n AssemblySemVer: string\n AssemblySemFileVer: string\n FullSemVer: string\n InformationalVersion: string\n BranchName: string\n EscapedBranchName: string\n Sha: string\n ShortSha: string\n VersionSourceSha: string\n CommitsSinceVersionSource: number\n UncommittedChanges: number\n CommitDate: string\n}\n","import { type ISettingsProvider, SettingsProvider } from '@tools/common'\nimport { CommandFields, ExecuteFields, type GitVersionCommandSettings, type GitVersionExecuteSettings } from './models'\n\nexport interface IGitVersionSettingsProvider extends ISettingsProvider {\n getGitVersionExecuteSettings(): GitVersionExecuteSettings\n\n getGitVersionCommandSettings(): GitVersionCommandSettings\n}\n\nexport class GitVersionSettingsProvider extends SettingsProvider implements IGitVersionSettingsProvider {\n getGitVersionExecuteSettings(): GitVersionExecuteSettings {\n const targetPath = this.buildAgent.getInput(ExecuteFields.targetPath)\n\n const disableCache = this.buildAgent.getBooleanInput(ExecuteFields.disableCache)\n const disableNormalization = this.buildAgent.getBooleanInput(ExecuteFields.disableNormalization)\n const disableShallowCloneCheck = this.buildAgent.getBooleanInput(ExecuteFields.disableShallowCloneCheck)\n\n const useConfigFile = this.buildAgent.getBooleanInput(ExecuteFields.useConfigFile)\n const configFilePath = this.buildAgent.getInput(ExecuteFields.configFilePath)\n const overrideConfig = this.buildAgent.getListInput(ExecuteFields.overrideConfig)\n\n const updateAssemblyInfo = this.buildAgent.getBooleanInput(ExecuteFields.updateAssemblyInfo)\n const updateAssemblyInfoFilename = this.buildAgent.getInput(ExecuteFields.updateAssemblyInfoFilename)\n\n return {\n targetPath,\n disableCache,\n disableNormalization,\n disableShallowCloneCheck,\n useConfigFile,\n configFilePath,\n overrideConfig,\n updateAssemblyInfo,\n updateAssemblyInfoFilename\n }\n }\n\n getGitVersionCommandSettings(): GitVersionCommandSettings {\n const targetPath = this.buildAgent.getInput(CommandFields.targetPath)\n const disableShallowCloneCheck = this.buildAgent.getBooleanInput(CommandFields.disableShallowCloneCheck)\n const args = this.buildAgent.getInput(CommandFields.arguments)\n\n return {\n targetPath,\n disableShallowCloneCheck,\n arguments: args\n }\n }\n}\n","import { type ExecResult } from '@agents/common'\nimport { DotnetTool, keysOf } from '@tools/common'\nimport { type GitVersionCommandSettings, type GitVersionExecuteSettings, type GitVersionOutput } from './models'\nimport { GitVersionSettingsProvider, type IGitVersionSettingsProvider } from './settings'\n\nexport class GitVersionTool extends DotnetTool {\n get packageName(): string {\n return 'GitVersion.Tool'\n }\n\n get toolName(): string {\n return 'dotnet-gitversion'\n }\n\n get toolPathVariable(): string {\n return 'GITVERSION_PATH'\n }\n\n get versionRange(): string | null {\n return '>=5.2.0 <6.1.0'\n }\n\n get settingsProvider(): IGitVersionSettingsProvider {\n return new GitVersionSettingsProvider(this.buildAgent)\n }\n\n async executeJson(): Promise {\n const settings = this.settingsProvider.getGitVersionExecuteSettings()\n const workDir = await this.getRepoDir(settings)\n\n await this.checkShallowClone(settings, workDir)\n\n const args = await this.getExecuteArguments(workDir, settings)\n\n await this.setDotnetRoot()\n return await this.executeTool(args)\n }\n\n async executeCommand(): Promise {\n const settings = this.settingsProvider.getGitVersionCommandSettings()\n const workDir = await this.getRepoDir(settings)\n\n await this.checkShallowClone(settings, workDir)\n\n const args = await this.getCommandArguments(workDir, settings)\n\n await this.setDotnetRoot()\n return await this.executeTool(args)\n }\n\n writeGitVersionToAgent(output: GitVersionOutput): void {\n for (const property of keysOf(output)) {\n const name = this.toCamelCase(property)\n try {\n let value = output[property]?.toString()\n if (value === '0') {\n value = '0'\n }\n this.buildAgent.setOutput(name, value)\n this.buildAgent.setOutput(`GitVersion_${property}`, value)\n this.buildAgent.setVariable(name, value)\n this.buildAgent.setVariable(`GitVersion_${property}`, value)\n } catch (error) {\n this.buildAgent.error(`Unable to set output/variable for ${property}`)\n }\n }\n }\n\n protected async getRepoDir(settings: GitVersionExecuteSettings | GitVersionCommandSettings): Promise {\n return await super.getRepoPath(settings.targetPath)\n }\n\n protected async getExecuteArguments(workDir: string, options: GitVersionExecuteSettings): Promise {\n const args = [workDir, '/output', 'json', '/output', 'buildserver']\n\n const {\n useConfigFile,\n disableCache,\n disableNormalization,\n configFilePath,\n overrideConfig,\n updateAssemblyInfo,\n updateAssemblyInfoFilename\n //\n } = options\n\n if (disableCache) {\n args.push('/nocache')\n }\n\n if (disableNormalization) {\n args.push('/nonormalize')\n }\n\n if (useConfigFile) {\n if (await this.isValidInputFile('configFilePath', configFilePath)) {\n args.push('/config', configFilePath)\n } else {\n throw new Error(`GitVersion configuration file not found at ${configFilePath}`)\n }\n }\n\n if (overrideConfig) {\n for (let config of overrideConfig) {\n config = config.trim()\n if (config.match(/([a-zA-Z0-9]+(-[a-zA-Z]+)*=[a-zA-Z0-9\\- :.']*)/)) {\n args.push('/overrideconfig', config)\n }\n }\n }\n\n if (updateAssemblyInfo) {\n args.push('/updateassemblyinfo')\n\n // You can specify 'updateAssemblyInfo' without 'updateAssemblyInfoFilename'.\n if (updateAssemblyInfoFilename?.length > 0) {\n if (await this.isValidInputFile('updateAssemblyInfoFilename', updateAssemblyInfoFilename)) {\n args.push(updateAssemblyInfoFilename)\n } else {\n throw new Error(`AssemblyInfoFilename file not found at ${updateAssemblyInfoFilename}`)\n }\n }\n }\n\n return args\n }\n\n protected async getCommandArguments(workDir: string, options: GitVersionCommandSettings): Promise {\n let args = [workDir]\n\n if (options.arguments) {\n args = args.concat(this.argStringToArray(options.arguments))\n }\n return args\n }\n\n private argStringToArray(argString: string): string[] {\n const args: string[] = []\n\n let inQuotes = false\n let escaped = false\n let lastCharWasSpace = true\n let arg = ''\n\n const append = (c: string): void => {\n // we only escape double quotes.\n if (escaped && c !== '\"') {\n arg += '\\\\'\n }\n\n arg += c\n escaped = false\n }\n\n for (let i = 0; i < argString.length; i++) {\n const c = argString.charAt(i)\n\n if (c === ' ' && !inQuotes) {\n if (!lastCharWasSpace) {\n args.push(arg)\n arg = ''\n }\n lastCharWasSpace = true\n continue\n } else {\n lastCharWasSpace = false\n }\n\n if (c === '\"') {\n if (!escaped) {\n inQuotes = !inQuotes\n } else {\n append(c)\n }\n continue\n }\n\n if (c === '\\\\' && escaped) {\n append(c)\n continue\n }\n\n if (c === '\\\\' && inQuotes) {\n escaped = true\n continue\n }\n\n append(c)\n lastCharWasSpace = false\n }\n\n if (!lastCharWasSpace) {\n args.push(arg.trim())\n }\n\n return args\n }\n\n private async checkShallowClone(settings: GitVersionExecuteSettings | GitVersionCommandSettings, workDir: string): Promise {\n if (!settings.disableShallowCloneCheck) {\n const isShallowResult = await this.execute('git', ['-C', workDir, 'rev-parse', '--is-shallow-repository'])\n if (isShallowResult.code === 0 && isShallowResult.stdout.trim() === 'true') {\n throw new Error(\n 'The repository is shallow. Consider disabling shallow clones. See https://github.com/GitTools/actions/blob/main/docs/cloning.md for more information.'\n )\n }\n }\n }\n\n private toCamelCase(input: string): string {\n return input.replace(/^\\w|[A-Z]|\\b\\w|\\s+/g, function (match, index) {\n if (+match === 0) return '' // or if (/\\s+/.test(match)) for white spaces\n return index === 0 ? match.toLowerCase() : match.toUpperCase()\n })\n }\n}\n","import { type ExecResult, type IBuildAgent } from '@agents/common'\nimport { type IRunner } from '@tools/common'\nimport { type Commands, type GitVersionOutput } from './models'\nimport { GitVersionTool } from './tool'\n\nexport class Runner implements IRunner {\n private readonly gitVersionTool: GitVersionTool\n\n constructor(private readonly buildAgent: IBuildAgent) {\n this.gitVersionTool = new GitVersionTool(this.buildAgent)\n }\n\n async run(command: Commands): Promise {\n switch (command) {\n case 'setup':\n return await this.setup()\n case 'execute':\n return await this.execute()\n case 'command':\n return await this.command()\n }\n }\n\n private async setup(): Promise {\n try {\n this.disableTelemetry()\n\n this.buildAgent.debug('Installing GitVersion')\n const toolPath = await this.gitVersionTool.install()\n\n const pathVariable = this.gitVersionTool.toolPathVariable\n this.buildAgent.info(`Set ${pathVariable} to ${toolPath}`)\n this.buildAgent.setVariable(pathVariable, toolPath)\n\n this.buildAgent.setSucceeded('GitVersion installed successfully', true)\n return {\n code: 0\n }\n } catch (error) {\n if (error instanceof Error) {\n this.buildAgent.setFailed(error.message, true)\n }\n return {\n code: -1,\n error\n }\n }\n }\n\n private async execute(): Promise {\n try {\n this.disableTelemetry()\n\n this.buildAgent.info('Executing GitVersion')\n\n const result = await this.gitVersionTool.executeJson()\n\n if (result.code === 0) {\n this.buildAgent.info('GitVersion executed successfully')\n const stdout: string = result.stdout as string\n\n this.buildAgent.info('GitVersion output:')\n this.buildAgent.info('-------------------')\n this.buildAgent.info(stdout)\n this.buildAgent.info('-------------------')\n this.buildAgent.debug('Parsing GitVersion output')\n\n if (stdout.lastIndexOf('{') === -1 || stdout.lastIndexOf('}') === -1) {\n this.buildAgent.debug('GitVersion output is not valid JSON')\n this.buildAgent.setFailed('GitVersion output is not valid JSON', true)\n return {\n code: -1,\n error: new Error('GitVersion output is not valid JSON')\n }\n } else {\n const jsonOutput = stdout.substring(stdout.lastIndexOf('{'), stdout.lastIndexOf('}') + 1)\n\n const gitVersionOutput = JSON.parse(jsonOutput) as GitVersionOutput\n this.gitVersionTool.writeGitVersionToAgent(gitVersionOutput)\n this.buildAgent.setSucceeded('GitVersion executed successfully', true)\n return result\n }\n } else {\n this.buildAgent.debug('GitVersion failed')\n const error = result.error\n if (error instanceof Error) {\n this.buildAgent.setFailed(error.message, true)\n }\n return result\n }\n } catch (error) {\n if (error instanceof Error) {\n this.buildAgent.setFailed(error.message, true)\n }\n return {\n code: -1,\n error\n }\n }\n }\n\n private async command(): Promise {\n try {\n this.disableTelemetry()\n\n this.buildAgent.info('Executing GitVersion')\n\n const result = await this.gitVersionTool.executeCommand()\n\n if (result.code === 0) {\n this.buildAgent.info('GitVersion executed successfully')\n const stdout = result.stdout as string\n\n this.buildAgent.info('GitVersion output:')\n this.buildAgent.info('-------------------')\n this.buildAgent.info(stdout)\n this.buildAgent.info('-------------------')\n\n this.buildAgent.setSucceeded('GitVersion executed successfully', true)\n return result\n } else {\n this.buildAgent.debug('GitVersion failed')\n const error = result.error\n if (error instanceof Error) {\n this.buildAgent.setFailed(error.message, true)\n }\n return result\n }\n } catch (error) {\n if (error instanceof Error) {\n this.buildAgent.setFailed(error.message, true)\n }\n return {\n code: -1,\n error\n }\n }\n }\n\n private disableTelemetry(): void {\n this.buildAgent.info(`Running on: '${this.buildAgent.agentName}'`)\n this.buildAgent.debug('Disabling telemetry')\n this.gitVersionTool.disableTelemetry()\n }\n}\n"],"names":["ExecuteFields","CommandFields"],"mappings":";;;;;;;AAEY,IAAA,aAAA,qBAAAA,cAAL,KAAA;AACH,EAAAA,eAAA,YAAa,CAAA,GAAA,YAAA,CAAA;AACb,EAAAA,eAAA,cAAe,CAAA,GAAA,cAAA,CAAA;AACf,EAAAA,eAAA,sBAAuB,CAAA,GAAA,sBAAA,CAAA;AACvB,EAAAA,eAAA,0BAA2B,CAAA,GAAA,0BAAA,CAAA;AAC3B,EAAAA,eAAA,eAAgB,CAAA,GAAA,eAAA,CAAA;AAChB,EAAAA,eAAA,gBAAiB,CAAA,GAAA,gBAAA,CAAA;AACjB,EAAAA,eAAA,gBAAiB,CAAA,GAAA,gBAAA,CAAA;AACjB,EAAAA,eAAA,oBAAqB,CAAA,GAAA,oBAAA,CAAA;AACrB,EAAAA,eAAA,4BAA6B,CAAA,GAAA,4BAAA,CAAA;AATrB,EAAAA,OAAAA,cAAAA,CAAAA;AAAA,CAAA,EAAA,aAAA,IAAA,EAAA,CAAA,CAAA;AAYA,IAAA,aAAA,qBAAAC,cAAL,KAAA;AACH,EAAAA,eAAA,YAAa,CAAA,GAAA,YAAA,CAAA;AACb,EAAAA,eAAA,0BAA2B,CAAA,GAAA,0BAAA,CAAA;AAC3B,EAAAA,eAAA,WAAY,CAAA,GAAA,WAAA,CAAA;AAHJ,EAAAA,OAAAA,cAAAA,CAAAA;AAAA,CAAA,EAAA,aAAA,IAAA,EAAA,CAAA;;ACLL,MAAM,mCAAmC,gBAAwD,CAAA;AAAA,EACpG,4BAA0D,GAAA;AACtD,IAAA,MAAM,UAAa,GAAA,IAAA,CAAK,UAAW,CAAA,QAAA,CAAS,cAAc,UAAU,CAAA,CAAA;AAEpE,IAAA,MAAM,YAAe,GAAA,IAAA,CAAK,UAAW,CAAA,eAAA,CAAg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;AAAA,OACJ,MAAA;AACH,QAAK,IAAA,CAAA,UAAA,CAAW,MAAM,mBAAmB,CAAA,CAAA;AACzC,QAAA,MAAM,QAAQ,MAAO,CAAA,KAAA,CAAA;AACrB,QAAA,IAAI,iBAAiB,KAAO,EAAA;AACxB,UAAA,IAAA,CAAK,UAAW,CAAA,SAAA,CAAU,KAAM,CAAA,OAAA,EAAS,IAAI,CAAA,CAAA;AAAA,SACjD;AACA,QAAO,OAAA,MAAA,CAAA;AAAA,OACX;AAAA,aACK,KAAO,EAAA;AACZ,MAAA,IAAI,iBAAiB,KAAO,EAAA;AACxB,QAAA,IAAA,CAAK,UAAW,CAAA,SAAA,CAAU,KAAM,CAAA,OAAA,EAAS,IAAI,CAAA,CAAA;AAAA,OACjD;AACA,MAAO,OAAA;AAAA,QACH,IAAM,EAAA,CAAA,CAAA;AAAA,QACN,KAAA;AAAA,OACJ,CAAA;AAAA,KACJ;AAAA,GACJ;AAAA,EAEQ,gBAAyB,GAAA;AAC7B,IAAA,IAAA,CAAK,WAAW,IAAK,CAAA,CAAA,aAAA,EAAgB,IAAK,CAAA,UAAA,CAAW,SAAS,CAAG,CAAA,CAAA,CAAA,CAAA;AACjE,IAAK,IAAA,CAAA,UAAA,CAAW,MAAM,qBAAqB,CAAA,CAAA;AAC3C,IAAA,IAAA,CAAK,eAAe,gBAAiB,EAAA,CAAA;AAAA,GACzC;AACJ;;;;"}
\ No newline at end of file
diff --git a/docs/examples/azure/gitversion/command.md b/docs/examples/azure/gitversion/command.md
new file mode 100644
index 000000000..b3615660d
--- /dev/null
+++ b/docs/examples/azure/gitversion/command.md
@@ -0,0 +1,95 @@
+# Command GitVersion Task (gitversion/command) usage Examples
+
+Find out how to use the **gitversion/command** task using the examples below.
+
+Note that if the pipeline is set up to use a shallow git fetch mode the GitVersion Command task will fail. It is required to use `fetchDepth: 0`.
+You must also run the GitVersion Setup step before the Command step:
+
+```yaml
+steps:
+ - checkout: self
+ fetchDepth: 0
+
+ - task: gitversion/setup@2.0.1
+ displayName: Install GitVersion
+ inputs:
+ versionSpec: '6.x'
+```
+
+These steps are omitted from the examples for brevity.
+
+> The examples use version _2.0.1_ of the GitVersion Command task. It is recommended to use the latest released version in your own workflows.
+
+## Inputs
+
+The Command GitVersion task accepts the following inputs:
+
+```yaml
+targetPath:
+ description: Optionally supply the path to the working directory
+ required: false
+ default: ''
+disableShallowCloneCheck:
+ description: Whether to disable the check for shallow clone
+ required: false
+ default: 'false'
+arguments:
+ description: Arguments to send to GitVersion
+ required: true
+ default: ''
+```
+
+---
+
+## Execution Examples
+
+### Example 1
+
+
+ Show the effective configuration for GitVersion by running the /showConfig command.
+
+```yaml
+steps:
+ # gitversion/setup@2.0.1 task omitted for brevity.
+
+ - task: gitversion/command@2.0.1
+ displayName: Display GitVersion config
+ inputs:
+ arguments: '/showConfig'
+```
+
+
+
+### Example 2
+
+
+ Outputs the FullSemVer variable by running the /showvariable FullSemVer command.
+
+```yaml
+steps:
+ # gitversion/setup@2.0.1 task omitted for brevity.
+
+ - task: gitversion/command@2.0.1
+ displayName: Output the FullSemVer variable
+ inputs:
+ arguments: '/showvariable FullSemVer'
+```
+
+
+
+### Example 3
+
+
+ Outputs the formatted version by running the /format {Major}.{Minor} command.
+
+```yaml
+steps:
+ # gitversion/setup@2.0.1 task omitted for brevity.
+
+ - task: gitversion/command@2.0.1
+ displayName: Output the formatted version
+ inputs:
+ arguments: '/format {Major}.{Minor}' # any Output Variable can be used here
+```
+
+
diff --git a/docs/examples/azure/gitversion/execute.md b/docs/examples/azure/gitversion/execute.md
index 83702b733..320b06c03 100644
--- a/docs/examples/azure/gitversion/execute.md
+++ b/docs/examples/azure/gitversion/execute.md
@@ -64,10 +64,6 @@ updateAssemblyInfoFilename:
description: Update versions in specified file
required: false
default: ''
-additionalArguments:
- description: Additional arguments to send to GitVersion
- required: false
- default: ''
```
## Outputs
@@ -175,23 +171,6 @@ steps:
### Example 4
-
- Show the effective configuration for GitVersion by running the /showConfig command (passed as an additional argument).
-
-```yaml
-steps:
- # gitversion/setup@2.0.1 task omitted for brevity.
-
- - task: gitversion/execute@2.0.1
- displayName: Display GitVersion config
- inputs:
- additionalArguments: '/showConfig'
-```
-
-
-
-### Example 5
-
Calculate the version for the build. Disabling the cache and normalization.
@@ -208,7 +187,7 @@ steps:
-### Example 6
+### Example 5
Calculate the version for the build. Update the version in the AssemblyInfo files.
@@ -225,7 +204,7 @@ steps:
-### Example 7
+### Example 6
Calculate the version for the build. Override the configuration file with the specified values.
@@ -256,7 +235,7 @@ The multi-job output variables can be accessed across jobs and stages, in both c
**GitVersion also automatically updates the pre-defined Build variable `Build.BuildNumber`.**
You can disable the default behavior by setting the `update-build-number` to `false` in the configuration file or by using the `overrideConfig` input.
-### Example 8
+### Example 7
Calculate the version for the build and use the output in a subsequent steps within the same job.
@@ -326,7 +305,7 @@ jobs:
-### Example 9
+### Example 8
Calculate the version for the build and use the output in a subsequent job.
@@ -414,7 +393,7 @@ jobs:
-### Example 10
+### Example 9
Calculate the version for the build and use the output in a subsequent stage.
diff --git a/docs/examples/azure/gitversion/index.md b/docs/examples/azure/gitversion/index.md
index a800b31d6..2dd324663 100644
--- a/docs/examples/azure/gitversion/index.md
+++ b/docs/examples/azure/gitversion/index.md
@@ -11,3 +11,7 @@ Note: You need to run the Setup step before the Execute step, otherwise the Exec
## Execute GitVersion (gitversion/execute)
- [Execute](execute.md)
+
+## Execute GitVersion (gitversion/command)
+
+- [Command](command.md)
diff --git a/docs/examples/github/gitversion/command.md b/docs/examples/github/gitversion/command.md
new file mode 100644
index 000000000..6120dd7ea
--- /dev/null
+++ b/docs/examples/github/gitversion/command.md
@@ -0,0 +1,98 @@
+# Command GitVersion Action (gitversion/command) usage Examples
+
+Find out how to use the **gitversion/command** action using the examples below.
+
+Note that if the pipeline is set up to use a shallow git fetch mode the GitVersion Command action will fail. It is required to use `fetch-depth: 0`.
+You must also run the GitVersion Setup step before the Command step:
+
+```yaml
+steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+
+ - name: Install GitVersion
+ uses: gittools/actions/gitversion/setup@v2.0.1
+ with:
+ versionSpec: '6.x'
+```
+
+These steps are omitted from the examples for brevity.
+
+> The examples use version _2.0.1_ of the GitVersion Command action. It is recommended to use the latest released version in your own workflows.
+
+## Inputs
+
+The Command GitVersion action accepts the following inputs:
+
+```yaml
+targetPath:
+ description: Optionally supply the path to the working directory
+ required: false
+ default: ''
+disableShallowCloneCheck:
+ description: Whether to disable the check for shallow clone
+ required: false
+ default: 'false'
+arguments:
+ description: Arguments to send to GitVersion
+ required: true
+ default: ''
+```
+
+---
+
+## Execution Examples
+
+### Example 1
+
+
+ Show the effective configuration for GitVersion by running the /showConfig command.
+
+```yaml
+steps:
+ # gittools/actions/gitversion/setup@v2.0.1 action omitted for brevity.
+
+ - name: Display GitVersion config
+ uses: gittools/actions/gitversion/command@v2.0.1
+ with:
+ useConfigFile: true
+ arguments: '/showConfig'
+```
+
+
+
+### Example 2
+
+
+ Outputs the FullSemVer variable by running the /showvariable FullSemVer command.
+
+```yaml
+steps:
+ # gittools/actions/gitversion/setup@v2.0.1 action omitted for brevity.
+
+ - name: Output the FullSemVer variable
+ uses: gittools/actions/gitversion/command@v2.0.1
+ with:
+ arguments: '/showvariable FullSemVer'
+```
+
+
+
+### Example 3
+
+
+ Outputs the formatted version by running the /format {Major}.{Minor} command.
+
+```yaml
+steps:
+ # gittools/actions/gitversion/setup@v2.0.1 action omitted for brevity.
+
+ - name: Output the formatted version
+ uses: gittools/actions/gitversion/command@v2.0.1
+ with:
+ arguments: '/format {Major}.{Minor}' # any Output Variable can be used here
+```
+
+
diff --git a/docs/examples/github/gitversion/execute.md b/docs/examples/github/gitversion/execute.md
index b93a24b18..1dd9b2e1a 100644
--- a/docs/examples/github/gitversion/execute.md
+++ b/docs/examples/github/gitversion/execute.md
@@ -66,10 +66,6 @@ updateAssemblyInfoFilename:
description: Update versions in specified file
required: false
default: ''
-additionalArguments:
- description: Additional arguments to send to GitVersion
- required: false
- default: ''
```
## Outputs
@@ -174,24 +170,6 @@ steps:
### Example 4
-
- Show the effective configuration for GitVersion by running the /showConfig command (passed as an additional argument).
-
-```yaml
-steps:
- # gittools/actions/gitversion/setup@v2.0.1 action omitted for brevity.
-
- - name: Display GitVersion config
- uses: gittools/actions/gitversion/execute@v2.0.1
- with:
- useConfigFile: true
- additionalArguments: '/showConfig'
-```
-
-
-
-### Example 5
-
Calculate the version for the build. Disabling the cache and normalization.
@@ -208,7 +186,7 @@ steps:
-### Example 6
+### Example 5
Calculate the version for the build. Update the version in the AssemblyInfo files.
@@ -225,7 +203,7 @@ steps:
-### Example 7
+### Example 6
Calculate the version for the build. Override the configuration file with the specified values.
@@ -251,7 +229,7 @@ where `` is the ID assigned to the step that calls the action, by subsequent
The action also creates environment variables of the form `${{ env. }}` or `${{ env.GitVersion_ }}` for use by other steps in the same job.
-### Example 8
+### Example 7
Calculate the version for the build and use the output in a subsequent steps within the same job.
@@ -335,7 +313,7 @@ jobs:
-### Example 9
+### Example 8
Calculate the version for the build and use the output in a subsequent job.
diff --git a/docs/examples/github/gitversion/index.md b/docs/examples/github/gitversion/index.md
index 00140a6f6..dd6dbc977 100644
--- a/docs/examples/github/gitversion/index.md
+++ b/docs/examples/github/gitversion/index.md
@@ -11,3 +11,7 @@ Note: You need to run the Setup step before the Execute step, otherwise the Exec
## Execute GitVersion (gitversion/execute)
- [Execute](execute.md)
+
+## Execute GitVersion (gitversion/command)
+
+- [Command](command.md)
diff --git a/envs/gitversion/command/azure.env b/envs/gitversion/command/azure.env
new file mode 100644
index 000000000..cac9a3e98
--- /dev/null
+++ b/envs/gitversion/command/azure.env
@@ -0,0 +1,5 @@
+BUILD_SOURCESDIRECTORY=.
+AGENT_TEMPDIRECTORY=./.test/temp
+AGENT_TOOLSDIRECTORY=./.test/tools
+GITVERSION_PATH=./.test/tools/GitVersion.Tool/6.0.0
+INPUT_ARGUMENTS='/format {Major}.{Minor}.{Patch}.{Sha}'
diff --git a/envs/gitversion/command/github.env b/envs/gitversion/command/github.env
new file mode 100644
index 000000000..d62fa3a25
--- /dev/null
+++ b/envs/gitversion/command/github.env
@@ -0,0 +1,5 @@
+GITHUB_WORKSPACE=.
+RUNNER_TEMP=./.test/temp
+RUNNER_TOOL_CACHE=./.test/tools
+GITVERSION_PATH=./.test/tools/GitVersion.Tool/6.0.0
+INPUT_ARGUMENTS='/format {Major}.{Minor}.{Patch}.{Sha}'
diff --git a/envs/gitversion/command/local.env b/envs/gitversion/command/local.env
new file mode 100644
index 000000000..983329c96
--- /dev/null
+++ b/envs/gitversion/command/local.env
@@ -0,0 +1,5 @@
+AGENT_SOURCE_DIR=.
+AGENT_TEMP_DIR=./.test/temp
+AGENT_TOOLS_DIR=./.test/tools
+GITVERSION_PATH=./.test/tools/GitVersion.Tool/6.0.0
+INPUT_ARGUMENTS='/format {Major}.{Minor}.{Patch}.{Sha}'
diff --git a/gitversion/command/action.yml b/gitversion/command/action.yml
new file mode 100644
index 000000000..c0f5d3a84
--- /dev/null
+++ b/gitversion/command/action.yml
@@ -0,0 +1,22 @@
+name: gitversion-command
+description: GitHub Action for Easy Semantic Versioning with GitVersion. Run GitVersion with arguments.
+author: GitTools
+branding:
+ color: gray-dark
+ icon: git-pull-request
+runs:
+ using: node20
+ main: main.mjs
+inputs:
+ targetPath:
+ description: Optionally supply the path to the working directory
+ required: false
+ default: ''
+ disableShallowCloneCheck:
+ description: Whether to disable the check for shallow clone
+ required: false
+ default: 'false'
+ arguments:
+ description: Arguments to send to GitVersion
+ required: true
+ default: ''
diff --git a/gitversion/command/main.mjs b/gitversion/command/main.mjs
new file mode 100644
index 000000000..1b6f0e16f
--- /dev/null
+++ b/gitversion/command/main.mjs
@@ -0,0 +1,2 @@
+import { run } from '../../dist/tools/lib.mjs'
+await run('github', 'gitversion', 'command')
diff --git a/gitversion/execute/action.yml b/gitversion/execute/action.yml
index 045663d8f..f8178f752 100644
--- a/gitversion/execute/action.yml
+++ b/gitversion/execute/action.yml
@@ -47,10 +47,6 @@ inputs:
description: Update versions in specified file
required: false
default: ''
- additionalArguments:
- description: Additional arguments to send to GitVersion
- required: false
- default: ''
outputs:
major: # id of output
description: 'The Major value'
diff --git a/src/__tests__/tools/gitversion/runner.spec.ts b/src/__tests__/tools/gitversion/runner.spec.ts
index 8beb1e83a..2e86f1306 100644
--- a/src/__tests__/tools/gitversion/runner.spec.ts
+++ b/src/__tests__/tools/gitversion/runner.spec.ts
@@ -73,6 +73,32 @@ describe('GitVersion Runner', () => {
expect(result.stdout).toContain('Executing GenerateSetVersionMessage')
expect(result.stdout).toContain('Executing GenerateBuildLogOutput')
})
+
+ it.sequential('should output Major variable', async () => {
+ setEnv(toolPathVariable, toolPath)
+
+ setInputs({
+ arguments: '/showvariable major'
+ })
+
+ const result = await runner.run('command')
+
+ expect(result.code).toBe(0)
+ expect(result.stdout).toContain('2')
+ })
+
+ it.sequential('should output formatted version', async () => {
+ setEnv(toolPathVariable, toolPath)
+
+ setInputs({
+ arguments: '/format {Major}.{Minor}'
+ })
+
+ const result = await runner.run('command')
+
+ expect(result.code).toBe(0)
+ expect(result.stdout).toContain('2.0')
+ })
}
describe('Local Agent', () => {
diff --git a/src/__tests__/tools/gitversion/settings.spec.ts b/src/__tests__/tools/gitversion/settings.spec.ts
index 7f2fcdbda..0fd25ef4a 100644
--- a/src/__tests__/tools/gitversion/settings.spec.ts
+++ b/src/__tests__/tools/gitversion/settings.spec.ts
@@ -1,6 +1,6 @@
import { describe, it } from 'vitest'
import { IBuildAgent } from '@agents/common'
-import { type GitVersionExecuteSettings, GitVersionSettingsProvider } from '@tools/gitversion'
+import { type GitVersionCommandSettings, type GitVersionExecuteSettings, GitVersionSettingsProvider } from '@tools/gitversion'
import { expectValidSettings } from '../common/utils'
describe('GitVersion settings', () => {
@@ -14,8 +14,7 @@ describe('GitVersion settings', () => {
configFilePath: 'path',
overrideConfig: ['update-build-number=false'],
updateAssemblyInfo: true,
- updateAssemblyInfoFilename: 'path',
- additionalArguments: 'args'
+ updateAssemblyInfoFilename: 'path'
}
const buildAgent = {
@@ -30,4 +29,23 @@ describe('GitVersion settings', () => {
expectValidSettings(settings, gitVersionExecuteSettings)
})
+
+ it('should return GitVersionCommandSettings', () => {
+ const settings: GitVersionCommandSettings = {
+ targetPath: 'path',
+ disableShallowCloneCheck: true,
+ arguments: 'args'
+ }
+
+ const buildAgent = {
+ getInput: (input: keyof GitVersionCommandSettings) => settings[input] as string,
+ getBooleanInput: (input: keyof GitVersionCommandSettings) => settings[input] as boolean
+ } as IBuildAgent
+
+ const settingsProvider = new GitVersionSettingsProvider(buildAgent)
+
+ const gitVersionCommandSettings = settingsProvider.getGitVersionCommandSettings()
+
+ expectValidSettings(settings, gitVersionCommandSettings)
+ })
})
diff --git a/src/__tests__/tools/gitversion/tool.spec.ts b/src/__tests__/tools/gitversion/tool.spec.ts
index 3026d0187..ca12146b7 100644
--- a/src/__tests__/tools/gitversion/tool.spec.ts
+++ b/src/__tests__/tools/gitversion/tool.spec.ts
@@ -1,6 +1,6 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { IBuildAgent } from '@agents/common'
-import { type GitVersionOutput, type GitVersionExecuteSettings, GitVersionTool } from '@tools/gitversion'
+import { type GitVersionOutput, type GitVersionCommandSettings, type GitVersionExecuteSettings, GitVersionTool } from '@tools/gitversion'
class TestGitVersionTool extends GitVersionTool {
private _isValidInputFile = false
@@ -13,13 +13,17 @@ class TestGitVersionTool extends GitVersionTool {
return Promise.resolve(this._isValidInputFile)
}
- async getRepoDir(settings: GitVersionExecuteSettings): Promise {
+ async getRepoDir(settings: GitVersionExecuteSettings | GitVersionCommandSettings): Promise {
return super.getRepoDir(settings)
}
async getExecuteArguments(workDir: string, options: GitVersionExecuteSettings): Promise {
return super.getExecuteArguments(workDir, options)
}
+
+ async getCommandArguments(workDir: string, options: GitVersionCommandSettings): Promise {
+ return super.getCommandArguments(workDir, options)
+ }
}
describe('GitVersionTool', () => {
@@ -101,7 +105,7 @@ describe('GitVersionTool', () => {
tool = new TestGitVersionTool(buildAgent)
const repoDir = await tool.getRepoDir({
targetPath: ''
- } as GitVersionExecuteSettings)
+ } as GitVersionExecuteSettings | GitVersionCommandSettings)
expect(repoDir).toBe('workdir')
})
@@ -112,7 +116,7 @@ describe('GitVersionTool', () => {
tool = new TestGitVersionTool(buildAgent)
const repoDir = await tool.getRepoDir({
targetPath: ''
- } as GitVersionExecuteSettings)
+ } as GitVersionExecuteSettings | GitVersionCommandSettings)
expect(repoDir).toBe('.')
})
@@ -125,7 +129,7 @@ describe('GitVersionTool', () => {
tool = new TestGitVersionTool(buildAgent)
const repoDir = await tool.getRepoDir({
targetPath: 'targetDir'
- } as GitVersionExecuteSettings)
+ } as GitVersionExecuteSettings | GitVersionCommandSettings)
expect(repoDir).toBe('targetDir')
})
@@ -140,7 +144,7 @@ describe('GitVersionTool', () => {
await expect(
tool.getRepoDir({
targetPath: wrongDir
- } as GitVersionExecuteSettings)
+ } as GitVersionExecuteSettings | GitVersionCommandSettings)
).rejects.toThrowError(`Directory not found at ${wrongDir}`)
})
})
@@ -242,12 +246,19 @@ describe('GitVersionTool', () => {
'AssemblyInfo.cs'
])
})
+ })
+
+ describe('getCommandArguments', () => {
+ it('should return correct arguments for empty settings', async () => {
+ const args = await tool.getCommandArguments('workdir', {} as GitVersionCommandSettings)
+ expect(args).toEqual(['workdir'])
+ })
it('should return correct arguments for settings with additional arguments', async () => {
- const args = await tool.getExecuteArguments('workdir', {
- additionalArguments: '--some-arg --another-arg'
- } as GitVersionExecuteSettings)
- expect(args).toEqual(['workdir', '/output', 'json', '/output', 'buildserver', '--some-arg', '--another-arg'])
+ const args = await tool.getCommandArguments('workdir', {
+ arguments: '--some-arg --another-arg'
+ } as GitVersionCommandSettings)
+ expect(args).toEqual(['workdir', '--some-arg', '--another-arg'])
})
})
})
diff --git a/src/tools/gitversion/models.ts b/src/tools/gitversion/models.ts
index a99b23c0c..dc22969f7 100644
--- a/src/tools/gitversion/models.ts
+++ b/src/tools/gitversion/models.ts
@@ -1,4 +1,4 @@
-export type Commands = 'setup' | 'execute'
+export type Commands = 'setup' | 'execute' | 'command'
export enum ExecuteFields {
targetPath = 'targetPath',
@@ -9,8 +9,13 @@ export enum ExecuteFields {
configFilePath = 'configFilePath',
overrideConfig = 'overrideConfig',
updateAssemblyInfo = 'updateAssemblyInfo',
- updateAssemblyInfoFilename = 'updateAssemblyInfoFilename',
- additionalArguments = 'additionalArguments'
+ updateAssemblyInfoFilename = 'updateAssemblyInfoFilename'
+}
+
+export enum CommandFields {
+ targetPath = 'targetPath',
+ disableShallowCloneCheck = 'disableShallowCloneCheck',
+ arguments = 'arguments'
}
export type GitVersionExecuteSettings = {
@@ -23,7 +28,12 @@ export type GitVersionExecuteSettings = {
[ExecuteFields.overrideConfig]: string[]
[ExecuteFields.updateAssemblyInfo]: boolean
[ExecuteFields.updateAssemblyInfoFilename]: string
- [ExecuteFields.additionalArguments]: string
+}
+
+export type GitVersionCommandSettings = {
+ [CommandFields.targetPath]: string
+ [ExecuteFields.disableShallowCloneCheck]: boolean
+ [CommandFields.arguments]: string
}
export type GitVersionOutput = {
diff --git a/src/tools/gitversion/runner.ts b/src/tools/gitversion/runner.ts
index 689fa0ab0..410e2feb6 100644
--- a/src/tools/gitversion/runner.ts
+++ b/src/tools/gitversion/runner.ts
@@ -16,6 +16,8 @@ export class Runner implements IRunner {
return await this.setup()
case 'execute':
return await this.execute()
+ case 'command':
+ return await this.command()
}
}
@@ -97,6 +99,44 @@ export class Runner implements IRunner {
}
}
+ private async command(): Promise {
+ try {
+ this.disableTelemetry()
+
+ this.buildAgent.info('Executing GitVersion')
+
+ const result = await this.gitVersionTool.executeCommand()
+
+ if (result.code === 0) {
+ this.buildAgent.info('GitVersion executed successfully')
+ const stdout = result.stdout as string
+
+ this.buildAgent.info('GitVersion output:')
+ this.buildAgent.info('-------------------')
+ this.buildAgent.info(stdout)
+ this.buildAgent.info('-------------------')
+
+ this.buildAgent.setSucceeded('GitVersion executed successfully', true)
+ return result
+ } else {
+ this.buildAgent.debug('GitVersion failed')
+ const error = result.error
+ if (error instanceof Error) {
+ this.buildAgent.setFailed(error.message, true)
+ }
+ return result
+ }
+ } catch (error) {
+ if (error instanceof Error) {
+ this.buildAgent.setFailed(error.message, true)
+ }
+ return {
+ code: -1,
+ error
+ }
+ }
+ }
+
private disableTelemetry(): void {
this.buildAgent.info(`Running on: '${this.buildAgent.agentName}'`)
this.buildAgent.debug('Disabling telemetry')
diff --git a/src/tools/gitversion/settings.ts b/src/tools/gitversion/settings.ts
index 49076aa43..93bec300d 100644
--- a/src/tools/gitversion/settings.ts
+++ b/src/tools/gitversion/settings.ts
@@ -1,8 +1,10 @@
import { type ISettingsProvider, SettingsProvider } from '@tools/common'
-import { ExecuteFields, type GitVersionExecuteSettings } from './models'
+import { CommandFields, ExecuteFields, type GitVersionCommandSettings, type GitVersionExecuteSettings } from './models'
export interface IGitVersionSettingsProvider extends ISettingsProvider {
getGitVersionExecuteSettings(): GitVersionExecuteSettings
+
+ getGitVersionCommandSettings(): GitVersionCommandSettings
}
export class GitVersionSettingsProvider extends SettingsProvider implements IGitVersionSettingsProvider {
@@ -20,8 +22,6 @@ export class GitVersionSettingsProvider extends SettingsProvider implements IGit
const updateAssemblyInfo = this.buildAgent.getBooleanInput(ExecuteFields.updateAssemblyInfo)
const updateAssemblyInfoFilename = this.buildAgent.getInput(ExecuteFields.updateAssemblyInfoFilename)
- const additionalArguments = this.buildAgent.getInput(ExecuteFields.additionalArguments)
-
return {
targetPath,
disableCache,
@@ -31,8 +31,19 @@ export class GitVersionSettingsProvider extends SettingsProvider implements IGit
configFilePath,
overrideConfig,
updateAssemblyInfo,
- updateAssemblyInfoFilename,
- additionalArguments
+ updateAssemblyInfoFilename
+ }
+ }
+
+ getGitVersionCommandSettings(): GitVersionCommandSettings {
+ const targetPath = this.buildAgent.getInput(CommandFields.targetPath)
+ const disableShallowCloneCheck = this.buildAgent.getBooleanInput(CommandFields.disableShallowCloneCheck)
+ const args = this.buildAgent.getInput(CommandFields.arguments)
+
+ return {
+ targetPath,
+ disableShallowCloneCheck,
+ arguments: args
}
}
}
diff --git a/src/tools/gitversion/tool.ts b/src/tools/gitversion/tool.ts
index 8a4094549..b48b155e9 100644
--- a/src/tools/gitversion/tool.ts
+++ b/src/tools/gitversion/tool.ts
@@ -1,6 +1,6 @@
import { type ExecResult } from '@agents/common'
import { DotnetTool, keysOf } from '@tools/common'
-import { type GitVersionExecuteSettings, type GitVersionOutput } from './models'
+import { type GitVersionCommandSettings, type GitVersionExecuteSettings, type GitVersionOutput } from './models'
import { GitVersionSettingsProvider, type IGitVersionSettingsProvider } from './settings'
export class GitVersionTool extends DotnetTool {
@@ -36,6 +36,18 @@ export class GitVersionTool extends DotnetTool {
return await this.executeTool(args)
}
+ async executeCommand(): Promise {
+ const settings = this.settingsProvider.getGitVersionCommandSettings()
+ const workDir = await this.getRepoDir(settings)
+
+ await this.checkShallowClone(settings, workDir)
+
+ const args = await this.getCommandArguments(workDir, settings)
+
+ await this.setDotnetRoot()
+ return await this.executeTool(args)
+ }
+
writeGitVersionToAgent(output: GitVersionOutput): void {
for (const property of keysOf(output)) {
const name = this.toCamelCase(property)
@@ -54,12 +66,12 @@ export class GitVersionTool extends DotnetTool {
}
}
- protected async getRepoDir(settings: GitVersionExecuteSettings): Promise {
+ protected async getRepoDir(settings: GitVersionExecuteSettings | GitVersionCommandSettings): Promise {
return await super.getRepoPath(settings.targetPath)
}
protected async getExecuteArguments(workDir: string, options: GitVersionExecuteSettings): Promise {
- let args = [workDir, '/output', 'json', '/output', 'buildserver']
+ const args = [workDir, '/output', 'json', '/output', 'buildserver']
const {
useConfigFile,
@@ -68,8 +80,7 @@ export class GitVersionTool extends DotnetTool {
configFilePath,
overrideConfig,
updateAssemblyInfo,
- updateAssemblyInfoFilename,
- additionalArguments
+ updateAssemblyInfoFilename
//
} = options
@@ -111,8 +122,14 @@ export class GitVersionTool extends DotnetTool {
}
}
- if (additionalArguments) {
- args = args.concat(this.argStringToArray(additionalArguments))
+ return args
+ }
+
+ protected async getCommandArguments(workDir: string, options: GitVersionCommandSettings): Promise {
+ let args = [workDir]
+
+ if (options.arguments) {
+ args = args.concat(this.argStringToArray(options.arguments))
}
return args
}
@@ -179,7 +196,7 @@ export class GitVersionTool extends DotnetTool {
return args
}
- private async checkShallowClone(settings: GitVersionExecuteSettings, workDir: string): Promise {
+ private async checkShallowClone(settings: GitVersionExecuteSettings | GitVersionCommandSettings, workDir: string): Promise {
if (!settings.disableShallowCloneCheck) {
const isShallowResult = await this.execute('git', ['-C', workDir, 'rev-parse', '--is-shallow-repository'])
if (isShallowResult.code === 0 && isShallowResult.stdout.trim() === 'true') {