Skip to content

Commit

Permalink
ci: add install-go-from-aquaconfig.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
sheldonhull authored Dec 22, 2023
1 parent 6592ea0 commit d76bee4
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions pipelines/templates/install-go-from-aquaconfig.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
parameters:
# - name: GO_VERSION # set dynamically in the task
# type: string
# default: 1.x
- name: GOPATH
type: string
default: $(Agent.HomeDirectory)/go
- name: workingDirectory
type: string
default: $(Build.SourcesDirectory)
steps:
- bash: |
# Search for the aqua.yaml file
if [[ -f "aqua.yaml" ]]; then
file="aqua.yaml"
elif [[ -f "aqua/aqua.yaml" ]]; then
file="aqua/aqua.yaml"
elif [[ -f ".aqua/aqua.yaml" ]]; then
file=".aqua/aqua.yaml"
else
echo "Error: aqua.yaml file not found."
echo "##vso[task.logissue type=warning]unable to find aqua config, behavior with tools might unpredictable"
fi
echo "found aqua.yaml at: $file"
GO_VERSION=$(grep -oP 'golang/go@go\\K[\\d\\.]+' "${file}")
echo "##vso[task.setvariable variable=GO_VERSION;isreadonly=true;isoutput=true;]${GO_VERSION}"
echo "##vso[task.setvariable variable=GO_VERSION;isreadonly=true;]${GO_VERSION}"
echo "👉 use go version: ${GO_VERSION}"
displayName: set-go-version
name: getgoversion
workingDirectory: ${{ parameters.workingDirectory }}
# condition: and(succeeded(), ne(variables['Agent.OS'], 'Windows_NT')) # won't work on windows
- task: GoTool@0
displayName: install-go
# condition: and(succeeded(), ne(variables['Agent.OS'], 'Windows_NT'))
inputs:
version: $(getgoversion.GO_VERSION)
goPath: $(GOPATH)

0 comments on commit d76bee4

Please sign in to comment.