Skip to content

Commit

Permalink
Add release endpoint to Makefile
Browse files Browse the repository at this point in the history
This commit adds the `release` and `release-dry-run` endpoints to the Makefile.
 These endpoints use Goreleaser to build the compare binary for different 
architectures and platforms. The `release-dry-run` endpoint only builds the binaries,
 creates the archives, and generates the release notes. The `release` endpoint also
 uploads the release to GitHub. The release notes contain a list of all the changes from 
the previous tag to the newest tag.  Also a release guide is created containing explanations 
on how to create a new release. 

Signed-off-by: Alina Sudakov <[email protected]>
  • Loading branch information
AlinaSecret committed May 23, 2024
1 parent 967f415 commit 7b8435c
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ Dockerfile.cross

#macOS
.DS_Store

# Release artifacts
dist/*
29 changes: 29 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
project_name: kube-compare
release:
github:
owner: openshift
name: kube-compare
builds:
- id: kube-compare
binary: kubectl-cluster_compare
goos:
- linux
- windows
- darwin
goarch:
- amd64
- "386"
env:
- CGO_ENABLED=0
- GO111MODULE=on
main: cmd/kubectl-cluster_compare.go
ldflags: -s -w
-X github.com/openshift/kube-compare/pkg/version.version=
archives:
- id: kube-compare
builds:
- kube-compare
name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}"
format_overrides:
- goos: windows
format: zip
28 changes: 28 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
ENGINE ?= docker
IMAGE_NAME=kube-compare

PACKAGE_NAME := github.com/openshift/kube-compare
GOLANG_CROSS_VERSION ?= v1.22.3


.PHONY: build
build:
go build ./cmd/kubectl-cluster_compare.go
Expand All @@ -28,3 +32,27 @@ markdownlint: markdownlint-image ## run the markdown linter
--env PULL_BASE_SHA=$(PULL_BASE_SHA) \
-v $$(pwd):/workdir:Z \
$(IMAGE_NAME)-markdownlint:latest


.PHONY: release-dry-run
release-dry-run:
@$(ENGINE) run \
--rm \
-e CGO_ENABLED=1 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/$(PACKAGE_NAME) \
-w /go/src/$(PACKAGE_NAME) \
ghcr.io/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
release --clean --skip=validate --skip=publish

.PHONY: release
release:
@$(ENGINE) run \
--rm \
-e GITHUB_TOKEN=$(GITHUB_TOKEN) \
-e CGO_ENABLED=1 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/$(PACKAGE_NAME) \
-w /go/src/$(PACKAGE_NAME) \
ghcr.io/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
release --clean
17 changes: 17 additions & 0 deletions docs/release-guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Release Guide

The plugin uses GitHub releases to store binaries and release info. The release notes and binaries are created using
GoReleaser allowing to build the binary for different architectures and platforms. The configuration of GoReleaser
is located in .goreleaser.yml.

## Release instructions

1. In your local clone of the project tag the commit using git, the tags value should be the number of the release
formatted as "v[major].[minor].[tiny]". for example "v1.0.0".
2. Run `make release-dry-run`, The release files will be created in the dist directory. make sure the release contains
the expected changes. once you are satisfied continue to the next step.
3. Set GITHUB_TOKEN environment variable to be your GitHub api token, the minimum permissions needed are
`packages:write`. (run `export GITHUB_TOKEN="<YOUR_TOKEN>"`).
4. Run `make release`, the command should upload the release to GitHub.

The release notes can be edited manually at any time if needed [here](https://github.com/openshift/kube-compare/releases).

0 comments on commit 7b8435c

Please sign in to comment.