Skip to content

Commit

Permalink
Merge pull request #62 from Pix4D/update-release-procedure
Browse files Browse the repository at this point in the history
update release procedure and add macOS ARM binaries
  • Loading branch information
marco-m-pix4d authored Jan 31, 2024
2 parents dd91f10 + 1fc5654 commit abcd6a7
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 17 deletions.
31 changes: 20 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand All @@ -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

Expand Down
40 changes: 34 additions & 6 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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).
Expand All @@ -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
Expand All @@ -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.
Expand All @@ -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

0 comments on commit abcd6a7

Please sign in to comment.