Skip to content

Commit 95278df

Browse files
authoredJan 5, 2022
Automate binary releases (cucumber#437)
* Add release assets automation * Use single module with local replace for examples * Update CHANGELOG.md * Allow expected failure for custom formatter example test * Set version value with ldflags * Restore artifacts cleanup
1 parent 1dcc44f commit 95278df

File tree

19 files changed

+110
-1380
lines changed

19 files changed

+110
-1380
lines changed
 

‎.github/workflows/release-assets.yml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# This script uploads application binaries as GitHub release assets.
2+
name: release-assets
3+
on:
4+
release:
5+
types:
6+
- created
7+
env:
8+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9+
10+
jobs:
11+
build:
12+
name: Upload Release Assets
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Install Go
16+
uses: actions/setup-go@v2
17+
with:
18+
go-version: 1.17.x
19+
- name: Checkout code
20+
uses: actions/checkout@v2
21+
- name: Build artifacts
22+
run: |
23+
make artifacts
24+
- name: Upload linux amd64 binary
25+
uses: actions/upload-release-asset@v1
26+
with:
27+
upload_url: ${{ github.event.release.upload_url }}
28+
asset_path: ./_artifacts/godog-${{ github.event.release.tag_name }}-linux-amd64.tar.gz
29+
asset_name: godog-${{ github.event.release.tag_name }}-linux-amd64.tar.gz
30+
asset_content_type: application/tar+gzip
31+
- name: Upload linux arm64 binary
32+
uses: actions/upload-release-asset@v1
33+
with:
34+
upload_url: ${{ github.event.release.upload_url }}
35+
asset_path: ./_artifacts/godog-${{ github.event.release.tag_name }}-linux-arm64.tar.gz
36+
asset_name: godog-${{ github.event.release.tag_name }}-linux-arm64.tar.gz
37+
asset_content_type: application/tar+gzip
38+
- name: Upload darwin amd64 binary
39+
uses: actions/upload-release-asset@v1
40+
with:
41+
upload_url: ${{ github.event.release.upload_url }}
42+
asset_path: ./_artifacts/godog-${{ github.event.release.tag_name }}-darwin-amd64.tar.gz
43+
asset_name: godog-${{ github.event.release.tag_name }}-darwin-amd64.tar.gz
44+
asset_content_type: application/tar+gzip

‎CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ This document is formatted according to the principles of [Keep A CHANGELOG](htt
1010

1111
## [Unreleased]
1212

13+
### Added
14+
15+
- Automated binary releases with GitHub Actions ([437](https://github.com/cucumber/godog/pull/437) - [vearutop])
16+
- Automated binary versioning with `go install` ([437](https://github.com/cucumber/godog/pull/437) - [vearutop])
17+
- Module with local replace in examples ([437](https://github.com/cucumber/godog/pull/437) - [vearutop])
18+
1319
### Changed
1420

1521
- suggest to use `go install` instead of the deprecated `go get` to install the `godog` binary ([449](https://github.com/cucumber/godog/pull/449) - [dmitris](https://github.com/dmitris))

‎Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.PHONY: test gherkin bump cover
22

3-
VERS := $(shell grep 'const Version' -m 1 godog.go | awk -F\" '{print $$2}')
3+
VERS ?= $(shell git symbolic-ref -q --short HEAD || git describe --tags --exact-match)
44

55
FOUND_GO_VERSION := $(shell go version)
66
EXPECTED_GO_VERSION = 1.17
@@ -58,7 +58,7 @@ artifacts:
5858

5959
define _build
6060
mkdir $(ARTIFACT_DIR)/godog-$(VERS)-$1-$2
61-
env GOOS=$1 GOARCH=$2 go build -o $(ARTIFACT_DIR)/godog-$(VERS)-$1-$2/godog ./cmd/godog
61+
env GOOS=$1 GOARCH=$2 go build -ldflags "-X github.com/cucumber/godog.Version=$(VERS)" -o $(ARTIFACT_DIR)/godog-$(VERS)-$1-$2/godog ./cmd/godog
6262
cp README.md $(ARTIFACT_DIR)/godog-$(VERS)-$1-$2/README.md
6363
cp LICENSE $(ARTIFACT_DIR)/godog-$(VERS)-$1-$2/LICENSE
6464
cd $(ARTIFACT_DIR) && tar -c --use-compress-program="pigz --fast" -f godog-$(VERS)-$1-$2.tar.gz godog-$(VERS)-$1-$2 && cd ..

‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ godogs
244244
- godogs_test.go
245245
```
246246

247-
#### Step 6 - Add some logic to the step defintions
247+
#### Step 6 - Add some logic to the step definitions
248248

249249
Now lets implement our step definitions to test our feature requirements:
250250

‎_examples/api/features/version.feature

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ Feature: get version
2020
And the response should match json:
2121
"""
2222
{
23-
"version": "v0.11.0"
23+
"version": "v0.0.0-dev"
2424
}
2525
"""

‎_examples/api/go.mod

-5
This file was deleted.

‎_examples/api/go.sum

-329
This file was deleted.

‎_examples/assert-godogs/go.mod

-9
This file was deleted.

‎_examples/assert-godogs/go.sum

-329
This file was deleted.

‎_examples/custom-formatter/go.mod

-13
This file was deleted.

‎_examples/custom-formatter/godogs_test.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ func TestMain(m *testing.M) {
3131
Options: &opts,
3232
}.Run()
3333

34-
os.Exit(status)
34+
// This example test is expected to fail to showcase custom formatting, suppressing status.
35+
if status != 1 {
36+
os.Exit(1)
37+
}
3538
}
3639

3740
func thereAreGodogs(available int) error {

‎_examples/db/go.mod

-10
This file was deleted.

‎_examples/db/go.sum

-335
This file was deleted.

‎_examples/go.mod

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module github.com/cucumber/godog/_examples
2+
3+
go 1.17
4+
5+
replace github.com/cucumber/godog => ../
6+
7+
require (
8+
github.com/DATA-DOG/go-txdb v0.1.4
9+
github.com/cucumber/godog v0.0.0-00010101000000-000000000000
10+
github.com/go-sql-driver/mysql v1.6.0
11+
github.com/spf13/pflag v1.0.5
12+
github.com/stretchr/testify v1.7.0
13+
)
14+
15+
require (
16+
github.com/cucumber/gherkin-go/v19 v19.0.3 // indirect
17+
github.com/cucumber/messages-go/v16 v16.0.1 // indirect
18+
github.com/davecgh/go-spew v1.1.1 // indirect
19+
github.com/gofrs/uuid v4.0.0+incompatible // indirect
20+
github.com/hashicorp/go-immutable-radix v1.3.0 // indirect
21+
github.com/hashicorp/go-memdb v1.3.0 // indirect
22+
github.com/hashicorp/golang-lru v0.5.4 // indirect
23+
github.com/lib/pq v1.10.3 // indirect
24+
github.com/pmezard/go-difflib v1.0.0 // indirect
25+
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect
26+
)

‎_examples/custom-formatter/go.sum ‎_examples/go.sum

+9-7
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiy
1313
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
1414
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
1515
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
16+
github.com/DATA-DOG/go-txdb v0.1.4 h1:6On4TAD6V33/QlE6Y5l0A4KngRzYrUQ7bgPsDrFrtQo=
17+
github.com/DATA-DOG/go-txdb v0.1.4/go.mod h1:DhAhxMXZpUJVGnT+p9IbzJoRKvlArO2pkHjnGX7o0n0=
1618
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
1719
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
1820
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
@@ -31,7 +33,6 @@ github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3Ee
3133
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
3234
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
3335
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
34-
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
3536
github.com/cucumber/gherkin-go/v19 v19.0.3 h1:mMSKu1077ffLbTJULUfM5HPokgeBcIGboyeNUof1MdE=
3637
github.com/cucumber/gherkin-go/v19 v19.0.3/go.mod h1:jY/NP6jUtRSArQQJ5h1FXOUgk5fZK24qtE7vKi776Vw=
3738
github.com/cucumber/messages-go/v16 v16.0.0/go.mod h1:EJcyR5Mm5ZuDsKJnT2N9KRnBK30BGjtYotDKpwQ0v6g=
@@ -49,6 +50,8 @@ github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9
4950
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
5051
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
5152
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
53+
github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
54+
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
5255
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
5356
github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw=
5457
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
@@ -83,12 +86,10 @@ github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyN
8386
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
8487
github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
8588
github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
89+
github.com/hashicorp/go-immutable-radix v1.3.0 h1:8exGP7ego3OmkfksihtSouGMZ+hQrhxx+FVELeXpVPE=
8690
github.com/hashicorp/go-immutable-radix v1.3.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
87-
github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc=
88-
github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
91+
github.com/hashicorp/go-memdb v1.3.0 h1:xdXq34gBOMEloa9rlGStLxmfX/dyIK8htOv36dQUwHU=
8992
github.com/hashicorp/go-memdb v1.3.0/go.mod h1:Mluclgwib3R93Hk5fxEfiRhB+6Dar64wWh71LpNSe3g=
90-
github.com/hashicorp/go-memdb v1.3.2 h1:RBKHOsnSszpU6vxq80LzC2BaQjuuvoyaQbkLTf7V7g8=
91-
github.com/hashicorp/go-memdb v1.3.2/go.mod h1:Mluclgwib3R93Hk5fxEfiRhB+6Dar64wWh71LpNSe3g=
9293
github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
9394
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
9495
github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU=
@@ -123,9 +124,10 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN
123124
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
124125
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
125126
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
127+
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
126128
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
127-
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
128-
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
129+
github.com/lib/pq v1.10.3 h1:v9QZf2Sn6AmjXtQeFpdoq/eaNtYP6IN+7lcrygsIAtg=
130+
github.com/lib/pq v1.10.3/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
129131
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
130132
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
131133
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=

‎_examples/godogs/go.mod

-8
This file was deleted.

‎_examples/godogs/go.sum

-329
This file was deleted.

‎godog.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ Godog was inspired by Behat and Cucumber the above description is taken from it'
3939
package godog
4040

4141
// Version of package - based on Semantic Versioning 2.0.0 http://semver.org/
42-
const Version = "v0.12.2"
42+
var Version = "v0.0.0-dev"

‎mod_version.go

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//go:build go1.12
2+
// +build go1.12
3+
4+
package godog
5+
6+
import (
7+
"runtime/debug"
8+
)
9+
10+
func init() {
11+
if info, available := debug.ReadBuildInfo(); available {
12+
if Version == "v0.0.0-dev" && info.Main.Version != "(devel)" {
13+
Version = info.Main.Version
14+
}
15+
}
16+
}

0 commit comments

Comments
 (0)
Please sign in to comment.