Collapse nested edition guards into single if-and conditions #290
This file contains hidden or 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
| 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 | |
| varnish_cache_version: | |
| description: "Varnish Cache OSS version to publish (required when publishing varnish-cache, e.g. 9.0.3)" | |
| type: string | |
| required: false | |
| 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 | |
| pip install yq | |
| sudo apt-get update | |
| sudo apt-get install -y --no-install-recommends bats parallel | |
| - name: "Generate community chart" | |
| if: matrix.chart == 'varnish-cache' | |
| run: | | |
| if [ "${{ github.event.inputs.publish }}" = "varnish-cache" ]; then | |
| if [ -z "${{ github.event.inputs.varnish_cache_version }}" ]; then | |
| echo "Error: varnish_cache_version input is required when publishing varnish-cache" | |
| exit 1 | |
| fi | |
| VERSION="${{ github.event.inputs.varnish_cache_version }}" | |
| else | |
| VERSION="latest" | |
| fi | |
| bash ci/publish-community.sh "$VERSION" dist/varnish-cache | |
| - name: "Add Helm dependencies" | |
| # See also: https://circleci.com/docs/env-vars/#alpine-linux | |
| run: | | |
| CHART_DIR=${{ matrix.chart == 'varnish-cache' && 'dist/varnish-cache' || matrix.chart }} | |
| cd "$CHART_DIR" | |
| # 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: | | |
| CHART_DIR=${{ matrix.chart == 'varnish-cache' && 'dist/varnish-cache' || matrix.chart }} | |
| helm package "$CHART_DIR" | |
| 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: | | |
| CHART_DIR=${{ matrix.chart == 'varnish-cache' && 'dist/varnish-cache' || matrix.chart }} | |
| VERSION=$(yq -r '.version' "$CHART_DIR/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 |