From 9eb798e0fe83e270186621c06c61cc1a8e7f5388 Mon Sep 17 00:00:00 2001 From: Leonidas Vrachnis Date: Wed, 16 Oct 2024 11:14:37 +0200 Subject: [PATCH] chore: add go releaser --- .github/workflows/release-please.yml | 0 .github/workflows/release.yml | 38 ++++++ .gitignore | 2 + .goreleaser.yaml | 182 +++++++++++++++++++++++++++ 4 files changed, 222 insertions(+) create mode 100644 .github/workflows/release-please.yml create mode 100644 .github/workflows/release.yml create mode 100644 .goreleaser.yaml diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 0000000..e69de29 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..e30e8ff --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,38 @@ +# .github/workflows/release.yml +name: goreleaser + +on: + pull_request: + push: + # run only against tags + tags: + - "*" + +permissions: + contents: write + # packages: write + # issues: write + # id-token: write + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: stable + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v6 + with: + # either 'goreleaser' (default) or 'goreleaser-pro' + distribution: goreleaser + # 'latest', 'nightly', or a semver + version: "~> v2" + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 6f72f89..ebca398 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,5 @@ go.work.sum # env file .env + +dist/ diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..10c5216 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,182 @@ +# This is an example .goreleaser.yml file with some sensible defaults. +# Make sure to check the documentation at https://goreleaser.com + +# The lines below are called `modelines`. See `:help modeline` +# Feel free to remove those if you don't want/need to use them. +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +# vim: set ts=2 sw=2 tw=0 fo=cnqoj + +version: 2 + +before: + hooks: + # You may remove this if you don't use go modules. + - go mod tidy + # you may remove this if you don't need go generate + - go generate ./... + +builds: + - env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin + +archives: + - format: tar.gz + # this name template makes the OS and Arch compatible with the results of `uname`. + name_template: >- + {{ .ProjectName }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}v{{ .Arm }}{{ end }} + # use zip for windows archives + format_overrides: + - goos: windows + format: zip + +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" + + +brews: + - + # Name of the recipe + # + # Default: the project name. + # Templates: allowed. + name: git-hooks + + + # IDs of the archives to use. + # Empty means all IDs. + ids: + - foo + - bar + + # GOARM to specify which 32-bit arm version to use if there are multiple + # versions from the build section. Brew formulas support only one 32-bit + # version. + # + # Default: 6. + goarm: 6 + + # GOAMD64 to specify which amd64 version to use if there are multiple + # versions from the build section. + # + # Default: v1. + goamd64: v1 + + + # Headers to include in the `url` stanza. + # This can be a more modern alternative to `download_strategy` in some + # cases. + url_headers: + - "Accept: application/octet-stream" + - 'Authorization: bearer #{ENV["HOMEBREW_GITHUB_API_TOKEN"]}' + + # Allows you to set a custom download strategy. Note that you'll need + # to implement the strategy and add it to your tap repository. + # Example: https://docs.brew.sh/Formula-Cookbook#specifying-the-download-strategy-explicitly + download_strategy: CurlDownloadStrategy + + + # Git author used to commit to the repository. + commit_author: + name: goreleaserbot + email: bot@goreleaser.com + + # The project name and current git tag are used in the format string. + # + # Templates: allowed. + commit_msg_template: "Brew formula update for {{ .ProjectName }} version {{ .Tag }}" + + # Directory inside the repository to put the formula. + directory: Formula + + + # Your app's homepage. + # + # Default: inferred from global metadata. + homepage: "https://github.com/lvrach/git-hooks/" + + # Setting this will prevent goreleaser to actually try to commit the updated + # formula - instead, the formula file will be stored on the dist directory + # only, leaving the responsibility of publishing it to the user. + # If set to auto, the release will not be uploaded to the homebrew tap + # in case there is an indicator for prerelease in the tag e.g. v1.0.0-rc1 + # + # Templates: allowed. + skip_upload: true + + + # Packages your package depends on. + dependencies: + - name: git + # Allow to specify the OS in which the dependency is required. + # Valid options are `mac` and `linux`. + os: mac + - name: zsh + type: optional + + + + # So you can `brew test` your formula. + # + # Template: allowed + test: | + system "#{bin}/git-hooks" + + + # Additional install instructions so you don't need to override `install`. + # + # Template: allowed + extra_install: | + bash_completion.install "completions/foo.bash" => "foo" + + + # Repository to push the generated files to. + repository: + # Repository owner. + # + # Templates: allowed. + owner: lvrach + + # Repository name. + # + # Templates: allowed. + name: git-hooks + + # Optionally a branch can be provided. + # + # Default: default repository branch. + # Templates: allowed. + branch: main + + + # Sets up pull request creation instead of just pushing to the given branch. + # Make sure the 'branch' property is different from base before enabling + # it. + # + # This might require a personal access token. + pull_request: + # Whether to enable it or not. + enabled: true + + # Whether to open the PR as a draft or not. + draft: true + + + # Base can also be another repository, in which case the owner and name + # above will be used as HEAD, allowing cross-repository pull requests. + base: + owner: lvrach + name: git-hooks + branch: main