diff --git a/.github/workflows/make-release.yml b/.github/workflows/make-release.yml deleted file mode 100644 index 51e240014..000000000 --- a/.github/workflows/make-release.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Image release - -on: - push: - tags: - - 'v**' - -jobs: - build_and_push_to_ghcr: - name: Create docker release and publish to ghcr - runs-on: ubuntu-latest - steps: - - name: checkout - uses: actions/checkout@v4 - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version-file: ./go.mod - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push ClusterLink images - run: make push-image IMAGE_VERSION=${{ github.ref_name }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..f38c55750 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,57 @@ +name: Release Images and Binaries + +on: + push: + tags: + - 'v**' + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: ./go.mod + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build images + run: make docker-build + - name: Build and compress linux binaries + run: | + GOOS=linux GOARCH=amd64 CGO_ENABLED=0 make cli-build BIN_DIR=linux + tar -czvf clusterlink-linux-amd64.tar.gz --transform 's/linux/clusterlink/' ./linux + - name: Build and compress macOS binaries + run: | + GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 make cli-build BIN_DIR=os + tar -czvf clusterlink-darwin-amd64.tar.gz --transform 's/os/clusterlink/' ./os + - name: Build and compress Arm-based macOS binaries + run: | + GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 make cli-build BIN_DIR=osarm64 + tar -czvf clusterlink-darwin-arm64.tar.gz --transform 's/osarm64/clusterlink/' ./osarm64 + - name: Upload binaries to release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ./clusterlink* + tag: ${{ github.ref }} + overwrite: true + file_glob: true + - name: Upload script + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ./hack/clusterlink.sh + asset_name: clusterlink.sh + tag: ${{ github.ref }} + overwrite: true + # - name: Tag and push ClusterLink images with tag 'latest' + # run: make push-image + # - name: Tag and push ClusterLink images latest with tag ${{ github.ref_name }} + # run: make push-image IMAGE_VERSION=${{ github.ref_name }} diff --git a/Makefile b/Makefile index 5a8c6fd82..9eae7f60d 100755 --- a/Makefile +++ b/Makefile @@ -75,6 +75,7 @@ copr-fix: ; $(info adding copyright header...) GO ?= CGO_ENABLED=0 go # Allow setting of go build flags from the command line. GOFLAGS := +BIN_DIR := ./bin TAG := $(shell git describe --tags --abbrev=0) LDFLAGS=-ldflags "-X github.com/clusterlink-net/clusterlink/pkg/versioninfo.GitTag=$(TAG)" @@ -102,14 +103,17 @@ codegen: controller-gen ## Generate ClusterRole, CRDs and DeepCopyObject. $(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="././pkg/apis/..." @goimports -l -w ./pkg/apis/clusterlink.net/v1alpha1/zz_generated.deepcopy.go -build: +cli-build: @echo "Start go build phase" - $(GO) build $(LDFLAGS) -o ./bin/gwctl ./cmd/gwctl - $(GO) build -o ./bin/cl-controlplane ./cmd/cl-controlplane - $(GO) build -o ./bin/cl-dataplane ./cmd/cl-dataplane - $(GO) build -o ./bin/cl-go-dataplane ./cmd/cl-go-dataplane - $(GO) build $(LDFLAGS) -o ./bin/cl-adm ./cmd/cl-adm - $(GO) build -o ./bin/cl-operator ./cmd/cl-operator/main.go + $(GO) build $(LDFLAGS) -o $(BIN_DIR)/gwctl ./cmd/gwctl + $(GO) build $(LDFLAGS) -o $(BIN_DIR)/cl-adm ./cmd/cl-adm + +build: cli-build + $(GO) build -o $(BIN_DIR)/cl-controlplane ./cmd/cl-controlplane + $(GO) build -o $(BIN_DIR)/cl-dataplane ./cmd/cl-dataplane + $(GO) build -o $(BIN_DIR)/cl-go-dataplane ./cmd/cl-go-dataplane + $(GO) build -o $(BIN_DIR)/cl-operator ./cmd/cl-operator/main.go + docker-build: build docker build --progress=plain --rm --tag cl-controlplane -f ./cmd/cl-controlplane/Dockerfile . @@ -127,9 +131,11 @@ push-image: docker-build docker push $(IMAGE_BASE)/cl-go-dataplane:$(IMAGE_VERSION) docker tag gwctl:latest $(IMAGE_BASE)/gwctl:$(IMAGE_VERSION) docker push $(IMAGE_BASE)/gwctl:$(IMAGE_VERSION) + docker tag cl-operator:latest $(IMAGE_BASE)/cl-operator:$(IMAGE_VERSION) + docker push $(IMAGE_BASE)/cl-operator:$(IMAGE_VERSION) install: - cp ./bin/gwctl /usr/local/bin/ + cp ./bin/gwctl ~/.local/bin/ clean-tests: kind delete cluster --name=peer1 diff --git a/hack/clusterlink.sh b/hack/clusterlink.sh new file mode 100755 index 000000000..08c225a61 --- /dev/null +++ b/hack/clusterlink.sh @@ -0,0 +1,77 @@ +#!/bin/sh +set -e + +# Detrmine the OS. +OS=$(uname) +if [ "${OS}" = "Darwin" ] ; then + CL_OS="os" +else + CL_OS="linux" +fi + + +# Detrmine the OS architecture. +OS_ARCH=$(uname -m) +case "${OS_ARCH}" in + x86_64|amd64) + CL_ARCH=amd64 + ;; + armv8*|aarch64*|arm64) + ARCH=arm64 + ;; + *) + echo "This ${OS_ARCH} architecture isn't supported" + exit 1 + ;; +esac + +filename="clusterlink-${CL_OS}-${CL_ARCH}.tar.gz" +url="https://github.com/kfirtoledo/clusterlink/releases/download/${VERSION}/${filename}" + +# Set version to latest if not define and update url. +if [ "${VERSION}" = "" ] ; then + VERSION="latest" + url="https://github.com/kfirtoledo/clusterlink/releases/${VERSION}/download/${filename}" +fi + + + +#url="https://github.com/clusterlinl-net/releases/download/${VERSION}/" +filename +printf "\n Downloading %s from %s ...\n" "$filename" "$url" + +if ! curl -o /dev/null -sIf "$url"; then + printf "\n%s This version of clusterlonk wasn't found\n" "$url" + exit 1 +fi + +# Open the tar file. +curl -fsLO ${url} +tar -xzf "${filename}" +rm "${filename}" + +current_path=$(pwd)/clusterlink + +install_path=${HOME}/.local/bin +mv $current_path/* $install_path +rm -rf $current_path + +# Installation summary. +printf "\n" +printf "\e[1;34m.----. .----. .-. . .-..-. .-..-. .----. .--. .----. .---. .----. .-. .-..----. .-. .----..---. .----.\n" +printf "| {} \\/ {} \| |/ \| || \`| || | / {} \\ / {} \\ | {} \ / ___}/ {} \| \`.' || {} }| | | {_ {_ _}| {_ \n" +printf "| /\\ /| .'. || |\ || \`--.\ // /\\ \| / \\ }\ /| |\ /| || .--' | \`--.| {__ | | | {__ \n" +printf "\`----' \`----' \`-' \`-'\`-' \`-'\`----' \`----' \`-' \`-'\`----' \`---' \`----' \`-' \` \`-'\`-' \`----'\`----' \`-' \`----'\e[0m\n" +printf "\n\n" + +printf "%s has been successfully downloaded.\n" "$filename" +printf "\n" +printf "ClusterLink CLI (gwctl and cl-adm) added to your environment path:\n" +printf "\n" +printf "\t\e[1;33m%s\n\e[0m" "$install_path" +printf "\n" +printf "If the ClusterLink command is not in your path, please add it using the following command:\n" +printf "\n" +printf "\t\e[1;33mexport PATH=\"\$PATH:%s\"\n\e[0m" "$install_path" +printf "\n" +printf "For more information on how to set up ClusterLink in your Kubernetes cluster, please see: \e[4mhttps://cluster-link.net/docs/getting-started\e[0m\n" +printf "\n" \ No newline at end of file diff --git a/website/content/en/docs/getting-started/_index.md b/website/content/en/docs/getting-started/_index.md index 8f75e775c..0941efdf6 100644 --- a/website/content/en/docs/getting-started/_index.md +++ b/website/content/en/docs/getting-started/_index.md @@ -14,25 +14,13 @@ Before you start, you must have access to a Kubernetes cluster. For example, you 1. {{< anchor install-cli>}}To install ClusterLink on Linux or Mac, use the installation script: ```sh - curl -L https://github.com/clusterlink-net/clusterlink/releases/latest/clusterlink.sh | sh - - ``` - -1. Move to the ClusterLink project folder: - - ```sh - cd clusterlink - ``` - -1. Export the ClusterLink CLI to your path: - - ```sh - export PATH=$PWD/bin:$PATH + curl -L https://github.com/clusterlink-net/clusterlink/releases/latest/download/clusterlink.sh | sh - ``` 1. Check the installation by running the command: ```sh - clusterlink version + clusterlink --version ``` ## Setup