Skip to content

Commit

Permalink
Update release script to publish to public S3 bucket (#263)
Browse files Browse the repository at this point in the history
* Add S3 as output to goreleaser config

* Update goreleaser to not need tag env var

* Update S3 bucket name

* Test change to point homebrew to S3

* Update homebrew-lekko branch name after testing

* Update deprecated goreleaser option

* Update README

* Update upgrade command instructions
  • Loading branch information
DavidSGK authored Nov 16, 2023
1 parent 5b97aae commit b7bf550
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 25 deletions.
96 changes: 83 additions & 13 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ builds:
# - windows
- darwin
ldflags:
- -X "main.version={{.Env.CLI_TAG}}"
- -X "main.version={{.Version}}"

archives:
- format: tar.gz
Expand All @@ -29,23 +29,94 @@ archives:
{{- if .Arm }}v{{ .Arm }}{{ end }}
# use zip for windows archives
format_overrides:
- goos: windows
format: zip
- goos: windows
format: zip
checksum:
name_template: 'checksums.txt'
name_template: "checksums.txt"
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
- "^docs:"
- "^test:"
project_name: lekko
# .goreleaser.yaml
blobs:
# You can have multiple blob configs
- # Cloud provider name:
# - s3 for AWS S3 Storage
# - azblob for Azure Blob Storage
# - gs for Google Cloud Storage
#
# Templates: allowed
provider: s3

# Set a custom endpoint, useful if you're using a minio backend or
# other s3-compatible backends.
#
# Implies s3ForcePathStyle and requires provider to be `s3`
#
# Templates: allowed
# endpoint: https://minio.foo.bar

# Sets the bucket region.
# Requires provider to be `s3`
#
# Templates: allowed
region: us-east-1

# Disables SSL
# Requires provider to be `s3`
# disableSSL: true

# Bucket name.
#
# Templates: allowed
bucket: "lekko-cli-releases"

# IDs of the artifacts you want to upload.
# ids:
# - foo
# - bar

# Path/name inside the bucket.
#
# Default: '{{ .ProjectName }}/{{ .Tag }}'
# Templates: allowed
folder: "{{.Version}}"

# Whether to disable this particular upload configuration.
#
# Since: v1.17
# Templates: allowed
# disable: '{{ neq .BLOB_UPLOAD_ONLY "foo" }}'

# You can add extra pre-existing files to the bucket.
# The filename on the release will be the last part of the path (base).
# If another file with the same name exists, the last one found will be used.
# These globs can also include templates.
# extra_files:
# - glob: ./path/to/file.txt
# - glob: ./glob/**/to/**/file/**/*
# - glob: ./glob/foo/to/bar/file/foobar/override_from_previous
# - glob: ./single_file.txt
# # Templates: allowed
# name_template: file.txt # note that this only works if glob matches 1 file only

# Additional templated extra files to uploaded.
# Those files will have their contents pass through the template engine,
# and its results will be uploaded.
#
# Since: v1.17 (pro)
# This feature is only available in GoReleaser Pro.
# Templates: allowed
# templated_extra_files:
# - src: LICENSE.tpl
# dst: LICENSE.txt
brews:
-
# Name template of the recipe
- # Name template of the recipe
# Default to project name
# name: myproject

Expand All @@ -72,7 +143,7 @@ brews:
# done with scoop.

# GitHub/GitLab repository to push the formula to
tap:
repository:
# Repository owner template. (templateable)
owner: lekkodev

Expand All @@ -92,18 +163,18 @@ brews:
# gitlab or gitea)
#
# Default depends on the client.
url_template: "https://github.com/lekkodev/cli/releases/download/{{ .Tag }}/{{ .ArtifactName }}"
url_template: "https://lekko-cli-releases.s3.amazonaws.com/{{ .Tag }}/{{ .ArtifactName }}"

# 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
# Default is empty.
download_strategy: GitHubPrivateRepositoryReleaseDownloadStrategy
download_strategy: CurlDownloadStrategy

# Allows you to add a custom require_relative at the top of the formula
# template.
# Default is empty
custom_require: ../lib/custom_download_strategy
# custom_require: ../lib/custom_download_strategy

# Git author used to commit to the repository.
# Defaults are shown.
Expand Down Expand Up @@ -190,7 +261,6 @@ brews:
# etc.install "app-config.conf"
# ...


# The lines beneath this are called `modelines`. See `:help modeline`
# Feel free to remove those if you don't want/use them.
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@

CLI Interface to the Lekko Dynamic Configuration Platform.

## Documentation
## Documentation

Find our documentation at https://app.lekko.com/docs.

## Download

To download `lekko` cli, you can use homebrew. Since the code is still in a private repository, you will need to use a Github personal access token that has been given access to `lekkodev/homebrew-lekko` and `lekkodev/cli` repos.
To download `lekko` cli, you can use homebrew.

```bash
export HOMEBREW_GITHUB_API_TOKEN=<MY_GITHUB_TOKEN>
brew tap lekkodev/lekko
brew install lekko
```
Expand Down Expand Up @@ -42,6 +41,8 @@ This command will first prompt you for a new tag that it will push to GitHub. Th

After completion, navigate to https://github.com/lekkodev/cli/releases/ to see the latest releases under the tag you just created.

Because the CLI repository is still private, the releaser is configured to publish the compiled assets to a public S3 bucket (`lekko-cli-releases`). The releaser is also responsible for generating/updating the homebrew formula for the lekkodev/lekko brew [tap](https://github.com/lekkodev/homebrew-lekko), which will download and install the CLI from that bucket.

Done! The cli has just been released. Follow instructions above to [Download](#download) the latest cli.

## Integration Tests
Expand Down
7 changes: 1 addition & 6 deletions cmd/lekko/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -594,14 +594,9 @@ func upgradeCmd() *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
fmt.Printf(
`Our CLI is currently managed by Homebrew.
In order to upgrade, first set your API key:
export LEKKO_API_KEY=lekko_********
Next, run the following commands:
In order to upgrade, run the following commands:
brew update
export HOMEBREW_GITHUB_API_TOKEN=$($(brew --repo)/Library/Taps/lekkodev/homebrew-lekko/gen_token.sh)
brew upgrade lekko
For more information, check out our docs:
Expand Down
5 changes: 2 additions & 3 deletions release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# First, ensure that the github token is set
if [[ -z $GITHUB_TOKEN ]]; then
echo Github token not found.
echo Github token not found.
echo "Please set your github token via \"export GITHUB_TOKEN=<your-gh-token>\" and try again."
exit 1
fi
Expand All @@ -13,7 +13,7 @@ echo What would you like the new tag to be?
read new_tag
tag_message=`git --no-pager log -1 --pretty=%s`

echo Pushing $new_tag: $tag_message.
echo Pushing $new_tag: $tag_message.
read -p "Continue? [y/N] " yn
case $yn in
[Yy]* ) echo Pushing to remote...;;
Expand All @@ -31,5 +31,4 @@ case $yn in
esac

# Build & release, setting the tag as the lekko cli version via ldflags.
export CLI_TAG=$new_tag
goreleaser release --clean

0 comments on commit b7bf550

Please sign in to comment.