Skip to content

Commit

Permalink
ci(release): Use goreleaser
Browse files Browse the repository at this point in the history
- Adds more OS and ARCH types
- Standardizes our release artifacts
- Adds checksums
  • Loading branch information
ctlong committed Sep 16, 2023
1 parent f7acafe commit 5694945
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 44 deletions.
28 changes: 11 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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 }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Builds
bin
dist/

# Binaries for programs and plugins
*.exe
Expand Down
43 changes: 43 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -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"
32 changes: 5 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -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 [email protected]: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

Expand Down

0 comments on commit 5694945

Please sign in to comment.