diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..b13ae71 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,34 @@ +name: goreleaser + +on: + push: + tags: + - 'v*' + +permissions: + contents: write + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.17 + - name: Go Lint + run: | + go mod tidy + go test -v ./... + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + distribution: goreleaser + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..e9b640b --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,46 @@ +builds: + - env: + - CGO_ENABLED=0 + goos: + - linux + - darwin + - windows + goarch: + - amd64 + ldflags: + - -X github.com/tjhop/clip/cmd.builddate={{ .CommitDate }} + - -X github.com/tjhop/clip/cmd.version={{ .Version }} + - -X github.com/tjhop/clip/cmd.commit={{ .Commit }} + binary: clip +archives: + - replacements: + darwin: Darwin + linux: Linux + windows: Windows + 386: i386 + amd64: x86_64 +checksum: + name_template: 'checksums.txt' +snapshot: + name_template: "{{ .Tag }}-next" +nfpms: + - package_name: 'clip' + homepage: 'https://github.com/tjhop/clip' + maintainer: 'TJ Hoplock ' + description: 'Cross Platform CLI clipboard and templating tool' + formats: + - apk + - deb + - rpm + bindir: /usr/bin + contents: + - src: ./README.md + dst: /usr/share/doc/tjhop/clip/README.md +changelog: + sort: asc + filters: + exclude: + - '^Merge pull request' + - '^ci(?:\(\w+\))?\!?:' + - '^docs(?:\(\w+\))?\!?:' + - '^test(?:\(\w+\))?\!?:' diff --git a/README.md b/README.md index d20e5d8..78bb72e 100644 --- a/README.md +++ b/README.md @@ -128,24 +128,30 @@ tjhop ``` ## Building -Builds are using `go1.12.1` with [gox](https://github.com/mitchellh/gox): - -```shell -~/go/src/github.com/tjhop/clip -> COMMIT=$(git rev-parse --short HEAD | tr -d "[ \r\n\']"); -TAG=$(git describe --always --tags --abbrev=0 | tr -d "[v\r\n]"); -echo "commit: $COMMIT"; echo "tag: $TAG"; -gox -ldflags="-X github.com/tjhop/clip/cmd.builddate=$(date +%Y-%m-%d) - -X github.com/tjhop/clip/cmd.version=$TAG - -X github.com/tjhop/clip/cmd.commit=$COMMIT" \ - -osarch "linux/amd64" -output="$GOBIN/{{ .OS }}/{{ .Arch }}/clip" \ - -osarch "darwin/amd64" -output="$GOBIN/{{ .OS }}/{{ .Arch }}/clip" -``` - -Release archive creation: -```shell -~/go/src/github.com/tjhop/clip -> tar vzcf "clip-$(git describe --always --tags --abbrev=0 | tr -d '[v\r\n]').darwin-amd64.tar.gz" -C $GOBIN/darwin/amd64/ -s /\./clip/g . -~/go/src/github.com/tjhop/clip -> tar vzcf "clip-$(git describe --always --tags --abbrev=0 | tr -d '[v\r\n]').linux-amd64.tar.gz" -C $GOBIN/linux/amd64/ -s /\./clip/g . -``` +### Binaries +Binaries are built by [goreleaser and github actions](https://goreleaser.com/ci/actions/). Please see [Releases](#Releases) for more information on building binaries for release. + +For testing purposes, binaries can be built manually, as well: + ```shell + COMMIT=$(git rev-parse --short HEAD); + TAG=$(git describe --always --tags --abbrev=0 | tr -d "[v\r\n]"); + go build -o clip -ldflags="-X github.com/tjhop/clip/cmd.builddate=$(date --iso-8601=seconds) + -X github.com/tjhop/clip/cmd.version=$TAG + -X github.com/tjhop/clip/cmd.commit=$COMMIT" + ``` + +### Releases +Releases are handled by [goreleaser and github actions](https://goreleaser.com/ci/actions/). + +In order to cut a release, a new semver tag must be pushed to the repo: + Note: It's highly recommended to install [SVU](https://github.com/caarlos0/svu) to help with tag creation. + + ```shell + git checkout master + git fetch --tags origin master + git tag $(svu next) + git push --tags upstream master + ``` ## TODO - [ ] allow editing Clip config directly through `clip` commands like template files?