Skip to content

Commit

Permalink
Add release process (#42)
Browse files Browse the repository at this point in the history
Co-authored-by: Vishal <[email protected]>
  • Loading branch information
PrasadG193 and vishal-biyani authored Mar 31, 2021
1 parent 49fc871 commit 7fb50bd
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,11 @@ jobs:

- name: Test
run: go test -v ./...

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34 changes: 34 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
before:
hooks:
- go mod download
builds:
- id: kbrew
binary: kbrew
main: cmd/cli/main.go
env:
- CGO_ENABLED=0
goos:
- linux
- windows
goarch:
- 386
- amd64
- arm
- arm64
archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
1 change: 1 addition & 0 deletions .release
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
release=v0.0.0
46 changes: 46 additions & 0 deletions build/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
set -e

version=$(cut -d'=' -f2- .release)
if [[ -z ${version} ]]; then
echo "Invalid version set in .release"
exit 1
fi


if [[ -z ${GITHUB_TOKEN} ]]; then
echo "GITHUB_TOKEN not set. Usage: GITHUB_TOKEN=<TOKEN> ./hack/release.sh"
exit 1
fi

echo "Publishing release ${version}"

generate_changelog() {
local version=$1

# generate changelog from github
github_changelog_generator --user kbrew-dev --project kbrew -t ${GITHUB_TOKEN} --future-release ${version} -o CHANGELOG.md
sed -i '$d' CHANGELOG.md
}

git_tag() {
local version=$1
echo "Creating a git tag"
git add .release CHANGELOG.md
git commit -m "Release ${version}"
git tag ${version}
git push --tags origin main
echo 'Git tag pushed successfully'
}

make_release() {
goreleaser release --rm-dist --debug
}

generate_changelog $version
git_tag $version
make_release

echo "=========================== Done ============================="
echo "Congratulations!! Release ${version} published."
echo "Don't forget to add changelog in the release description."
echo "=============================================================="

0 comments on commit 7fb50bd

Please sign in to comment.