mirror of
https://github.com/malarinv/iperf3-monitor.git
synced 2026-11-06 14:50:28 +00:00
This commit implements a verified yq command syntax in the `.github/workflows/release.yml` file to ensure correct and reliable updating of Chart.yaml version and appVersion from Git tags. The previous attempts faced issues with yq argument parsing and environment variable substitution. The new commands: VERSION=$VERSION yq e -i '.version = strenv(VERSION)' ./charts/iperf3-monitor/Chart.yaml VERSION=$VERSION yq e -i '.appVersion = strenv(VERSION)' ./charts/iperf3-monitor/Chart.yaml were tested and confirmed to correctly modify the Chart.yaml file as intended. This change should resolve the issues where chart versions were being set incorrectly or to empty strings during the release process.
95 lines
2.7 KiB
YAML
95 lines
2.7 KiB
YAML
name: Release iperf3-monitor
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v*.*.*"
|
|
|
|
env:
|
|
REGISTRY: ghcr.io
|
|
IMAGE_NAME: ${{ github.repository }}
|
|
|
|
jobs:
|
|
lint-and-test:
|
|
name: Lint and Test
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Check out code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Set up Helm
|
|
uses: azure/setup-helm@v3
|
|
with:
|
|
version: v3.10.0
|
|
|
|
- name: Helm Lint
|
|
run: helm lint ./charts/iperf3-monitor
|
|
|
|
build-and-publish-image:
|
|
name: Build and Publish Docker Image
|
|
runs-on: ubuntu-latest
|
|
needs: lint-and-test
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
steps:
|
|
- name: Check out code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Log in to GitHub Container Registry
|
|
uses: docker/login-action@v2
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Extract metadata (tags, labels) for Docker
|
|
id: meta
|
|
uses: docker/metadata-action@v4
|
|
with:
|
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v4
|
|
with:
|
|
context: ./exporter
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
|
|
package-and-publish-chart:
|
|
name: Package and Publish Helm Chart
|
|
runs-on: ubuntu-latest
|
|
needs: build-and-publish-image
|
|
permissions:
|
|
contents: write # Needed by stefanprodan/helm-gh-pages to push to gh-pages branch
|
|
steps:
|
|
- name: Check out code
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0 # Fetch all history for helm-gh-pages to calculate chart index
|
|
|
|
- name: Set up Helm
|
|
uses: azure/setup-helm@v3
|
|
with:
|
|
version: v3.10.0
|
|
|
|
- name: Install yq
|
|
run: |
|
|
sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq &&\
|
|
sudo chmod +x /usr/bin/yq
|
|
|
|
- name: Set Chart Version from Tag
|
|
run: |
|
|
VERSION=$(echo "${{ github.ref_name }}" | sed 's/^v//')
|
|
VERSION=$VERSION yq e -i '.version = strenv(VERSION)' ./charts/iperf3-monitor/Chart.yaml
|
|
VERSION=$VERSION yq e -i '.appVersion = strenv(VERSION)' ./charts/iperf3-monitor/Chart.yaml
|
|
cat ./charts/iperf3-monitor/Chart.yaml # Optional: print updated Chart.yaml
|
|
|
|
- name: Publish Helm chart
|
|
uses: stefanprodan/helm-gh-pages@v1.6.0
|
|
with:
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
charts_dir: ./charts
|
|
charts_url: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}
|