Skip to content

Commit

Permalink
Revert using yq to replace YAML values
Browse files Browse the repository at this point in the history
  • Loading branch information
pkosiec committed Jan 26, 2022
1 parent 0debf8e commit 505bf6f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/branch-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,6 @@ jobs:
uses: actions/checkout@v2
with:
fetch-depth: 2 # To be able to compare with the previous commit and detect changed files
- name: Install yq
run: sudo snap install yq --channel=v4/stable
- uses: google-github-actions/setup-gcloud@master
with:
service_account_key: ${{ secrets.CAPACT_GCS_CREDS }}
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/make-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ jobs:
go-version: ${{env.GO_VERSION}}
- name: Set up GoReleaser
run: go install github.com/goreleaser/goreleaser@v1.1.0
- name: Install yq
run: sudo snap install yq --channel=v4/stable
- name: Set up GCS
uses: google-github-actions/setup-gcloud@master
with:
Expand Down
12 changes: 7 additions & 5 deletions hack/make-release.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
#!/bin/bash

# TODO: Refactor this script to not use error-prone sed usage
# See discussion https://github.com/capactio/capact/pull/617

set -e

CURRENT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
REPO_ROOT_DIR=$(cd "${CURRENT_DIR}/.." && pwd)
readonly CURRENT_DIR
readonly REPO_ROOT_DIR


release::update_helm_charts_version() {
local -r release_version="$1"
local -r deploy_dir="${REPO_ROOT_DIR}/deploy/kubernetes/charts"

for d in "${deploy_dir}"/*/ ; do
yq eval -i ".version = \"${release_version}\"" "${d}/Chart.yaml"
sed -i.bak "s/^version: .*/version: ${release_version}/g" "${d}/Chart.yaml"
done
}

Expand All @@ -28,17 +30,17 @@ release::make_prepare_release_commit() {

release::set_capact_images_in_charts() {
local -r image_tag="$1"
yq eval -i ".global.containerRegistry.overrideTag = \"${image_tag}\"" "${REPO_ROOT_DIR}/deploy/kubernetes/charts/capact/values.yaml"
sed -E -i.bak "s/overrideTag: \".+\"/overrideTag: \"${image_tag}\"/g" "${REPO_ROOT_DIR}/deploy/kubernetes/charts/capact/values.yaml"
}

release::set_dashboard_image_in_chart() {
local -r image_tag="$1"
yq eval -i ".dashboard.image.tag = \"${image_tag}\"" "${REPO_ROOT_DIR}/deploy/kubernetes/charts/capact/values.yaml"
sed -E -i.bak "s/tag: \".+\"/tag: \"${image_tag}\"/g" "${REPO_ROOT_DIR}/deploy/kubernetes/charts/capact/values.yaml"
}

release::set_hub_manifest_source_branch() {
local -r branch="$1"
yq eval -i ".populator.manifestsLocations[0].branch = \"${branch}\"" "${REPO_ROOT_DIR}/deploy/kubernetes/charts/capact/charts/hub-public/values.yaml"
sed -E -i.bak "s/branch: .+/branch: ${branch}/g" "${REPO_ROOT_DIR}/deploy/kubernetes/charts/capact/charts/hub-public/values.yaml"
}

release::make_release_commit() {
Expand Down
4 changes: 2 additions & 2 deletions hack/release-charts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ setChartVersionAndImageTagToCommitSHA() {
readonly version="${GITHUB_SHA:0:7}"

for chart in "${charts[@]}"; do
yq eval -i ".version = .version + \"-${version}\"" "${DEPLOY_CHARTS_DIR}/${chart}/Chart.yaml"
sed -i.bak "/^version: / s/$/-${version}/" "${DEPLOY_CHARTS_DIR}/${chart}/Chart.yaml"
done

yq eval -i ".global.containerRegistry.overrideTag = \"${version}\"" "${DEPLOY_CHARTS_DIR}/capact/values.yaml"
sed -i.bak "s/overrideTag: \"latest\"/overrideTag: \"${version}\"/g" "${DEPLOY_CHARTS_DIR}/capact/values.yaml"
}

main() {
Expand Down

0 comments on commit 505bf6f

Please sign in to comment.