From 569494532812404d13941a9a156e300c137ed969 Mon Sep 17 00:00:00 2001 From: Carson Long Date: Fri, 15 Sep 2023 16:58:23 -0700 Subject: [PATCH] ci(release): Use goreleaser - Adds more OS and ARCH types - Standardizes our release artifacts - Adds checksums --- .github/workflows/release.yml | 28 +++++++++-------------- .gitignore | 1 + .goreleaser.yaml | 43 +++++++++++++++++++++++++++++++++++ README.md | 32 ++++---------------------- 4 files changed, 60 insertions(+), 44 deletions(-) create mode 100644 .goreleaser.yaml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ab309768..dd7c697a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,10 +1,12 @@ -name: Release from main +name: Create release on new tag + on: - workflow_dispatch: - inputs: - version: - description: 'Semver version to cut a release for (ie. 4.0.3)' - required: true + push: + tags: + - '*' + +permissions: + contents: write jobs: release: @@ -15,16 +17,8 @@ jobs: with: go-version-file: go.mod check-latest: true - - run: | - GOOS=linux go build -ldflags "-X main.version=$VERSION" -o bin/log-cache-cf-plugin-linux - GOOS=darwin go build -ldflags "-X main.version=$VERSION" -o bin/log-cache-cf-plugin-darwin - GOOS=windows go build -ldflags "-X main.version=$VERSION" -o bin/log-cache-cf-plugin-windows - env: - VERSION: ${{ github.event.inputs.version }} - CGO_ENABLED: 0 - - run: | - go_version=`go version | { read _ _ v _; echo ${v#go}; }` - gh release create -d -t "v$VERSION" --generate-notes "v$VERSION" --notes ":sparkles: built with go$go_version" ./bin/* + - uses: goreleaser/goreleaser-action@v5 + with: + args: release --clean env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - VERSION: ${{ github.event.inputs.version }} diff --git a/.gitignore b/.gitignore index c9a6de31..0b5d2f9e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # Builds bin +dist/ # Binaries for programs and plugins *.exe diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 00000000..8e2b42c6 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,43 @@ +# For more options see: https://goreleaser.com/customization + +before: + hooks: + - go mod tidy + - go mod vendor + +project_name: log-cache + +builds: +- env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin + +archives: +- format: tar.gz + name_template: >- + {{- .ProjectName }}_ + {{- .Version }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}v{{ .Arm }}{{ end }} + format_overrides: + - goos: windows + format: zip + +checksum: + name_template: 'checksums.txt' + +snapshot: + name_template: "{{ incpatch .Version }}-dev" + +changelog: + skip: true + +release: + draft: true + header: ":sparkles: built with {{ .Env.GOVERSION }}\n" diff --git a/README.md b/README.md index a48eeb93..91b0da3b 100644 --- a/README.md +++ b/README.md @@ -1,42 +1,20 @@ # Log Cache cf CLI Plugin -[![GoDoc][go-doc-badge]][go-doc] +A [Cloud Foundry CLI](https://github.com/cloudfoundry/cli) plugin for interacting with the +[Log Cache BOSH release](https://github.com/cloudfoundry/log-cache-release). -A [cf CLI](https://github.com/cloudfoundry/cli) plugin for interacting with -[Log Cache](https://github.com/cloudfoundry/log-cache). - -If you have any questions, or want to get attention for a PR or issue please reach out on the [#logging-and-metrics channel in the cloudfoundry slack](https://cloudfoundry.slack.com/archives/CUW93AF3M) +If you have any questions, or want to get attention for a PR or issue please reach out on the [#logging-and-metrics channel in Cloud Foundry slack](https://cloudfoundry.slack.com/archives/CUW93AF3M) ![Plugin Demo](./docs/Plugin-demo.gif) ## Installing Install directly from the [Cloud Foundry CLI Plugin Repository](https://github.com/cloudfoundry/cli-plugin-repo): -``` +```bash cf install-plugin -r CF-Community "log-cache" ``` -Or, you can download a pre-built binary from GitHub: -``` -# Linux -wget https://github.com/cloudfoundry/log-cache-cli/releases/latest/download/log-cache-cf-plugin-linux -cf install-plugin -f log-cache-cf-plugin-linux - -# OSX -wget https://github.com/cloudfoundry/log-cache-cli/releases/latest/download/log-cache-cf-plugin-darwin -cf install-plugin -f log-cache-cf-plugin-darwin - -# Windows -wget https://github.com/cloudfoundry/log-cache-cli/releases/latest/download/log-cache-cf-plugin-windows -cf install-plugin -f log-cache-cf-plugin-windows -``` - -Alternatively, you can build from source: -``` -git clone git@github.com:cloudfoundry/log-cache-cli.git -cd log-cache-cli -scripts/install.sh -``` +Or, download a pre-built binary from [releases](https://github.com/cloudfoundry/log-cache-cli/releases/latest). ## Creating Releases