1- name : goreleaser
1+ name : release
22
33on :
44 push :
55 tags :
66 - " v[0-9]+.[0-9]+.[0-9]+"
7+ - " v[0-9]+.[0-9]+.[0-9]+-testing[0-9]+"
78
89permissions :
910 contents : write
1011
12+ env :
13+ GH_REGISTRY : ghcr.io
14+ IMAGE_NAME : ${{ github.repository }}
15+ RELEASE_VERSION : ${{ github.ref_name }}
16+
1117jobs :
1218 goreleaser :
1319 runs-on : ubuntu-latest
@@ -18,11 +24,91 @@ jobs:
1824 uses : actions/setup-go@v3
1925 with :
2026 go-version : ' 1.24.3'
21- - uses : anchore/sbom-action/download-syft@v0.13.3
27+ - uses : anchore/sbom-action/download-syft@v0.20.6
2228 - name : Run GoReleaser
2329 uses : goreleaser/goreleaser-action@v4
2430 with :
2531 distribution : goreleaser
2632 args : release --clean
2733 env :
2834 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
35+
36+ packagerelease :
37+ runs-on : ubuntu-latest
38+ permissions :
39+ contents : read
40+ packages : write
41+ attestations : write
42+ id-token : write
43+ steps :
44+ - name : Checkout repository
45+ uses : actions/checkout@v5
46+ - name : Log in to the GitHub Container registry
47+ uses : docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
48+ with :
49+ registry : ${{ env.GH_REGISTRY }}
50+ username : ${{ github.actor }}
51+ password : ${{ secrets.GITHUB_TOKEN }}
52+ - name : Extract metadata (tags, labels) for Docker
53+ id : meta
54+ uses : docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
55+ with :
56+ images : ${{ env.GH_REGISTRY }}/${{ env.IMAGE_NAME }}
57+ - name : Set up QEMU
58+ uses : docker/setup-qemu-action@v3
59+ - name : Set up Docker Buildx
60+ uses : docker/setup-buildx-action@v3
61+ - name : Build and push Docker image
62+ id : push
63+ uses : docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
64+ with :
65+ context : .
66+ platforms : linux/amd64,linux/arm64
67+ push : true
68+ tags : ${{ steps.meta.outputs.tags }}
69+ labels : ${{ steps.meta.outputs.labels }}
70+ build-args : |
71+ VERSION=${{ env.RELEASE_VERSION }}
72+ - name : Login to Docker Hub
73+ uses : docker/login-action@v2
74+ with :
75+ username : ${{ secrets.DOCKERHUB_USERNAME }}
76+ password : ${{ secrets.DOCKERHUB_TOKEN }}
77+ - name : Build and push
78+ uses : docker/build-push-action@v4
79+ with :
80+ context : .
81+ platforms : linux/amd64,linux/arm64
82+ push : true
83+ tags : |
84+ controlplane/netassert:${{ github.ref_name }}
85+ controlplane/netassert:latest
86+ build-args : |
87+ VERSION=${{ env.RELEASE_VERSION }}
88+
89+ - name : Generate artifact attestation
90+ uses : actions/attest-build-provenance@v3
91+ with :
92+ subject-name : ${{ env.GH_REGISTRY }}/${{ env.IMAGE_NAME}}
93+ subject-digest : ${{ steps.push.outputs.digest }}
94+ push-to-registry : true
95+
96+ - name : Set up Helm
97+ uses : azure/setup-helm@v4
98+ - name : Setup yq
99+ uses : mikefarah/yq@v4
100+ - name : Log in to GitHub Container Registry
101+ run : |
102+ echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io -u ${{ github.actor }} --password-stdin
103+ - name : Prepare and package Helm chart
104+ run : |
105+ CLEAN_VERSION=$(echo "$RELEASE_VERSION" | sed 's/^v//')
106+ echo "Using chart version and appVersion: $CLEAN_VERSION"
107+ yq -i ".image.tag = \"${RELEASE_VERSION}\"" ./helm/values.yaml
108+ yq -i ".version = \"${CLEAN_VERSION}\"" ./helm/Chart.yaml
109+ yq -i ".appVersion = \"${CLEAN_VERSION}\"" ./helm/Chart.yaml
110+ helm package ./helm -d .
111+ - name : Push Helm chart to GHCR
112+ run : |
113+ CLEAN_VERSION=$(echo "$RELEASE_VERSION" | sed 's/^v//')
114+ helm push "./netassert-${CLEAN_VERSION}.tgz" oci://ghcr.io/${{ github.repository_owner }}/charts
0 commit comments