Skip to content

Commit 653f495

Browse files
authored
Automate release with Github actions (#302)
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.
1 parent 5e860e5 commit 653f495

File tree

5 files changed

+125
-68
lines changed

5 files changed

+125
-68
lines changed

.github/workflows/go.yml

-36
This file was deleted.

.github/workflows/release.yml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags: [ 'v*.*.*' ]
6+
7+
env:
8+
REGISTRY: ghcr.io
9+
IMAGE_NAME: ${{ github.repository }}
10+
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
16+
packages: write
17+
18+
steps:
19+
-
20+
name: Checkout
21+
uses: actions/checkout@v2
22+
with:
23+
fetch-depth: 0
24+
25+
-
26+
name: Log into registry ${{ env.REGISTRY }}
27+
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
28+
with:
29+
registry: ${{ env.REGISTRY }}
30+
username: ${{ github.actor }}
31+
password: ${{ secrets.GITHUB_TOKEN }}
32+
33+
-
34+
name: Set up Go
35+
uses: actions/setup-go@v2
36+
with:
37+
go-version: 1.17
38+
39+
-
40+
name: Release
41+
uses: goreleaser/goreleaser-action@5a54d7e660bda43b405e8463261b3d25631ffe86
42+
with:
43+
distribution: goreleaser
44+
version: v0.176.0
45+
args: release --rm-dist
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/test.yml

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
fail-fast: true
14+
matrix:
15+
go: [ '1.17', '1.16', '1.15', '1.14' ]
16+
name: Go ${{ matrix.go }}
17+
steps:
18+
-
19+
name: Checkout
20+
uses: actions/checkout@v2
21+
with:
22+
fetch-depth: 0
23+
-
24+
name: Setup go
25+
uses: actions/setup-go@v2
26+
with:
27+
go-version: ${{ matrix.go }}
28+
-
29+
name: Tests
30+
run: make test
31+
32+
build:
33+
runs-on: ubuntu-latest
34+
steps:
35+
-
36+
name: Checkout
37+
uses: actions/checkout@v2
38+
with:
39+
fetch-depth: 0
40+
41+
-
42+
name: Setup go
43+
uses: actions/setup-go@v2
44+
with:
45+
go-version: 1.17
46+
47+
-
48+
name: Build
49+
uses: goreleaser/goreleaser-action@5a54d7e660bda43b405e8463261b3d25631ffe86
50+
with:
51+
distribution: goreleaser
52+
version: v0.176.0
53+
args: build --snapshot --rm-dist --skip-post-hooks --skip-validate

.goreleaser.yml

+14-15
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
project_name: toxiproxy
2+
13
# This is an example .goreleaser.yml file with some sane defaults.
24
# Make sure to check the documentation at http://goreleaser.com
35
env:
@@ -68,17 +70,16 @@ nfpms:
6870
dockers:
6971
- &docker
7072
use: buildx
71-
skip_push: true
7273
dockerfile: Dockerfile
7374
ids:
7475
- server
7576
- client
7677
goos: linux
7778
goarch: amd64
7879
image_templates:
79-
- shopify/toxiproxy:{{ .Version }}-amd64
80-
- shopify/toxiproxy:v{{ .Major }}-amd64
81-
- shopify/toxiproxy:v{{ .Major }}.{{ .Minor }}-amd64
80+
- ghcr.io/shopify/toxiproxy:{{ .Version }}-amd64
81+
- ghcr.io/shopify/toxiproxy:v{{ .Major }}-amd64
82+
- ghcr.io/shopify/toxiproxy:v{{ .Major }}.{{ .Minor }}-amd64
8283
build_flag_templates:
8384
- --platform=linux/amd64
8485
- --no-cache
@@ -93,9 +94,9 @@ dockers:
9394
- <<: *docker
9495
goarch: arm64
9596
image_templates:
96-
- shopify/toxiproxy:{{ .Version }}-arm64
97-
- shopify/toxiproxy:v{{ .Major }}-arm64
98-
- shopify/toxiproxy:v{{ .Major }}.{{ .Minor }}-arm64
97+
- ghcr.io/shopify/toxiproxy:{{ .Version }}-arm64
98+
- ghcr.io/shopify/toxiproxy:v{{ .Major }}-arm64
99+
- ghcr.io/shopify/toxiproxy:v{{ .Major }}.{{ .Minor }}-arm64
99100
build_flag_templates:
100101
- --platform=linux/arm64/v8
101102
- --no-cache
@@ -110,17 +111,15 @@ dockers:
110111

111112
docker_manifests:
112113
-
113-
skip_push: true
114-
name_template: shopify/{{ .ProjectName }}:{{ .Version }}
114+
name_template: ghcr.io/shopify/{{ .ProjectName }}:{{ .Version }}
115115
image_templates:
116-
- shopify/{{ .ProjectName }}:{{ .Version }}-amd64
117-
- shopify/{{ .ProjectName }}:{{ .Version }}-arm64
116+
- ghcr.io/shopify/{{ .ProjectName }}:{{ .Version }}-amd64
117+
- ghcr.io/shopify/{{ .ProjectName }}:{{ .Version }}-arm64
118118
-
119-
skip_push: true
120-
name_template: shopify/{{ .ProjectName }}:latest
119+
name_template: ghcr.io/shopify/{{ .ProjectName }}:latest
121120
image_templates:
122-
- shopify/{{ .ProjectName }}:{{ .Version }}-amd64
123-
- shopify/{{ .ProjectName }}:{{ .Version }}-arm64
121+
- ghcr.io/shopify/{{ .ProjectName }}:{{ .Version }}-amd64
122+
- ghcr.io/shopify/{{ .ProjectName }}:{{ .Version }}-arm64
124123

125124
changelog:
126125
sort: asc

README.md

+11-17
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,12 @@ Toxiproxy for Windows is available for download at https://github.com/Shopify/to
228228

229229
**Docker**
230230

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

233234
```bash
234-
$ docker pull shopify/toxiproxy
235-
$ docker run -it shopify/toxiproxy
235+
$ docker pull ghcr.io/shopify/toxiproxy
236+
$ docker run -it ghcr.io/shopify/toxiproxy
236237
```
237238

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

589587
### Release
590588

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

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

0 commit comments

Comments
 (0)