Remove goreleaser and fix helm packaging (#6)

Goreleaser was causing issues when helm chart action created releases
for packaged helm chart, this PR replaces goreleaser with a much simpler
build and push model, and returns packaged helm charts to normal.
This commit is contained in:
M. Essam
2025-03-05 09:03:04 +01:00
committed by GitHub
parent 3716e5daba
commit cea60745d2
22 changed files with 238 additions and 346 deletions
+30 -44
View File
@@ -8,13 +8,8 @@ on:
- main
pull_request:
env:
GORELEASER_VER: "v2.3.2"
jobs:
release:
env:
flags: ""
runs-on: ubuntu-latest
permissions:
contents: read
@@ -24,51 +19,42 @@ jobs:
id-token: write
steps:
- name: Parse semver string
id: semver_parser
uses: booxmedialtd/ws-action-parse-semver@v1
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
input_string: ${{ (startsWith(github.ref, 'refs/tags/v') && github.ref) || 'refs/tags/v0.0.0' }}
version_extractor_regex: '\/v(.*)$'
# list of Docker images to use as base name for tags
images: |
netbirdio/kubernetes-operator
# generate Docker tags based on the following events/attributes
tags: |
type=ref,event=pr
type=ref,event=branch
type=semver,pattern={{version}}
- if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
run: echo "flags=--snapshot" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # It is required for GoReleaser to work properly
- name: Install modules
run: go mod tidy
- name: check git status
run: git --no-pager diff --exit-code
# Set up BuildKit Docker container builder to be able to build
# multi-platform images and export cache
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Login to Docker hub
- name: Login to Docker Hub
if: github.repository == github.event.pull_request.head.repo.full_name || !github.head_ref
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Install OS build dependencies
run: sudo apt update && sudo apt install -y -q gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Install goversioninfo
run: go install github.com/josephspurrier/goversioninfo/cmd/goversioninfo@233067e
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v6
with:
version: ${{ env.GORELEASER_VER }}
args: release --clean ${{ env.flags }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: |
"org.opencontainers.image.created={{.Date}}"
"org.opencontainers.image.title={{.ProjectName}}"
"org.opencontainers.image.version={{.Version}}"
"org.opencontainers.image.revision={{.FullCommit}}"
"org.opencontainers.image.version={{.Version}}"
"maintainer=dev@netbird.io"
+14 -38
View File
@@ -4,7 +4,7 @@ on:
push:
paths:
# update this file to trigger helm chart release
- 'helm/netbird-operator/Chart.yaml'
- 'helm/kubernetes-operator/Chart.yaml'
branches:
- main
@@ -18,49 +18,25 @@ jobs:
contents: write
pages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v3.1.0
with:
fetch-depth: 0
- name: Set ENVs
id: env-setup
- name: Configure Git
run: |
echo "SHA_SHORT=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Package Charts
run: |
# Package charts
mkdir -p charts/.ci-build
echo "Setting chart version to ${{ steps.env-setup.outputs.CHART_VERSION }}"
for DIR in $CHART_BASE_DIR/*; do
# Check if Chart.yaml exists in this directory
if [ -f "${DIR}/Chart.yaml" ]; then
echo "Packaging ${DIR}"
helm dependency update $DIR
helm lint $DIR
helm package $DIR --destination charts/.ci-build
fi
done
git fetch --all
- name: Upload chart artifacts
uses: actions/upload-artifact@v4
- name: Install Helm
uses: azure/setup-helm@v3.4
with:
name: helm-charts-${{ github.ref_name }}
path: charts/.ci-build/*
retention-days: 30
version: v3.4.2
- name: Publish to GH-Pages
id: ghpublish
run: |
git checkout $GH_PAGES_BRANCH --force
helm repo index charts/.ci-build/ --merge index.yaml --url ${{ github.server_url }}/${{github.repository}}/releases/download/${{ github.ref_name }}
cp charts/.ci-build/index.yaml index.yaml
echo "New index:" && cat index.yaml
git add index.yaml charts
git commit -a -m "bot: update pages index for helm charts"
git push origin $GH_PAGES_BRANCH
- name: Run chart-releaser
uses: helm/chart-releaser-action@v1.4.1
with:
charts_dir: helm
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
CR_RELEASE_NAME_TEMPLATE: "helm-v{{ .Version }}"
+2 -2
View File
@@ -44,7 +44,7 @@ jobs:
- name: Lint Helm Chart
run: |
helm lint ./helm/netbird-operator
helm lint ./helm/kubernetes-operator
- name: Install cert-manager via Helm
run: |
@@ -60,7 +60,7 @@ jobs:
- name: Install Helm chart for project
run: |
helm install test-chart --create-namespace --namespace netbird --set 'operator.image.tag=debug' ./helm/netbird-operator
helm install test-chart --create-namespace --namespace netbird --set 'operator.image.tag=debug' ./helm/kubernetes-operator
- name: Check Helm release status
run: |