From 53e663e5e8f74600edd5e2714b0165d5132b81dc Mon Sep 17 00:00:00 2001 From: Kamesh Sampath Date: Wed, 1 Feb 2023 15:58:11 +0530 Subject: [PATCH] chore: build and goreleaser updates --- .editorconfig | 2 +- .envrc | 5 +---- .gitignore | 6 ++++-- .goreleaser.yaml | 35 +++++++++++++++++++++++++++++++++++ scripts/rename.py | 27 --------------------------- 5 files changed, 41 insertions(+), 34 deletions(-) create mode 100644 .goreleaser.yaml delete mode 100755 scripts/rename.py diff --git a/.editorconfig b/.editorconfig index ebe51d3..95405c1 100644 --- a/.editorconfig +++ b/.editorconfig @@ -9,4 +9,4 @@ indent_size = 2 end_of_line = lf charset = utf-8 trim_trailing_whitespace = false -insert_final_newline = false \ No newline at end of file +insert_final_newline = false diff --git a/.envrc b/.envrc index 4acd36e..6b309df 100644 --- a/.envrc +++ b/.envrc @@ -1,4 +1 @@ -export TUTORIAL_HOME="$PWD" -export KUBECONFIG="$TUTORIAL_HOME/.kube/config" -dotenv_if_exists -source_env_if_exists .envrc.local \ No newline at end of file +dotenv_if_exists .env diff --git a/.gitignore b/.gitignore index f3cfac9..31efa7e 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,8 @@ dist .direnv .env* !.env.example -cosign* image-refs.txt -!/bin/*.sh \ No newline at end of file +cosign.pub +cosign.key +.kube +goreleaser \ No newline at end of file diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..dbf44ed --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,35 @@ +project_name: go-hello-world +before: + hooks: + - go mod tidy +builds: + - id: go-hello-world + asmflags: + - all=-trimpath={{.Env.GOPATH}} + ldflags: + - -s + - -w + - -X main.Version={{.Tag}} + - -extldflags "-static" + goos: + - linux + - darwin + goarch: + - amd64 + - arm64 +kos: + - id: go-hello-world-ko + build: go-hello-world + bare: true + tags: + - latest + - '{{.Tag}}' + platforms: + - linux/amd64 + - linux/arm64 +# since its a demo, setting the release to be draft/pre-release always +release: + mode: append + prerelease: auto + draft: true + replace_existing_draft: true \ No newline at end of file diff --git a/scripts/rename.py b/scripts/rename.py deleted file mode 100755 index b8c9321..0000000 --- a/scripts/rename.py +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env python3 - -import argparse -import re -import os - -parser = argparse.ArgumentParser(description='Process target architectures') -parser.add_argument('--target-arch', metavar='t', type=str, - help='the target architecture that is being used for build') - -args = parser.parse_args() -''' -Currently goreleaser supports only v1 for amd64 and hence renaming the target folder to be like linux_amd64 -''' -regex = r"(?P^.*)_(?Pv[0-9]*$)" -matches = re.finditer(regex, args.target_arch) -try: - for matchNum, match in enumerate(matches,start=1): - if len(match.groups()) > 1: - if "linux_amd64" == match.group(1) and "v1" == match.group(2): - src = os.sep.join([os.getcwd(),"dist",f"server_{match.group(1)}_{match.group(2)}"]) - dest = os.sep.join([os.getcwd(),"dist",f"server_{match.group(1)}"]) - print(f"Renaming {src} to {dest} ") - os.rename(src,dest) -except Exception as e: - print(e) - exit(1)