Skip to content

Commit

Permalink
Automate release with Github actions (#302)
Browse files Browse the repository at this point in the history
The current process according the README is manual.
It requires to have access users to DockerHub.

After small investigation, found that DockerHub is not actively
internaly used and decided to switch container registry to Github.

The relase part was done with [goreleaser](https://github.com/goreleaser/goreleaser).
It can create Release in Github, Container registries and Homebrew.

Update documentation to use Github container registry for new versions.
  • Loading branch information
miry authored Aug 31, 2021
1 parent 5e860e5 commit 653f495
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 68 deletions.
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
packages: write

steps:
-
name: Checkout
uses: actions/checkout@v2
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

0 comments on commit 653f495

Please sign in to comment.