diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 6313b56..0000000 --- a/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -* text=auto eol=lf diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..97557aa --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,38 @@ +name: '🧑🏭' +on: [ push ] +permissions: + contents: write +jobs: + + check: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + check-latest: true + cache: true + - run: go vet ./... + - run: go test -v ./... + + release: + if: startsWith(github.ref, 'refs/tags/v') == true + needs: check + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + check-latest: true + cache: true + - uses: goreleaser/goreleaser-action@v5 + with: + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml deleted file mode 100644 index 90f40d6..0000000 --- a/.github/workflows/release.yaml +++ /dev/null @@ -1,19 +0,0 @@ -name: '🧑🏭' -on: [ push ] -jobs: - release: - if: startsWith(github.ref, 'refs/tags/v') - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5.0.0 - with: - go-version-file: 'go.mod' - check-latest: true - cache: true - - run: | - make release - - uses: softprops/action-gh-release@v2 - with: - body: 'Built at commit: ${{ github.sha }}' - files: 'out/*' diff --git a/.github/workflows/todos.yaml b/.github/workflows/todos.yaml deleted file mode 100644 index dc7e6b1..0000000 --- a/.github/workflows/todos.yaml +++ /dev/null @@ -1,26 +0,0 @@ -name: '✏️' -on: - workflow_dispatch: - inputs: - importAll: - default: false - required: false - type: boolean - description: Enable, if you want to import all TODOs. Runs on checked out branch! Only use if you're sure what you are doing. - push: - branches: - - 'master' - -permissions: - issues: write - repository-projects: read - contents: read - -jobs: - todos: - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 - - uses: derjuulsn/todo-issue@v1.1.4 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 097edd8..178135c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,17 +1 @@ -* -!*/ - -!/.github/**/*.yaml - -!/.gitattributes -!/.gitignore - -!/Makefile -!/deb.sh - -!/go.mod -!/go.sum -!/*.go - -!/LICENSE.txt -!/README.md +/dist/ diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..0f7b086 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,80 @@ +# This is a goreleaser config file. Check the docs at https://goreleaser.com +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +# vim: set ts=2 sw=2 tw=0 fo=cnqoj + +version: 1 + +project_name: gobonsai + +builds: + - binary: '{{ .ProjectName }}' + env: + - CGO_ENABLED=0 + tags: + - osusergo + - netgo + ldflags: + - '-s' + - '-w' + - '-X github.com/nothub/gobonsai/buildinfo.Version={{ .Version }}' + goos: + - linux + - darwin + - windows + ignore: + - goos: linux + goarch: 386 + - goos: windows + goarch: 386 + - goos: windows + goarch: arm64 + #no_unique_dist_dir: true + +upx: + - enabled: true + goos: [ linux, windows ] + compress: best + lzma: true + +archives: + - meta: false + name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}' + format_overrides: + - goos: windows + format: zip + files: + - LICENSE.txt + +nfpms: + - file_name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}' + maintainer: Florian Hübner <code@hub.lol> + description: |- + A bonsai tree generator + homepage: https://github.com/nothub/gobonsai + license: MIT + section: games + dependencies: + - libc6 (>= 2.24) + formats: + - apk + - deb + - rpm + - archlinux + bindir: /usr/local/bin + meta: false + +changelog: + sort: asc + +checksum: + name_template: "checksums.txt" + algorithm: sha256 + +release: + github: + owner: nothub + name: gobonsai + name_template: 'v{{ .Version }}' + header: 'Release generated at commit: {{ .ShortCommit }}' + draft: true + replace_existing_draft: true diff --git a/Makefile b/Makefile deleted file mode 100644 index 99440b3..0000000 --- a/Makefile +++ /dev/null @@ -1,32 +0,0 @@ -MOD_NAME = $(shell go list -m) -BIN_NAME = $(shell basename $(MOD_NAME)) -GIT_TAG = $(shell git describe --tags --dirty --match v[0-9]* 2> /dev/null || echo "v0.0.0-indev") -VERSION = $(GIT_TAG:v%=%) -GOFLAGS = -tags osusergo,netgo -LDFLAGS = -ldflags="-w -extldflags=-static -X '$(MOD_NAME)/version=$(VERSION)'" - -out/$(BIN_NAME): $(shell ls go.mod go.sum *.go) - $(info dev build of $(VERSION)) - go build $(GOFLAGS) -race $(LDFLAGS) -o out/$(BIN_NAME) - -.PHONY: release -release: clean - $(info release builds of $(VERSION)) - GOOS=linux GOARCH=amd64 go build $(GOFLAGS) $(LDFLAGS) -o out/$(BIN_NAME)_$(VERSION)_linux-amd64 - GOOS=linux GOARCH=arm64 go build $(GOFLAGS) $(LDFLAGS) -o out/$(BIN_NAME)_$(VERSION)_linux-arm64 - ./deb.sh $(VERSION) amd64 - ./deb.sh $(VERSION) arm64 - GOOS=darwin GOARCH=amd64 go build $(GOFLAGS) $(LDFLAGS) -o out/$(BIN_NAME)_$(VERSION)_darwin-amd64 - GOOS=darwin GOARCH=arm64 go build $(GOFLAGS) $(LDFLAGS) -o out/$(BIN_NAME)_$(VERSION)_darwin-arm64 - GOOS=windows GOARCH=amd64 go build $(GOFLAGS) $(LDFLAGS) -o out/$(BIN_NAME)_$(VERSION)_windows-amd64.exe - -.PHONY: clean -clean: - go clean - go mod tidy - rm -rf out - -.PHONY: check -check: - go vet - go test -v -parallel $(shell grep -c -E "^processor.*[0-9]+" "/proc/cpuinfo") $(MOD_NAME)/... diff --git a/buildinfo.go b/buildinfo.go index ff88b8a..946cea6 100644 --- a/buildinfo.go +++ b/buildinfo.go @@ -1,5 +1,4 @@ package main -// This variable will be populated at build-time. -// TODO: version variable not injected at build -var version = "" +// The Version variable will be populated at build-time. +var Version = "" diff --git a/deb.sh b/deb.sh deleted file mode 100755 index b0ea203..0000000 --- a/deb.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env sh - -set -o errexit -set -o nounset - -version="${1}" -arch="${2}" - -bin="out/gobonsai_${version}_linux-${arch}" -deb="out/gobonsai_${version}_${arch}.deb" -target="/usr/local/games/gobonsai" - -if ! test -r "${bin}"; then - echo >&2 "can not read ${bin}" - exit 1 -fi - -work=$(mktemp -d) -echo >&2 "assembling ${arch} deb in ${work}" - -mkdir -p "${work}/DEBIAN" -cat >"${work}/DEBIAN/control" <<EOF -Package: gobonsai -Version: ${version} -Architecture: ${arch} -Depends: libc6 (>= 2.24) -Priority: optional -Section: games -Description: A bonsai tree generator -Homepage: https://github.com/nothub/gobonsai -Maintainer: Florian Hübner <code@hub.lol> -EOF - -mkdir -p "$(dirname "${work}${target}")" -cp "${bin}" "${work}${target}" - -# generate checksums -(cd "${work}" && find . -type f -not -path "./DEBIAN/*" -exec md5sum {} \; >"${work}/DEBIAN/md5sums") - -# bundle deb package -dpkg-deb --root-owner-group --verbose --build "${work}" "${deb}" diff --git a/go.mod b/go.mod index edd7acb..5f2859c 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module hub.lol/gobonsai +module github.com/nothub/gobonsai go 1.20