Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate release with Github actions #302

Merged
merged 1 commit into from
Aug 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 0 additions & 36 deletions .github/workflows/go.yml

This file was deleted.

47 changes: 47 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Release

on:
push:
tags: [ 'v*.*.*' ]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noice - I like how this drops privileges 😍.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It requires for release to Github.

packages: write

steps:
-
name: Checkout
uses: actions/checkout@v2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idea: did you consider using the commit/digest, instead of tracking a mutable tag?

Maybe just for goreleaser/goreleaser-action? The first party actions/* actions are less important, but pinning third party actions is a best practice.

I'm a fan of pinning to immutable digests, then using Dependabot to follow v2.3.3 -> v2.3.4, instead of following the mutable v2 tag.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Thank you for the full clarification.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am going to keep the official actions like actions/checkout@v2 and actions/setup-go@v2, because there are no maintainers to merge Dependbot's PRs and it was suggested by Github.

with:
fetch-depth: 0

-
name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

-
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17

-
name: Release
uses: goreleaser/goreleaser-action@5a54d7e660bda43b405e8463261b3d25631ffe86
with:
distribution: goreleaser
version: v0.176.0
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53 changes: 53 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Test

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
go: [ '1.17', '1.16', '1.15', '1.14' ]
name: Go ${{ matrix.go }}
steps:
-
name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
-
name: Setup go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
-
name: Tests
run: make test

build:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

-
name: Setup go
uses: actions/setup-go@v2
with:
go-version: 1.17

-
name: Build
uses: goreleaser/goreleaser-action@5a54d7e660bda43b405e8463261b3d25631ffe86
with:
distribution: goreleaser
version: v0.176.0
args: build --snapshot --rm-dist --skip-post-hooks --skip-validate
29 changes: 14 additions & 15 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
project_name: toxiproxy

# This is an example .goreleaser.yml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
env:
Expand Down Expand Up @@ -68,17 +70,16 @@ nfpms:
dockers:
- &docker
use: buildx
skip_push: true
dockerfile: Dockerfile
ids:
- server
- client
goos: linux
goarch: amd64
image_templates:
- shopify/toxiproxy:{{ .Version }}-amd64
- shopify/toxiproxy:v{{ .Major }}-amd64
- shopify/toxiproxy:v{{ .Major }}.{{ .Minor }}-amd64
- ghcr.io/shopify/toxiproxy:{{ .Version }}-amd64
- ghcr.io/shopify/toxiproxy:v{{ .Major }}-amd64
- ghcr.io/shopify/toxiproxy:v{{ .Major }}.{{ .Minor }}-amd64
build_flag_templates:
- --platform=linux/amd64
- --no-cache
Expand All @@ -93,9 +94,9 @@ dockers:
- <<: *docker
goarch: arm64
image_templates:
- shopify/toxiproxy:{{ .Version }}-arm64
- shopify/toxiproxy:v{{ .Major }}-arm64
- shopify/toxiproxy:v{{ .Major }}.{{ .Minor }}-arm64
- ghcr.io/shopify/toxiproxy:{{ .Version }}-arm64
- ghcr.io/shopify/toxiproxy:v{{ .Major }}-arm64
- ghcr.io/shopify/toxiproxy:v{{ .Major }}.{{ .Minor }}-arm64
build_flag_templates:
- --platform=linux/arm64/v8
- --no-cache
Expand All @@ -110,17 +111,15 @@ dockers:

docker_manifests:
-
skip_push: true
name_template: shopify/{{ .ProjectName }}:{{ .Version }}
name_template: ghcr.io/shopify/{{ .ProjectName }}:{{ .Version }}
image_templates:
- shopify/{{ .ProjectName }}:{{ .Version }}-amd64
- shopify/{{ .ProjectName }}:{{ .Version }}-arm64
- ghcr.io/shopify/{{ .ProjectName }}:{{ .Version }}-amd64
- ghcr.io/shopify/{{ .ProjectName }}:{{ .Version }}-arm64
-
skip_push: true
name_template: shopify/{{ .ProjectName }}:latest
name_template: ghcr.io/shopify/{{ .ProjectName }}:latest
image_templates:
- shopify/{{ .ProjectName }}:{{ .Version }}-amd64
- shopify/{{ .ProjectName }}:{{ .Version }}-arm64
- ghcr.io/shopify/{{ .ProjectName }}:{{ .Version }}-amd64
- ghcr.io/shopify/{{ .ProjectName }}:{{ .Version }}-arm64

changelog:
sort: asc
Expand Down
28 changes: 11 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,12 @@ Toxiproxy for Windows is available for download at https://github.com/Shopify/to

**Docker**

Toxiproxy is available on [Docker Hub](https://hub.docker.com/r/shopify/toxiproxy/).
Toxiproxy is available on [Github container registry](https://github.com/Shopify/toxiproxy/pkgs/container/toxiproxy).
Old versions `<= 2.1.4` are available on on [Docker Hub](https://hub.docker.com/r/shopify/toxiproxy/).

```bash
$ docker pull shopify/toxiproxy
$ docker run -it shopify/toxiproxy
$ docker pull ghcr.io/shopify/toxiproxy
$ docker run -it ghcr.io/shopify/toxiproxy
```

If using Toxiproxy from the host rather than other containers, enable host networking with `--net=host`.
Expand Down Expand Up @@ -579,25 +580,18 @@ For example, `shopify_test_redis_master` or `shopify_development_mysql_1`.
* `make`. Build a toxiproxy development binary for the current platform.
* `make all`. Build Toxiproxy binaries and packages for all platforms. Requires
to have Go compiled with cross compilation enabled on Linux and Darwin (amd64)
as well as [`fpm`](https://github.com/jordansissel/fpm) in your `$PATH` to
build the Debian package.
as well as [`goreleaser`](https://goreleaser.com/) in your `$PATH` to
build binaries the Linux package.
* `make test`. Run the Toxiproxy tests.
* `make darwin`. Build binary for Darwin.
* `make linux`. Build binary for Linux.
* `make windows`. Build binary for Windows.

### Release

1. Ensure this release has run internally for `Shopify/shopify` for at least a
day which is the best fuzzy test for robustness we have.
2. Update `CHANGELOG.md`
3. Bump `VERSION`
4. Change versions in `README.md`
5. Commit
6. Tag
7. `make release` to create binaries, packages and push new Docker image
8. Create [Github draft release](https://github.com/Shopify/toxiproxy/releases/new) against new tag and upload binaries and Debian package
9. [Bump version for Homebrew](https://github.com/Shopify/homebrew-shopify/blob/master/toxiproxy.rb#L9)

1. Update `CHANGELOG.md`
1. Bump `VERSION`
1. Change versions in `README.md`
1. Commit, Tag, and Push
1. [Bump version for Homebrew](https://github.com/Shopify/homebrew-shopify/blob/master/toxiproxy.rb#L9)

[blog]: https://shopifyengineering.myshopify.com/blogs/engineering/building-and-testing-resilient-ruby-on-rails-applications