diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml
index 84b0a1c..71ddeb4 100644
--- a/.github/workflows/release.yaml
+++ b/.github/workflows/release.yaml
@@ -1,34 +1,33 @@
-name: goreleaser
+name: release
on:
- push:
- # Run only on tags
- tags:
- - "*"
+ # Only run when triggered through the Github UI or API.
+ workflow_dispatch: {}
permissions:
contents: write
packages: write
+ issues: write
concurrency:
- group: stencil-release-${{ github.head_ref }}
+ group: binhost-release-${{ github.head_ref }}
cancel-in-progress: true
jobs:
- goreleaser:
+ release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- - run: git fetch --force --tags
+ fetch-tags: true
- uses: jdx/mise-action@v2
with:
experimental: true
env:
GH_TOKEN: ${{ github.token }}
- name: Retrieve goreleaser version
- run: |
+ run: |-
echo "version=$(mise current goreleaser)" >> "$GITHUB_OUTPUT"
id: goreleaser
- name: Login to GitHub Container Registry
@@ -37,10 +36,28 @@ jobs:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- - uses: goreleaser/goreleaser-action@v5
+ - uses: fregante/setup-git-user@v2
+
+ # Bumping logic
+ - name: Get next version
+ id: next_version
+ uses: thenativeweb/get-next-version@main
+ with:
+ prefix: "v" # optional, defaults to ''
+ - name: Wait for manual approval
+ uses: trstringer/manual-approval@v1
+ with:
+ secret: ${{ secrets.GITHUB_TOKEN }}
+ approvers: "jaredallard"
+ issue-title: "Release ${{ steps.next_version.outputs.version }}"
+ - name: Create Tag
+ run: |-
+ git tag -a "${{ steps.next_version.outputs.version }}" -m "Release ${{ steps.next_version.outputs.version }}"
+ - name: Create release artifacts and Github Release
+ uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: v${{ steps.goreleaser.outputs.version }}
args: release --clean
env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
\ No newline at end of file
diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml
new file mode 100644
index 0000000..8561c43
--- /dev/null
+++ b/.github/workflows/tests.yaml
@@ -0,0 +1,56 @@
+name: tests
+on:
+ push:
+ branches:
+ - main
+ pull_request:
+
+permissions:
+ contents: read
+
+concurrency:
+ group: binhost-build-${{ github.head_ref }}
+ cancel-in-progress: true
+
+jobs:
+ gotest:
+ name: go test
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - uses: jdx/mise-action@v2
+ with:
+ experimental: true
+ env:
+ GH_TOKEN: ${{ github.token }}
+ - name: Download dependencies
+ run: go mod download
+ - name: Run go test
+ run: |
+ gotestsum -- -coverprofile=cover.out ./...
+ - name: Upload test coverage
+ uses: codecov/codecov-action@v4.3.0
+ with:
+ token: ${{ secrets.CODECOV_TOKEN }}
+ files: ./cover.out
+ fail_ci_if_error: true
+
+ golangci-lint:
+ name: golangci-lint
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - uses: jdx/mise-action@v2
+ with:
+ experimental: true
+ env:
+ GH_TOKEN: ${{ github.token }}
+ - name: Retrieve golangci-lint version
+ run: |
+ echo "version=$(mise current golangci-lint)" >> "$GITHUB_OUTPUT"
+ id: golangci_lint
+ - name: golangci-lint
+ uses: golangci/golangci-lint-action@v4
+ with:
+ version: v${{ steps.golangci_lint.outputs.version }}
+ args: --timeout=30m
\ No newline at end of file
diff --git a/.goreleaser.yaml b/.goreleaser.yaml
new file mode 100644
index 0000000..419678a
--- /dev/null
+++ b/.goreleaser.yaml
@@ -0,0 +1,58 @@
+# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
+# vim: set ts=2 sw=2 tw=0 fo=cnqoj
+project_name: binhost
+before:
+ hooks:
+ - go mod tidy
+builds:
+ - main: ./cmd/{{ .ProjectName }}
+ flags:
+ - -trimpath
+ ldflags:
+ - -s
+ - -w
+ env:
+ - CGO_ENABLED=0
+ goarch:
+ - amd64
+ - arm64
+ goos:
+ - linux
+ - darwin
+archives:
+ - format: tar.xz
+checksum:
+ name_template: "checksums.txt"
+snapshot:
+ name_template: "{{ incpatch .Version }}-next"
+changelog:
+ sort: asc
+ use: git
+ filters:
+ exclude:
+ - "^test:"
+ - "^chore:"
+ - "merge conflict"
+ - Merge pull request
+ - Merge remote-tracking branch
+ - Merge branch
+ - go mod tidy
+ groups:
+ - title: Dependency updates
+ regexp: "^.*(feat|chore|fix)\\(deps\\)*:+.*$"
+ order: 300
+ - title: "New Features"
+ regexp: "^.*feat[(\\w)]*:+.*$"
+ order: 100
+ - title: "Bug fixes"
+ regexp: "^.*fix[(\\w)]*:+.*$"
+ order: 200
+ - title: "Documentation updates"
+ regexp: "^.*docs[(\\w)]*:+.*$"
+ order: 400
+ - title: Other work
+ order: 9999
+
+release:
+ footer: |-
+ **Full Changelog**: https://github.com/jaredallard/binhost/compare/{{ .PreviousTag }}...{{ .Tag }}
diff --git a/.mise.toml b/.mise.toml
index 4f787a2..14877f6 100644
--- a/.mise.toml
+++ b/.mise.toml
@@ -1,27 +1,35 @@
+
+# Default versions of tools, to update these, set [tools.override]
[tools]
golang = "1.22"
-golangci-lint = "1.56.2"
+shfmt = "3"
+golangci-lint = "1.56"
+goreleaser = "latest"
"go:gotest.tools/gotestsum" = "v1.11.0"
"go:golang.org/x/tools/cmd/goimports" = "latest"
-[tasks.tests]
-alias = "test"
+[tasks.build]
+description = "Build a binary for the current platform/architecture"
+run = "go build -trimpath -o ./bin/ -v ./cmd/..."
+
+[tasks.test]
description = "Run tests"
-run = ["gotestsum", "golangci-lint run --allow-parallel-runners --fast"]
+run = "gotestsum"
+
+[tasks.lint]
+description = "Run linters"
+run = "golangci-lint run"
[tasks.fmt]
alias = "format"
description = "Format code"
-run = ["goimports -w .", "go mod tidy"]
+run = [
+ "go mod tidy",
+ "gofmt -s -w .",
+ "goimports -w .",
+ "shfmt -w -i 2 -ci -sr .",
+]
-[tasks.build]
-alias = "default"
-description = "Build the project"
-outputs = ["bin/binhost"]
-run = ["go mod download", "go build -v -trimpath -o bin/ ./cmd/..."]
+## <>
-[tasks.dev]
-depends = ["build"]
-sources = ["cmd/**/*.go", "internal/**/*.go", "go.mod", "go.sum"]
-env = { ENV = "development" }
-run = ["./bin/binhost"]
+## <>
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
index be3f7b2..bae94e1 100644
--- a/LICENSE
+++ b/LICENSE
@@ -658,4 +658,4 @@ specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
-.
+.
\ No newline at end of file
diff --git a/go.sum b/go.sum
index 1e56cae..7212d0b 100644
--- a/go.sum
+++ b/go.sum
@@ -100,8 +100,6 @@ github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s=
github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8=
github.com/muesli/termenv v0.15.2 h1:GohcuySI0QmI3wN8Ok9PtKGkgkFIk7y6Vpb5PvrY+Wo=
github.com/muesli/termenv v0.15.2/go.mod h1:Epx+iuz8sNs7mNKhxzH4fWXGNpZwUaJKRS1noLXviQ8=
-github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
-github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
@@ -114,10 +112,6 @@ github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc=
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
-github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
-github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
-github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
-github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
@@ -158,8 +152,6 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
-golang.org/x/tools v0.18.0 h1:k8NLag8AGHnn+PHbl7g43CtqZAwG60vZkLqgyZgIHgQ=
-golang.org/x/tools v0.18.0/go.mod h1:GL7B4CwcLLeo59yx/9UWWuNOW1n3VZ4f5axWfML7Lcg=
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
diff --git a/internal/packages/packages.go b/internal/packages/packages.go
index cb8ee96..51e7fec 100644
--- a/internal/packages/packages.go
+++ b/internal/packages/packages.go
@@ -188,6 +188,9 @@ func metadataFromDir(dir string) (*Metadata, error) {
// Calculate name and version from PF. The version is the last part of
// the string split by the '-' character.
+ //
+ // TODO(jaredallard): This will break on packages with - in the
+ // version. I'm not sure how we're supposed to get the version then.
parts := strings.Split(md.PF, "-")
md.Name = strings.Join(parts[:len(parts)-1], "-")
md.Version = parts[len(parts)-1]
diff --git a/stencil.lock b/stencil.lock
new file mode 100644
index 0000000..c43a24c
--- /dev/null
+++ b/stencil.lock
@@ -0,0 +1,21 @@
+version: (devel)
+modules:
+ - name: github.com/rgst-io/stencil-golang
+ url: https://github.com/rgst-io/stencil-golang
+ version: v0.1.3
+files:
+ - name: .github/workflows/release.yaml
+ template: .github/workflows/release.yaml.tpl
+ module: github.com/rgst-io/stencil-golang
+ - name: .github/workflows/tests.yaml
+ template: .github/workflows/tests.yaml.tpl
+ module: github.com/rgst-io/stencil-golang
+ - name: .goreleaser.yaml
+ template: .goreleaser.yaml.tpl
+ module: github.com/rgst-io/stencil-golang
+ - name: .mise.toml
+ template: .mise.toml.tpl
+ module: github.com/rgst-io/stencil-golang
+ - name: LICENSE
+ template: LICENSE_AGPL-3.0.tpl
+ module: github.com/rgst-io/stencil-golang
diff --git a/stencil.yaml b/stencil.yaml
new file mode 100644
index 0000000..0728b4d
--- /dev/null
+++ b/stencil.yaml
@@ -0,0 +1,6 @@
+name: binhost
+arguments:
+ org: jaredallard
+ license: AGPL-3.0
+modules:
+- name: github.com/rgst-io/stencil-golang