Skip to content

Commit

Permalink
Publish Helm chart to ghcr.io/telepresenceio
Browse files Browse the repository at this point in the history
Relates to #3649
Closes #3657

Signed-off-by: Thomas Hallgren <[email protected]>
  • Loading branch information
thallgren committed Aug 14, 2024
1 parent bebecb1 commit 801fe05
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ jobs:
platforms: linux/amd64,linux/arm64
- name: Build image dependencies
run: make images-deps
- name: Make helm chart
run: make helm-chart
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Push client image
Expand All @@ -77,6 +79,8 @@ jobs:
run: |
docker buildx build --platform=linux/amd64,linux/arm64 --build-arg TELEPRESENCE_VERSION=${{env.TELEPRESENCE_SEMVER}} \
--push --tag ${{env.TELEPRESENCE_REGISTRY}}/tel2:${{env.TELEPRESENCE_SEMVER}} -f build-aux/docker/images/Dockerfile.traffic .
- name: Push Helm Chart
run: helm push build-output/telepresence-chart.tgz oci://${{env.TELEPRESENCE_REGISTRY}}
- name: Log out from registry
if: always()
run: docker logout
Expand Down
7 changes: 7 additions & 0 deletions build-aux/main.mk
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,13 @@ push-client-image: client-image ## (Build) Push the client container image to $(
.PHONY: push-images
push-images: push-tel2-image push-client-image

.PHONY: helm-chart
helm-chart: $(BUILDDIR)/telepresence-chart.tgz

$(BUILDDIR)/telepresence-chart.tgz: $(wildcard charts/telepresence/**/*)
mkdir -p $(BUILDDIR)
go run packaging/helmpackage.go -o $@ -v $(TELEPRESENCE_SEMVER)

.PHONY: clobber
clobber: ## (Build) Remove all build artifacts and tools
rm -rf $(BUILDDIR)
Expand Down
46 changes: 46 additions & 0 deletions packaging/helmpackage.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package main

import (
"flag"
"log"
"os"

"github.com/blang/semver/v4"

telcharts "github.com/telepresenceio/telepresence/v2/charts"
)

type sv semver.Version

func (v *sv) String() string {
return (*semver.Version)(v).String()
}

func (v *sv) Set(s string) error {
ver, err := semver.Parse(s)
if err == nil {
*v = sv(ver)
}
return err
}

func main() {
var output string
var version sv
flag.StringVar(&output, "o", "", "output file")
flag.Var(&version, "v", "Helm chart version")
flag.Parse()
err := packageHelmChart(output, semver.Version(version))
if err != nil {
log.Fatal(err)
}
}

func packageHelmChart(filename string, version semver.Version) error {
fh, err := os.Create(filename)
if err != nil {
return err
}
defer fh.Close()
return telcharts.WriteChart(telcharts.DirTypeTelepresence, fh, "telepresence", version.String())
}

0 comments on commit 801fe05

Please sign in to comment.