Skip to content

Commit

Permalink
Add goreleaser config and bump version support
Browse files Browse the repository at this point in the history
Releases are cut manually by calling bump-version.sh

Signed-off-by: Jose Luis Vazquez Gonzalez <[email protected]>
  • Loading branch information
Jose Luis Vazquez Gonzalez committed Dec 16, 2021
1 parent a1a3a89 commit d61d3cb
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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 }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ build/*
.idea
*.iml


dist/

next-semver/next-semver
35 changes: 35 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -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:'
13 changes: 13 additions & 0 deletions bump-version.sh
Original file line number Diff line number Diff line change
@@ -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}"

5 changes: 5 additions & 0 deletions next-semver/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module example.com/versions/next-semver

go 1.17

require github.com/Masterminds/semver/v3 v3.1.1 // indirect
2 changes: 2 additions & 0 deletions next-semver/go.sum
Original file line number Diff line number Diff line change
@@ -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=
19 changes: 19 additions & 0 deletions next-semver/main.go
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit d61d3cb

Please sign in to comment.