diff --git a/README.md b/README.md index 7949f9a..143b086 100644 --- a/README.md +++ b/README.md @@ -426,13 +426,17 @@ Thus, `terravalet remove` parses a plan file and creates all the `state rm` comm ## Setup -1. Install [github-release](https://github.com/github-release/github-release). -2. Install [gopass](https://github.com/gopasspw/gopass) or equivalent. -3. Configure a GitHub token: - * Go to [Personal Access tokens](https://github.com/settings/tokens) +1. Install [gopass](https://github.com/gopasspw/gopass) or equivalent. +2. Configure a fine-grained personal access token, scoped to the terravalet repository: + * Go to [Fine-grained personal access tokens](https://github.com/settings/tokens?type=beta) * Click on "Generate new token" - * Select only the `repo` scope -4. Store the token securely with a tool like `gopass`. The name `GITHUB_TOKEN` is expected by `github-release` + * Give it a name like "terravalet-releases" + * Select "Resource owner" -> Pix4D + * Select "Repository access" -> "Only select repositories" -> Terravalet + * Select "Repository permissions" + * "Contents" -> RW + * Generate the token +3. Store the token securely with a tool like `gopass`. The name `GITHUB_TOKEN` is expected by `github-release` ``` $ gopass insert gh/terravalet/GITHUB_TOKEN ``` @@ -441,13 +445,18 @@ Thus, `terravalet remove` parses a plan file and creates all the `state rm` comm 1. Update [CHANGELOG](CHANGELOG.md) 2. Update this README and/or additional documentation. -3. Commit and push. -4. Begin the release process with +3. Make and merge a PR. +4. Ensure your local master branch is up-to-date: ``` - $ env RELEASE_TAG=v0.1.0 gopass env gh/terravalet task release + $ git checkout master + $ git pull ``` -5. Finish the release process by following the instructions printed by `task` above. -6. To recover from a half-baked release, see the hints in the [Taskfile](Taskfile.yml). +5. Begin the release process with + ``` + $ RELEASE_TAG=v0.1.0 gopass env gh/terravalet task release + ``` +6. Finish the release process by following the instructions printed by `task` above. +7. To recover from a half-baked release, see the hints in the [Taskfile](Taskfile.yml). # History and credits diff --git a/Taskfile.yml b/Taskfile.yml index 647c91d..a435f96 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -20,6 +20,7 @@ tasks: - go install github.com/golangci/golangci-lint/cmd/golangci-lint@{{.GOLANGCI_VERSION}} - go install gotest.tools/gotestsum@{{.GOTESTSUM_VERSION}} - go install github.com/segmentio/golines@{{.GOLINES_VERSION}} + - go install github.com/github-release/github-release@latest lint: desc: Lint the code. @@ -51,7 +52,7 @@ tasks: LDFLAGS: -w -s -X main.fullVersion={{.FULL_VERSION}} # - # usage: env RELEASE_TAG=v0.1.0 gopass task release + # usage: RELEASE_TAG=v0.1.0 gopass env gh/terravalet task release # release: desc: Build a release and upload to GitHub as draft. You need to transition @@ -71,7 +72,8 @@ tasks: # To recover: delete local tag: git tag --delete tagname - git tag --annotate {{.RELEASE_TAG}} -m 'Release {{.RELEASE_TAG}}' - task: release-linux - - task: release-darwin + - task: release-darwin-amd + - task: release-darwin-arm # - task: system-test - task: test # We create the release as a draft (that is: not visible to the public). @@ -82,6 +84,16 @@ tasks: --draft --description "See the [CHANGELOG](https://github.com/$GITHUB_USER/$GITHUB_REPO/blob/{{.RELEASE_TAG}}/CHANGELOG.md)" + + # + # Since 2024, if we upload immeditately after having created the draft release, + # we get: + # + # error: could not find the release corresponding to tag vX.Y.Z + # + # to avoid this, we sleep a moment :-/ + - sleep 2 + # Upload the artifacts. - > github-release upload @@ -93,6 +105,11 @@ tasks: --tag {{.RELEASE_TAG}} --name terravalet-darwin-amd64.zip --file bin/darwin/terravalet-darwin-amd64.zip + - > + github-release upload + --tag {{.RELEASE_TAG}} + --name terravalet-darwin-arm64.zip + --file bin/darwin/terravalet-darwin-arm64.zip # Push the tag. - cmd: git push origin {{.RELEASE_TAG}} # Create a draft release. @@ -105,18 +122,29 @@ tasks: GITHUB_REPO: terravalet # GITHUB_TOKEN expected to be set securely via `gopass` or equivalent release-linux: - cmds: &release-cmds + cmds: - go build -o bin/$GOOS/terravalet -v -ldflags="{{.LDFLAGS}}" . - - zip bin/$GOOS/terravalet-$GOOS-$GOARCH.zip bin/$GOOS/terravalet + - cd bin/$GOOS && zip terravalet-$GOOS-$GOARCH.zip terravalet env: CGO_ENABLED: 0 GOOS: linux GOARCH: amd64 vars: *build-vars - release-darwin: - cmds: *release-cmds + release-darwin-amd: + cmds: + - go build -o bin/$GOOS/terravalet -v -ldflags="{{.LDFLAGS}}" . + - cd bin/$GOOS && zip terravalet-$GOOS-$GOARCH.zip terravalet env: CGO_ENABLED: 0 GOOS: darwin GOARCH: amd64 vars: *build-vars + release-darwin-arm: + cmds: + - go build -o bin/$GOOS/terravalet -v -ldflags="{{.LDFLAGS}}" . + - cd bin/$GOOS && zip terravalet-$GOOS-$GOARCH.zip terravalet + env: + CGO_ENABLED: 0 + GOOS: darwin + GOARCH: arm64 + vars: *build-vars