-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add install-go-from-aquaconfig.yml
- Loading branch information
1 parent
6592ea0
commit d76bee4
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |