diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d3fe708a..a4ca91c7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,6 +20,14 @@ jobs: uses: actions/setup-go@v2 with: go-version: 1.16 + - + name: Set up Snapcraft + # FIXME: the mkdirs are a hack for https://github.com/goreleaser/goreleaser/issues/1715 + run: | + sudo apt-get update + sudo apt-get -yq --no-install-suggests --no-install-recommends install snapcraft + mkdir -p $HOME/.cache/snapcraft/download + mkdir -p $HOME/.cache/snapcraft/stage-packages - name: Login to GitHub Container Registry if: startsWith(github.ref, 'refs/tags/v') @@ -28,6 +36,11 @@ jobs: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} + - + name: Snapcraft Login + if: startsWith(github.ref, 'refs/tags/v') + run: | + snapcraft login --with <(echo "${{ secrets.SNAPCRAFT_LOGIN }}") - name: Run GoReleaser uses: goreleaser/goreleaser-action@v2 @@ -36,3 +49,4 @@ jobs: args: release --rm-dist -f ./.goreleaser.yml env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.GH_PAT }} diff --git a/.goreleaser.yml b/.goreleaser.yml index 5374c8be..6d296094 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,14 +1,11 @@ --- -# This is an example .goreleaser.yml file with some sane defaults. -# Make sure to check the documentation at http://goreleaser.com 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 ./... + - ./scripts/completions.sh builds: - - env: + - id: yot + env: - CGO_ENABLED=0 goos: - linux @@ -26,6 +23,13 @@ archives: 386: i386 amd64: x86_64 name_template: "yot_v{{ .Version }}_{{ .Os }}_{{ .Arch }}" + format_overrides: + - goos: windows + format: zip + files: + - README.md + - LICENSE + - completions/* checksum: name_template: 'checksums.txt' snapshot: @@ -34,11 +38,11 @@ changelog: sort: asc filters: exclude: - - '^docs:' - - '^test:' - - '^ci:' - - '^chore:' - - '^build' + - '^docs(\(.*\))?:' + - '^test(\(.*\))?:' + - '^ci(\(.*\))?:' + - '^chore(\(.*\))?:' + - '^build(\(.*\))?:' project_name: yot dockers: - image_templates: @@ -55,3 +59,89 @@ dockers: - "--label=org.opencontainers.image.licenses=MIT" - "--label=VERSION={{.Version}}" - "--platform=linux/amd64" +brews: + - name: yot + + tap: + owner: vmware-tanzu-labs + name: homebrew-tap + token: "{{ .Env.HOMEBREW_TAP_GITHUB_TOKEN }}" + + # Git author used to commit to the repository. + # Defaults are shown. + commit_author: + name: goreleaserbot + email: goreleaser@vmware-tanzu-labs.com + + # Folder inside the repository to put the formula. + # Default is the root folder. + folder: Formula + + # Your app's homepage. + # Default is empty. + homepage: "https://github.com/vmware-tanzu-labs/yaml-overlay-tool" + + # Template of your app's description. + # Default is empty. + description: "A YAML Overlay Tool with templating tendencies." + + # SPDX identifier of your app's license. + # Default is empty. + license: "MIT" + + # Setting this will prevent goreleaser to actually try to commit the updated + # formula - instead, the formula file will be stored on the dist folder 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 + # Default is false. + skip_upload: auto + + # Packages your package depends on. + dependencies: + - name: kubectl + type: optional + + install: |- + bin.install "yot" + bash_completion.install "completions/yot.bash" => "yot" + zsh_completion.install "completions/yot.zsh" => "_yot" + fish_completion.install "completions/yot.fish" + + # So you can `brew test` your formula. + # Default is empty. + test: | + system "#{bin}/yot --version" +nfpms: + - file_name_template: '{{ .ProjectName }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}' + homepage: https://github.com/vmware-tanzu-labs/yaml-overlay-tool.com + description: "A YAML Overlay Tool with templating tendencies." + maintainer: Jeff Davis , Andrew Huffman + license: MIT + vendor: VMware Tanzu Labs + contents: + - src: ./completions/yot.bash + dst: /etc/bash_completion.d/yot + - src: ./completions/yot.fish + dst: /usr/share/fish/completions/yot.fish + - src: ./completions/yot.zsh + dst: /usr/local/share/zsh/site-functions/_yot + formats: + - apk + - deb + - rpm + recommends: + - kubectl +snapcrafts: + - name_template: '{{ .ProjectName }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}' + name: yaml-overlay-tool + summary: "A YAML Overlay Tool with templating tendencies." + description: | + YAML Overlay Tool, or Yot for short, often pronounced /yaucht/, is a tool + to assist with patching YAML files. Yot uses JSONPath to query YAML documents + within YAML files, and to perform a change. YAML Overlay Tool operates on YAML + nodes. It is able to preserve and inject head, foot, and line comments into the + new output versions of the files that you manipulate. + grade: stable + confinement: strict + publish: true \ No newline at end of file diff --git a/README.md b/README.md index f349f4c9..dce26dc5 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,9 @@ [![Go Report Card](https://goreportcard.com/badge/github.com/vmware-tanzu-labs/yaml-overlay-tool)](https://goreportcard.com/report/github.com/vmware-tanzu-labs/yaml-overlay-tool) [![GitHub](https://img.shields.io/github/license/vmware-tanzu-labs/yaml-overlay-tool)](https://github.com/vmware-tanzu-labs/yaml-overlay-tool/blob/main/LICENSE) [![GitHub release (latest by date)](https://img.shields.io/github/v/release/vmware-tanzu-labs/yaml-overlay-tool)](https://github.com/vmware-tanzu-labs/yaml-overlay-tool/releases) +![Github Downloads (by Release)](https://img.shields.io/github/downloads/vmware-tanzu-labs/yaml-overlay-tool/total.svg) + +[![Get it from the Snap Store](https://snapcraft.io/static/images/badges/en/snap-store-black.svg)](https://snapcraft.io/yaml-overlay-tool) # YAML Overlay Tool (Yot) YAML Overlay Tool, or Yot for short, often pronounced */yaucht/*, is a tool to assist with patching YAML files. Yot uses JSONPath to query YAML documents within YAML files, and to perform a change. YAML Overlay Tool operates on YAML nodes. It is able to preserve and inject head, foot, and line comments into the new output versions of the files that you manipulate. diff --git a/scripts/completions.sh b/scripts/completions.sh new file mode 100755 index 00000000..ddb8eedd --- /dev/null +++ b/scripts/completions.sh @@ -0,0 +1,7 @@ +#!/bin/sh +set -e +rm -rf completions +mkdir completions +for sh in bash zsh fish; do + go run ./cmd/yot completion "$sh" >"completions/yot.$sh" +done \ No newline at end of file