Skip to content

Commit

Permalink
.github/workflows: Update release action
Browse files Browse the repository at this point in the history
Signed-off-by: Kfir Toledo <[email protected]>
  • Loading branch information
kfirtoledo committed Mar 3, 2024
1 parent 49a3aa8 commit db1f68f
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 48 deletions.
26 changes: 0 additions & 26 deletions .github/workflows/make-release.yml

This file was deleted.

57 changes: 57 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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 }}
22 changes: 14 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)"

Expand Down Expand Up @@ -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 .
Expand All @@ -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
Expand Down
77 changes: 77 additions & 0 deletions hack/clusterlink.sh
Original file line number Diff line number Diff line change
@@ -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"
16 changes: 2 additions & 14 deletions website/content/en/docs/getting-started/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit db1f68f

Please sign in to comment.