Skip to content

Fix the version bumper on multi-line version output (#132) #316

Fix the version bumper on multi-line version output (#132)

Fix the version bumper on multi-line version output (#132) #316

Workflow file for this run

name: Build and push
on:
push:
branches:
- "*"
workflow_dispatch:
inputs:
publish:
description: Publish
type: choice
options:
- varnish-cache
- orca-chart
- varnish-enterprise
- varnish-controller
- varnish-controller-router
jobs:
build_and_push:
strategy:
matrix:
chart:
- varnish-cache
- orca-chart
- varnish-enterprise
- varnish-controller
- varnish-controller-router
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: "Install system dependencies"
run: |
curl -sL https://get.helm.sh/helm-v3.19.0-linux-amd64.tar.gz -o /tmp/helm.tar.gz
tar xavf /tmp/helm.tar.gz
mv linux-amd64/helm /usr/local/bin/helm
sudo apt-get update
sudo apt-get install -y --no-install-recommends bats parallel
- name: "Add Helm dependencies"
# See also: https://circleci.com/docs/env-vars/#alpine-linux
run: |
cd ${{ matrix.chart }}
# Helm is painful https://github.com/helm/helm/issues/8036
i=0
yq -r '.dependencies[]?.repository' < Chart.yaml | while read -r p; do
i=$((i+1))
helm repo add dep$i "$p"
done
helm dependency build
- name: "Unit tests"
run: |
if [ -x ${{ matrix.chart }}/test/unit/run.sh ]; then
${{ matrix.chart }}/test/unit/run.sh -j 50
fi
if [ -x ${{ matrix.chart }}/test/unit_common/run.sh ]; then
${{ matrix.chart }}/test/unit_common/run.sh -j 50
fi
- name: Create package
run: |
helm package "${{ matrix.chart }}"
mkdir -p /tmp/artifacts
cp "${{ matrix.chart }}"-*.tgz /tmp/artifacts
- name: "Check version does not already exist"
if: ${{ github.event.inputs.publish == matrix.chart }}
run: |
VERSION=$(yq -r '.version' "${{ matrix.chart }}/Chart.yaml")
echo ${{ secrets.DOCKERHUB_TOKEN }} | helm registry login -u "varnish" --password-stdin registry-1.docker.io
if helm pull "oci://registry-1.docker.io/varnish/${{ matrix.chart }}" --version "$VERSION" --destination /tmp 2>/dev/null; then
echo "Error: ${{ matrix.chart }} version $VERSION already exists in the registry"
exit 1
fi
- name: "Push chart"
if: ${{ github.event.inputs.publish == matrix.chart }}
run: |
echo ${{ secrets.DOCKERHUB_TOKEN }} | helm registry login -u "varnish" --password-stdin registry-1.docker.io
helm push "${{ matrix.chart }}"-*.tgz "oci://registry-1.docker.io/varnish"
- name: Push to packagecloud
if: ${{ github.event.inputs.publish == matrix.chart }}
run: |
sudo gem install package_cloud
PACKAGECLOUD_TOKEN=${{ secrets.PACKAGECLOUD_TOKEN }} package_cloud push varnishplus/helm-staging/helm/v1 "${{ matrix.chart }}"-*.tgz