Skip to content

Commit

Permalink
🧹 Use own yq installation (#2558)
Browse files Browse the repository at this point in the history
* 🧹 Use own yq installation

* Add the GOFLAGS in yq goinstall

Co-authored-by: David Simansky <dsimansk@redhat.com>

* Call yq using go-run command

---------

Co-authored-by: David Simansky <dsimansk@redhat.com>
  • Loading branch information
cardil and dsimansk committed Mar 13, 2024
1 parent 19b784c commit c9dcd9f
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 38 deletions.
8 changes: 0 additions & 8 deletions .github/workflows/bump.yaml
Expand Up @@ -24,14 +24,6 @@ jobs:
with:
go-version: 1.21.x

- name: Install prerequisites
env:
YQ_VERSION: 3.4.0
run: |
sudo wget https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64 -O /usr/bin/yq
sudo chmod +x /usr/bin/yq
sudo mv /usr/bin/yq /usr/local/bin/yq
- name: Checkout openshift-knative/serverless-operator
uses: actions/checkout@v4
with:
Expand Down
8 changes: 0 additions & 8 deletions .github/workflows/dependabot-deps.yaml
Expand Up @@ -24,14 +24,6 @@ jobs:
with:
go-version: 1.21.x

- name: Install prerequisites
env:
YQ_VERSION: 3.4.0
run: |
sudo wget https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64 -O /usr/bin/yq
sudo chmod +x /usr/bin/yq
sudo mv /usr/bin/yq /usr/local/bin/yq
- name: Run ./hack/update-deps.sh
working-directory: ./src/github.com/${{ github.repository }}
run: ./hack/update-deps.sh
Expand Down
9 changes: 0 additions & 9 deletions .github/workflows/release-generate-ci.yaml
Expand Up @@ -24,15 +24,6 @@ jobs:
with:
go-version: 1.21.x

- name: Install prerequisites
env:
YQ_VERSION: 3.4.0
run: |
sudo wget https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64 -O /usr/bin/yq
sudo chmod +x /usr/bin/yq
sudo mv /usr/bin/yq /usr/local/bin/yq
- name: Checkout openshift-knative/serverless-operator
uses: actions/checkout@v4
with:
Expand Down
12 changes: 2 additions & 10 deletions .github/workflows/validate.yaml
Expand Up @@ -26,14 +26,6 @@ jobs:
with:
go-version: 1.21.x

- name: Install prerequisites
env:
YQ_VERSION: 3.4.0
run: |
sudo wget https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64 -O /usr/bin/yq
sudo chmod +x /usr/bin/yq
sudo mv /usr/bin/yq /usr/local/bin/yq
- name: Checkout
uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -110,8 +102,8 @@ jobs:
working-directory: ./src/github.com/${{ github.repository }}
run: |
csv="olm-catalog/serverless-operator/manifests/serverless-operator.clusterserviceversion.yaml"
if [[ "$(yq read "$csv" spec.replaces)" == "" || \
"$(yq read "$csv" 'metadata.annotations."olm.skipRange"')" == "" ]]; then
if [[ "$(GOFLAGS='' go run github.com/mikefarah/yq/v3@latest read "$csv" spec.replaces)" == "" || \
"$(GOFLAGS='' go run github.com/mikefarah/yq/v3@latest read "$csv" 'metadata.annotations."olm.skipRange"')" == "" ]]; then
echo '::error:: Missing spec.replaces or metadata.annotations."olm.skipRange" in CSV.'
exit 34
fi
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -11,7 +11,7 @@ For the scripts in this repository to work properly, the following requirements
build images from code)
- `bash` (4.0.0 or newer)
- `make`
- `yq` (3.4.0)
- `helm`

## Install an unreleased version

Expand Down
13 changes: 11 additions & 2 deletions hack/lib/metadata.bash
@@ -1,7 +1,16 @@
#!/usr/bin/env bash

# Make sure yq is on PATH.
yq > /dev/null || exit 127
function yq() {
local thisfile rootdir bindir
thisfile=$(realpath "${BASH_SOURCE[0]}")
rootdir=$(dirname "$(dirname "$(dirname "${thisfile}")")")
bindir="${rootdir}/_output/bin"
if [[ ! -f "${bindir}/yq" ]]; then
mkdir -p "${bindir}"
GOBIN="${bindir}" GOFLAGS='' go install github.com/mikefarah/yq/v3@latest
fi
"${bindir}/yq" "$@"
}

#######################################
# Gets a value from a metadata file
Expand Down

0 comments on commit c9dcd9f

Please sign in to comment.