From 8f97c01a695dfe8852094b9b46c6fe351e91e07d Mon Sep 17 00:00:00 2001 From: Jose Luis Vazquez Gonzalez Date: Mon, 13 Dec 2021 11:50:16 +0100 Subject: [PATCH 01/14] Add goreleaser config and bump version support Releases are cut manually by calling bump-version.sh Signed-off-by: Jose Luis Vazquez Gonzalez --- .github/workflows/release.yml | 27 +++++++++++++++++++++++++++ .gitignore | 4 ++++ .goreleaser.yml | 35 +++++++++++++++++++++++++++++++++++ bump-version.sh | 13 +++++++++++++ next-semver/go.mod | 5 +++++ next-semver/go.sum | 2 ++ next-semver/main.go | 19 +++++++++++++++++++ 7 files changed, 105 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 .goreleaser.yml create mode 100755 bump-version.sh create mode 100644 next-semver/go.mod create mode 100644 next-semver/go.sum create mode 100644 next-semver/main.go diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..660d0e03 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,27 @@ +name: release + +on: + push: + tags: + - "v*.*.*" + +jobs: + release: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Unshallow + run: git fetch --prune --unshallow + - name: Set up Go + uses: actions/setup-go@v1 + with: + go-version: 1.17.x + - name: Release + uses: goreleaser/goreleaser-action@v2 + with: + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 77b12d4c..4e11a5f5 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,7 @@ build/* .idea *.iml + +dist/ + +next-semver/next-semver diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 00000000..1b37c74d --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,35 @@ +# This is an example .goreleaser.yml file with some sensible defaults. +# Make sure to check the documentation at https://goreleaser.com +env: + - VERSION="{{ .Version }}" +before: + hooks: + - make build +builds: + - env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin + binary: relok8s +archives: + - replacements: + darwin: Darwin + linux: Linux + windows: Windows + 386: i386 + amd64: x86_64 + name_template: "{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}" + files: + - README.md +checksum: + name_template: 'checksums.txt' +snapshot: + name_template: "{{ incpatch .Version }}-next" +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' diff --git a/bump-version.sh b/bump-version.sh new file mode 100755 index 00000000..c390a6d8 --- /dev/null +++ b/bump-version.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +set -euo pipefail + +old_version=$(cat version) +(cd next-semver && go build .) +version=$(./next-semver/next-semver "${old_version}") +echo "${version}" > version +git add version +git commit -s -m "Bump version to ${version}" +git push +git tag "v${version}" && git push origin "v${version}" + diff --git a/next-semver/go.mod b/next-semver/go.mod new file mode 100644 index 00000000..cf77a39d --- /dev/null +++ b/next-semver/go.mod @@ -0,0 +1,5 @@ +module example.com/versions/next-semver + +go 1.17 + +require github.com/Masterminds/semver/v3 v3.1.1 // indirect diff --git a/next-semver/go.sum b/next-semver/go.sum new file mode 100644 index 00000000..471bde90 --- /dev/null +++ b/next-semver/go.sum @@ -0,0 +1,2 @@ +github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc= +github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= diff --git a/next-semver/main.go b/next-semver/main.go new file mode 100644 index 00000000..f200da38 --- /dev/null +++ b/next-semver/main.go @@ -0,0 +1,19 @@ +package main + +import ( + "fmt" + "os" + + semverv3 "github.com/Masterminds/semver/v3" +) + +func main() { + if len(os.Args) != 2 { + fmt.Printf("Usage: %s {semver-version}\n$ %s 1.2.3\n", os.Args[0], os.Args[0]) + os.Exit(-1) + } + v := os.Args[1] + version := semverv3.MustParse(v) + next := version.IncPatch() + fmt.Println(next) +} From d73725662ec3daacc6d81d200afdc0145a9e8f0b Mon Sep 17 00:00:00 2001 From: Jose Luis Vazquez Gonzalez Date: Thu, 16 Dec 2021 11:29:43 +0100 Subject: [PATCH 02/14] Allow to bump custom versions Signed-off-by: Jose Luis Vazquez Gonzalez --- bump-version.sh | 4 +- next-semver/go.mod | 5 -- next-semver/go.sum | 2 - next-semver/main.go | 59 ++++++++++++++++--- next-semver/main_test.go | 123 +++++++++++++++++++++++++++++++++++++++ version | 1 - 6 files changed, 177 insertions(+), 17 deletions(-) delete mode 100644 next-semver/go.mod delete mode 100644 next-semver/go.sum create mode 100644 next-semver/main_test.go delete mode 100644 version diff --git a/bump-version.sh b/bump-version.sh index c390a6d8..a1e01b5c 100755 --- a/bump-version.sh +++ b/bump-version.sh @@ -2,9 +2,11 @@ set -euo pipefail +desired_version=${1:-} + old_version=$(cat version) (cd next-semver && go build .) -version=$(./next-semver/next-semver "${old_version}") +version=$(./next-semver/next-semver "${old_version}" "${desired_version}") echo "${version}" > version git add version git commit -s -m "Bump version to ${version}" diff --git a/next-semver/go.mod b/next-semver/go.mod deleted file mode 100644 index cf77a39d..00000000 --- a/next-semver/go.mod +++ /dev/null @@ -1,5 +0,0 @@ -module example.com/versions/next-semver - -go 1.17 - -require github.com/Masterminds/semver/v3 v3.1.1 // indirect diff --git a/next-semver/go.sum b/next-semver/go.sum deleted file mode 100644 index 471bde90..00000000 --- a/next-semver/go.sum +++ /dev/null @@ -1,2 +0,0 @@ -github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc= -github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= diff --git a/next-semver/main.go b/next-semver/main.go index f200da38..12fb968b 100644 --- a/next-semver/main.go +++ b/next-semver/main.go @@ -1,19 +1,62 @@ +// Copyright 2021 VMware, Inc. +// SPDX-License-Identifier: BSD-2-Clause + package main import ( + "errors" "fmt" "os" - semverv3 "github.com/Masterminds/semver/v3" + semver3 "github.com/Masterminds/semver/v3" ) -func main() { - if len(os.Args) != 2 { - fmt.Printf("Usage: %s {semver-version}\n$ %s 1.2.3\n", os.Args[0], os.Args[0]) - os.Exit(-1) +var ( + // ErrBadInputs when the number of CLI inputs are wrong + ErrBadInputs = errors.New("bad inputs") + + // ErrBadVersionBump when the desired version is not after the previous one + ErrBadVersionBump = errors.New("bad version bump") +) + +func nextSemVer(previous, desired *semver3.Version) (*semver3.Version, error) { + if desired == nil { + next := previous.IncPatch() + return &next, nil + } + if !desired.GreaterThan(previous) { + return nil, fmt.Errorf("%w: %v is not after %v", ErrBadVersionBump, desired, previous) + } + return desired, nil +} + +func mainE(args ...string) error { + if len(args) < 2 || len(args) > 3 { + return fmt.Errorf("%w\nusage: %s {semver-version} [{desired_semver}]\n$ %s 1.2.3", + ErrBadInputs, args[0], args[0]) + } + previous, err := semver3.NewVersion(args[1]) + if err != nil { + return fmt.Errorf("failed to parse previous version %q: %w", args[1], err) + } + var desired *semver3.Version + if len(args) > 2 && args[2] != "" { + desired, err = semver3.NewVersion(args[2]) + if err != nil { + return fmt.Errorf("failed to parse desired version %q: %w", args[2], err) + } + } + next, err := nextSemVer(previous, desired) + if err != nil { + return err } - v := os.Args[1] - version := semverv3.MustParse(v) - next := version.IncPatch() fmt.Println(next) + return nil +} + +func main() { + if err := mainE(os.Args...); err != nil { + fmt.Fprintln(os.Stderr, err) + os.Exit(1) + } } diff --git a/next-semver/main_test.go b/next-semver/main_test.go new file mode 100644 index 00000000..8c1c8490 --- /dev/null +++ b/next-semver/main_test.go @@ -0,0 +1,123 @@ +// Copyright 2021 VMware, Inc. +// SPDX-License-Identifier: BSD-2-Clause + +package main + +import ( + "errors" + "fmt" + "testing" + + semver3 "github.com/Masterminds/semver/v3" +) + +var nextSemVerTests = []struct { + previous, desired string + expected string +}{ + { + previous: "0.0.0", + desired: "", + expected: "0.0.1", + }, + { + previous: "0.0.1", + desired: "", + expected: "0.0.2", + }, + { + previous: "0.0.1", + desired: "0.1.0", + expected: "0.1.0", + }, + { + previous: "0.9.1", + desired: "1.0.0", + expected: "1.0.0", + }, + { + previous: "0.9.9", + desired: "", + expected: "0.9.10", + }, + { + previous: "0.9.9-rc", + desired: "", + expected: "0.9.9", + }, +} + +func version(v string) *semver3.Version { + if v == "" { + return nil + } + return semver3.MustParse(v) +} + +func TestNextSemVer(t *testing.T) { + for _, tc := range nextSemVerTests { + testName := fmt.Sprintf("(%q, %q)->%q", tc.previous, tc.desired, tc.expected) + t.Run(testName, func(t *testing.T) { + next, err := nextSemVer(version(tc.previous), version(tc.desired)) + if err != nil { + t.Fatalf("unexpected error: %s", err) + } + got := next.String() + want := tc.expected + if got != want { + t.Fatalf("want %s got %s", want, got) + } + }) + } +} + +var mainEIssues = []struct { + args []string + expected error +}{ + { + args: []string{"next-semver", "0.0.0"}, + expected: nil, + }, + { + args: []string{"next-semver", "0.0.1", "0.0.0"}, + expected: ErrBadVersionBump, + }, + { + args: []string{"next-semver", "0.0.1", "0.1.0"}, + expected: nil, + }, + { + args: []string{"next-semver", "1.0.1", "0.9.0"}, + expected: ErrBadVersionBump, + }, + { + args: []string{"next-semver", "blah1.0.1", "0.9.0"}, + expected: semver3.ErrInvalidSemVer, + }, + { + args: []string{"next-semver", "1.0.1", "blah0.9.0"}, + expected: semver3.ErrInvalidSemVer, + }, + { + args: []string{"next-semver", "1.0.1", "0.9.0.1"}, + expected: semver3.ErrInvalidSemVer, + }, + { + args: []string{"next-semver"}, + expected: ErrBadInputs, + }, +} + +func TestMainE(t *testing.T) { + for _, tc := range mainEIssues { + testName := fmt.Sprintf("%v->%v", tc.args, tc.expected) + t.Run(testName, func(t *testing.T) { + got := mainE(tc.args...) + want := tc.expected + if !errors.Is(got, want) { + t.Fatalf("want %v got %v", want, got) + } + }) + } +} diff --git a/version b/version deleted file mode 100644 index 755765fe..00000000 --- a/version +++ /dev/null @@ -1 +0,0 @@ -0.3.60 From 17c4e4e0f79739455b4a8226dc82dc1a5d7cfcc3 Mon Sep 17 00:00:00 2001 From: josvaz Date: Fri, 17 Dec 2021 09:03:51 +0100 Subject: [PATCH 03/14] remove sample comment Co-authored-by: Tomas Pizarro Signed-off-by: Jose Luis Vazquez Gonzalez --- .goreleaser.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index 1b37c74d..7ce6b32d 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,4 +1,3 @@ -# This is an example .goreleaser.yml file with some sensible defaults. # Make sure to check the documentation at https://goreleaser.com env: - VERSION="{{ .Version }}" From 12b74a1c8b3f4a648982b22d8075da154cb57654 Mon Sep 17 00:00:00 2001 From: Jose Luis Vazquez Gonzalez Date: Mon, 10 Jan 2022 12:23:21 +0100 Subject: [PATCH 04/14] Remove version bump helpers Signed-off-by: Jose Luis Vazquez Gonzalez --- .gitignore | 2 - bump-version.sh | 15 ----- next-semver/main.go | 62 -------------------- next-semver/main_test.go | 123 --------------------------------------- 4 files changed, 202 deletions(-) delete mode 100755 bump-version.sh delete mode 100644 next-semver/main.go delete mode 100644 next-semver/main_test.go diff --git a/.gitignore b/.gitignore index 4e11a5f5..e83759a8 100644 --- a/.gitignore +++ b/.gitignore @@ -10,5 +10,3 @@ build/* dist/ - -next-semver/next-semver diff --git a/bump-version.sh b/bump-version.sh deleted file mode 100755 index a1e01b5c..00000000 --- a/bump-version.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -set -euo pipefail - -desired_version=${1:-} - -old_version=$(cat version) -(cd next-semver && go build .) -version=$(./next-semver/next-semver "${old_version}" "${desired_version}") -echo "${version}" > version -git add version -git commit -s -m "Bump version to ${version}" -git push -git tag "v${version}" && git push origin "v${version}" - diff --git a/next-semver/main.go b/next-semver/main.go deleted file mode 100644 index 12fb968b..00000000 --- a/next-semver/main.go +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2021 VMware, Inc. -// SPDX-License-Identifier: BSD-2-Clause - -package main - -import ( - "errors" - "fmt" - "os" - - semver3 "github.com/Masterminds/semver/v3" -) - -var ( - // ErrBadInputs when the number of CLI inputs are wrong - ErrBadInputs = errors.New("bad inputs") - - // ErrBadVersionBump when the desired version is not after the previous one - ErrBadVersionBump = errors.New("bad version bump") -) - -func nextSemVer(previous, desired *semver3.Version) (*semver3.Version, error) { - if desired == nil { - next := previous.IncPatch() - return &next, nil - } - if !desired.GreaterThan(previous) { - return nil, fmt.Errorf("%w: %v is not after %v", ErrBadVersionBump, desired, previous) - } - return desired, nil -} - -func mainE(args ...string) error { - if len(args) < 2 || len(args) > 3 { - return fmt.Errorf("%w\nusage: %s {semver-version} [{desired_semver}]\n$ %s 1.2.3", - ErrBadInputs, args[0], args[0]) - } - previous, err := semver3.NewVersion(args[1]) - if err != nil { - return fmt.Errorf("failed to parse previous version %q: %w", args[1], err) - } - var desired *semver3.Version - if len(args) > 2 && args[2] != "" { - desired, err = semver3.NewVersion(args[2]) - if err != nil { - return fmt.Errorf("failed to parse desired version %q: %w", args[2], err) - } - } - next, err := nextSemVer(previous, desired) - if err != nil { - return err - } - fmt.Println(next) - return nil -} - -func main() { - if err := mainE(os.Args...); err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } -} diff --git a/next-semver/main_test.go b/next-semver/main_test.go deleted file mode 100644 index 8c1c8490..00000000 --- a/next-semver/main_test.go +++ /dev/null @@ -1,123 +0,0 @@ -// Copyright 2021 VMware, Inc. -// SPDX-License-Identifier: BSD-2-Clause - -package main - -import ( - "errors" - "fmt" - "testing" - - semver3 "github.com/Masterminds/semver/v3" -) - -var nextSemVerTests = []struct { - previous, desired string - expected string -}{ - { - previous: "0.0.0", - desired: "", - expected: "0.0.1", - }, - { - previous: "0.0.1", - desired: "", - expected: "0.0.2", - }, - { - previous: "0.0.1", - desired: "0.1.0", - expected: "0.1.0", - }, - { - previous: "0.9.1", - desired: "1.0.0", - expected: "1.0.0", - }, - { - previous: "0.9.9", - desired: "", - expected: "0.9.10", - }, - { - previous: "0.9.9-rc", - desired: "", - expected: "0.9.9", - }, -} - -func version(v string) *semver3.Version { - if v == "" { - return nil - } - return semver3.MustParse(v) -} - -func TestNextSemVer(t *testing.T) { - for _, tc := range nextSemVerTests { - testName := fmt.Sprintf("(%q, %q)->%q", tc.previous, tc.desired, tc.expected) - t.Run(testName, func(t *testing.T) { - next, err := nextSemVer(version(tc.previous), version(tc.desired)) - if err != nil { - t.Fatalf("unexpected error: %s", err) - } - got := next.String() - want := tc.expected - if got != want { - t.Fatalf("want %s got %s", want, got) - } - }) - } -} - -var mainEIssues = []struct { - args []string - expected error -}{ - { - args: []string{"next-semver", "0.0.0"}, - expected: nil, - }, - { - args: []string{"next-semver", "0.0.1", "0.0.0"}, - expected: ErrBadVersionBump, - }, - { - args: []string{"next-semver", "0.0.1", "0.1.0"}, - expected: nil, - }, - { - args: []string{"next-semver", "1.0.1", "0.9.0"}, - expected: ErrBadVersionBump, - }, - { - args: []string{"next-semver", "blah1.0.1", "0.9.0"}, - expected: semver3.ErrInvalidSemVer, - }, - { - args: []string{"next-semver", "1.0.1", "blah0.9.0"}, - expected: semver3.ErrInvalidSemVer, - }, - { - args: []string{"next-semver", "1.0.1", "0.9.0.1"}, - expected: semver3.ErrInvalidSemVer, - }, - { - args: []string{"next-semver"}, - expected: ErrBadInputs, - }, -} - -func TestMainE(t *testing.T) { - for _, tc := range mainEIssues { - testName := fmt.Sprintf("%v->%v", tc.args, tc.expected) - t.Run(testName, func(t *testing.T) { - got := mainE(tc.args...) - want := tc.expected - if !errors.Is(got, want) { - t.Fatalf("want %v got %v", want, got) - } - }) - } -} From 71aef5fe27c2a3501e547ee2feea755d42e2820c Mon Sep 17 00:00:00 2001 From: Jose Luis Vazquez Gonzalez Date: Mon, 10 Jan 2022 12:24:14 +0100 Subject: [PATCH 05/14] Ensure goreleaser sets the binary version Signed-off-by: Jose Luis Vazquez Gonzalez --- .goreleaser.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index 7ce6b32d..8993c993 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,12 +1,13 @@ # Make sure to check the documentation at https://goreleaser.com -env: - - VERSION="{{ .Version }}" before: hooks: - - make build + - make clean + - env VERSION="{{ .Version }}" make build builds: - env: - CGO_ENABLED=0 + ldflags: + - -X github.com/vmware-tanzu/asset-relocation-tool-for-kubernetes/cmd.Version={{ .Version }} goos: - linux - windows From 78c50a18d03a992b9f663cee52a2417314985606 Mon Sep 17 00:00:00 2001 From: Jose Luis Vazquez Gonzalez Date: Mon, 10 Jan 2022 12:31:49 +0100 Subject: [PATCH 06/14] Attempt to remove version handling from CI code Signed-off-by: Jose Luis Vazquez Gonzalez --- ci/pipeline.yaml | 33 ++------------------------------- ci/tasks/build.yaml | 2 -- 2 files changed, 2 insertions(+), 33 deletions(-) diff --git a/ci/pipeline.yaml b/ci/pipeline.yaml index 016c5299..23a6333e 100644 --- a/ci/pipeline.yaml +++ b/ci/pipeline.yaml @@ -80,17 +80,6 @@ resources: repository: asset-relocation-tool-for-kubernetes access_token: ((github.access_token)) - - name: version - type: semver - icon: github - source: - driver: git - uri: git@github.com:vmware-tanzu/asset-relocation-tool-for-kubernetes.git - private_key: ((github.private_key)) - branch: main - file: version - commit_message: "[ci skip] bump version to %version%" - - name: nginx-chart type: helm-chart icon: kubernetes @@ -143,7 +132,7 @@ jobs: REGISTRY_PASSWORD: ((harbor-private.token)) - name: build - serial_groups: [version] + serial_groups: [] plan: - in_parallel: - get: test-image @@ -153,16 +142,13 @@ jobs: trigger: true passed: - test - - get: version - params: - bump: patch - in_parallel: - do: - task: build image: test-image file: source/ci/tasks/build.yaml - put: release - inputs: [build, source, version] + inputs: [build, source] params: name: version/version tag: version/version @@ -174,8 +160,6 @@ jobs: image: test-image config: platform: linux - inputs: - - name: version outputs: - name: args-file run: @@ -208,22 +192,9 @@ jobs: - put: docker-image inputs: - image - - version params: image: image/image.tar additional_tags: version/version - - put: version - params: - file: version/version - inputs: detect - - - name: bump-minor-version - serial_groups: [version] - plan: - - put: version - inputs: detect - params: - bump: minor - name: relocate-chart plan: diff --git a/ci/tasks/build.yaml b/ci/tasks/build.yaml index 7bf2507b..cb4a635c 100644 --- a/ci/tasks/build.yaml +++ b/ci/tasks/build.yaml @@ -5,7 +5,6 @@ platform: linux inputs: - name: source - - name: version outputs: - name: build @@ -16,6 +15,5 @@ run: args: - -exc - | - export VERSION=$(cat ../version/version) make build-all cp build/* ../build From 9adfaef472aa5c65739cfa499aac7cd6e716f933 Mon Sep 17 00:00:00 2001 From: Jose Luis Vazquez Gonzalez Date: Mon, 10 Jan 2022 16:45:11 +0100 Subject: [PATCH 07/14] Add file copyright headers Signed-off-by: Jose Luis Vazquez Gonzalez --- .github/workflows/golangci-lint.yml | 2 ++ .github/workflows/release.yml | 2 ++ .goreleaser.yml | 2 ++ 3 files changed, 6 insertions(+) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index aaf84177..db0d3b16 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -1,3 +1,5 @@ +# Copyright 2022 VMware, Inc. +# SPDX-License-Identifier: BSD-2-Clause name: golangci-lint on: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 660d0e03..f4f87fe7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,3 +1,5 @@ +# Copyright 2022 VMware, Inc. +# SPDX-License-Identifier: BSD-2-Clause name: release on: diff --git a/.goreleaser.yml b/.goreleaser.yml index 8993c993..ebd87f25 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,3 +1,5 @@ +# Copyright 2022 VMware, Inc. +# SPDX-License-Identifier: BSD-2-Clause # Make sure to check the documentation at https://goreleaser.com before: hooks: From eab908f820c8f61bb1c483638f8ea068436fe4f8 Mon Sep 17 00:00:00 2001 From: Jose Luis Vazquez Gonzalez Date: Mon, 10 Jan 2022 16:46:14 +0100 Subject: [PATCH 08/14] Add releases comment in gitignore for dist/ Signed-off-by: Jose Luis Vazquez Gonzalez --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index e83759a8..19f0a2a5 100644 --- a/.gitignore +++ b/.gitignore @@ -8,5 +8,5 @@ build/* .idea *.iml - +# Releases dist/ From 1d4d407d7b2140dce5036052339fdef35e62d3f5 Mon Sep 17 00:00:00 2001 From: Jose Luis Vazquez Gonzalez Date: Mon, 10 Jan 2022 16:47:26 +0100 Subject: [PATCH 09/14] Do not use the makefile at all in goreleaser Signed-off-by: Jose Luis Vazquez Gonzalez --- .goreleaser.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index ebd87f25..df1033ca 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,10 +1,6 @@ # Copyright 2022 VMware, Inc. # SPDX-License-Identifier: BSD-2-Clause # Make sure to check the documentation at https://goreleaser.com -before: - hooks: - - make clean - - env VERSION="{{ .Version }}" make build builds: - env: - CGO_ENABLED=0 From 880b8f109fedccd5c35e2cfcc087a2ee97a03e3a Mon Sep 17 00:00:00 2001 From: Jose Luis Vazquez Gonzalez Date: Mon, 10 Jan 2022 16:48:12 +0100 Subject: [PATCH 10/14] Do not build for Windows Signed-off-by: Jose Luis Vazquez Gonzalez --- .goreleaser.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index df1033ca..ead79f95 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -8,7 +8,6 @@ builds: - -X github.com/vmware-tanzu/asset-relocation-tool-for-kubernetes/cmd.Version={{ .Version }} goos: - linux - - windows - darwin binary: relok8s archives: From 9c87b6525f16c749a48571d94004c78c28119987 Mon Sep 17 00:00:00 2001 From: Jose Luis Vazquez Gonzalez Date: Mon, 10 Jan 2022 16:48:32 +0100 Subject: [PATCH 11/14] Do not rename OSs Signed-off-by: Jose Luis Vazquez Gonzalez --- .goreleaser.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index ead79f95..76d69ba1 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -12,9 +12,6 @@ builds: binary: relok8s archives: - replacements: - darwin: Darwin - linux: Linux - windows: Windows 386: i386 amd64: x86_64 name_template: "{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}" From c4d0be3e5b7d89f5fdff4b7b1d2faca958bf3ff4 Mon Sep 17 00:00:00 2001 From: Pete Wall Date: Mon, 10 Jan 2022 14:27:34 -0600 Subject: [PATCH 12/14] Change pipeline to only test source changes and run the CI relocation with new images Signed-off-by: Pete Wall --- ci/pipeline.yaml | 76 ------------------------------------------------ 1 file changed, 76 deletions(-) diff --git a/ci/pipeline.yaml b/ci/pipeline.yaml index 23a6333e..3a535cec 100644 --- a/ci/pipeline.yaml +++ b/ci/pipeline.yaml @@ -72,14 +72,6 @@ resources: username: ((harbor-public.username)) password: ((harbor-public.token)) - - name: release - type: github-release - icon: github - source: - owner: vmware-tanzu - repository: asset-relocation-tool-for-kubernetes - access_token: ((github.access_token)) - - name: nginx-chart type: helm-chart icon: kubernetes @@ -131,77 +123,10 @@ jobs: REGISTRY_USERNAME: ((harbor-private.username)) REGISTRY_PASSWORD: ((harbor-private.token)) - - name: build - serial_groups: [] - plan: - - in_parallel: - - get: test-image - passed: - - test - - get: source - trigger: true - passed: - - test - - in_parallel: - - do: - - task: build - image: test-image - file: source/ci/tasks/build.yaml - - put: release - inputs: [build, source] - params: - name: version/version - tag: version/version - commitish: source/.git/ref - globs: - - build/* - - do: - - task: make-args-file - image: test-image - config: - platform: linux - outputs: - - name: args-file - run: - path: bash - args: - - -exc - - | - echo "VERSION=$(cat version/version)" > args-file/args.env - - task: build-image - privileged: true - config: - platform: linux - image_resource: - type: registry-image - source: - repository: harbor-repo.vmware.com/dockerhub-proxy-cache/concourse/oci-build-task - username: ((harbor.username)) - password: ((harbor.token)) - inputs: - - name: args-file - - name: source - path: . - outputs: - - name: image - params: - BUILD_ARGS_FILE: args-file/args.env - REGISTRY_MIRRORS: mirror.kokoni.info - run: - path: build - - put: docker-image - inputs: - - image - params: - image: image/image.tar - additional_tags: version/version - - name: relocate-chart plan: - in_parallel: - get: docker-image - passed: - - build trigger: true - get: nginx-chart - task: relocate @@ -254,7 +179,6 @@ jobs: <(tar xzfO nginx-chart/*.tgz nginx/values.yaml) \ <(tar xzfO rewritten-chart/chart.tgz nginx/values.yaml) - - name: test-pull-request serial: true plan: From a3b669b47f897ebebfaafaeef89787810682e959 Mon Sep 17 00:00:00 2001 From: Jose Luis Vazquez Gonzalez Date: Tue, 11 Jan 2022 09:29:06 +0100 Subject: [PATCH 13/14] Use defaault goos Signed-off-by: Jose Luis Vazquez Gonzalez --- .goreleaser.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index 76d69ba1..ef688e7f 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -6,9 +6,6 @@ builds: - CGO_ENABLED=0 ldflags: - -X github.com/vmware-tanzu/asset-relocation-tool-for-kubernetes/cmd.Version={{ .Version }} - goos: - - linux - - darwin binary: relok8s archives: - replacements: From 03ad096364cea746de6ec7438af325eb2a3b36b9 Mon Sep 17 00:00:00 2001 From: Jose Luis Vazquez Gonzalez Date: Tue, 11 Jan 2022 09:29:22 +0100 Subject: [PATCH 14/14] Document manual releases Signed-off-by: Jose Luis Vazquez Gonzalez --- DEVELOPMENT.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 4b3191af..8e215923 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -41,3 +41,13 @@ To run all tests, including `test-external` do: ```bash make test-all ``` + +### Releasing + +Releases are cut manually like this: + +```bash +VERSION=X.Y.Z && git tag "v${VERSION}" && git push origin "v${VERSION}" +``` + +The `X.Y.Z` version must be a semver compliant version string. Once the tag is pushed, a GitHub Action will produce the corresponding release using goreleaser.