Skip to content

Commit

Permalink
Simplify release procedure (#1657)
Browse files Browse the repository at this point in the history
Build and push all Docker images at once.
  • Loading branch information
AlekSi committed Dec 20, 2022
1 parent 2bf1e63 commit b4f603a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 32 deletions.
14 changes: 5 additions & 9 deletions .github/RELEASE_CHECKLIST.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,17 @@
## Git tag

1. Make a signed tag `vX.Y.Z` with the relevant section of the changelog using `--cleanup=verbatim`.
2. Push it!
3. Check `task gen; cat internal/util/version/gen/version.txt; git status` output.
2. Check `task gen-version; git status` output.
3. Push it!
4. Refresh
* `env GOPROXY=https://proxy.golang.org go mod download -x github.com/FerretDB/FerretDB@<tag>`
* `https://pkg.go.dev/github.com/FerretDB/FerretDB@<tag>` from <https://pkg.go.dev/github.com/FerretDB/FerretDB?tab=versions>

## Docker

1. `task docker-cache`
2. `task docker-push` with four tags (`X.Y.Z` without leading `v` and `latest` for both ghcr.io and Docker Hub):
* `task docker-push DOCKER_IMAGES=ferretdb/ferretdb:latest`
* `task docker-push DOCKER_IMAGES=ferretdb/ferretdb:<tag>`
* `task docker-push DOCKER_IMAGES=ghcr.io/ferretdb/ferretdb:latest`
* `task docker-push DOCKER_IMAGES=ghcr.io/ferretdb/ferretdb:<tag>`
* Check <https://hub.docker.com/r/ferretdb/ferretdb/tags>, <https://github.com/FerretDB/FerretDB/pkgs/container/ferretdb>.
1. Check `task gen-version; git status` output.
2. `task docker-push-release`.
3. Check <https://hub.docker.com/r/ferretdb/ferretdb/tags>, <https://github.com/FerretDB/FerretDB/pkgs/container/ferretdb>.

## Release

Expand Down
26 changes: 11 additions & 15 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ tasks:
COMMIT:
sh: cat internal/util/version/gen/commit.txt

docker-cache:
docker-push:
deps: [gen-version]
cmds:
- >
Expand All @@ -354,30 +354,26 @@ tasks:
--build-arg COMMIT={{.COMMIT}}
--build-arg RACEFLAG={{.RACEFLAG}}
--platform=linux/arm/v7,linux/arm64,linux/amd64
.
{{range splitList "," .DOCKER_IMAGES}}--tag={{trim .}} {{end -}}
--push .
vars:
VERSION:
sh: cat internal/util/version/gen/version.txt
COMMIT:
sh: cat internal/util/version/gen/commit.txt

docker-push:
deps: [gen-version]
docker-push-release:
cmds:
- test {{.DOCKER_IMAGES}}
- >
docker buildx build --builder=ferretdb
--build-arg VERSION={{.VERSION}}
--build-arg COMMIT={{.COMMIT}}
--build-arg RACEFLAG={{.RACEFLAG}}
--platform=linux/arm/v7,linux/arm64,linux/amd64
--tag={{.DOCKER_IMAGES}}
--push .
- task: docker-push
vars:
DOCKER_IMAGES: >
ferretdb/ferretdb:latest,
ferretdb/ferretdb:{{trimPrefix "v" .VERSION}},
ghcr.io/ferretdb/ferretdb:latest,
ghcr.io/ferretdb/ferretdb:{{trimPrefix "v" .VERSION}}
vars:
VERSION:
sh: cat internal/util/version/gen/version.txt
COMMIT:
sh: cat internal/util/version/gen/commit.txt

packages:
cmds:
Expand Down
21 changes: 13 additions & 8 deletions internal/util/version/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package main

import (
"fmt"
"log"
"os"
"os/exec"
"path/filepath"
Expand All @@ -34,41 +35,45 @@ func runGit(args ...string) []byte {

b, err := cmd.Output()
if err != nil {
err = fmt.Errorf("Failed to run %q: %s", strings.Join(cmd.Args, " "), err)
panic(err)
panic(fmt.Sprintf("Failed to run %q: %s", strings.Join(cmd.Args, " "), err))
}

return b
}

// saveFile stores the given bytes in the given file with logging.
func saveFile(b []byte, filename string) {
log.Printf("%s: %s", filename, b)
must.NoError(os.WriteFile(filepath.Join("gen", filename), b, 0o666))
}

func main() {
log.SetFlags(0)

var wg sync.WaitGroup

// git describe --tags --dirty > gen/version.txt
wg.Add(1)
go func() {
defer wg.Done()

b := runGit("describe", "--tags", "--dirty")
must.NoError(os.WriteFile(filepath.Join("gen", "version.txt"), b, 0o666))
saveFile(runGit("describe", "--tags", "--dirty"), "version.txt")
}()

// git rev-parse HEAD > gen/commit.txt
wg.Add(1)
go func() {
defer wg.Done()

b := runGit("rev-parse", "HEAD")
must.NoError(os.WriteFile(filepath.Join("gen", "commit.txt"), b, 0o666))
saveFile(runGit("rev-parse", "HEAD"), "commit.txt")
}()

// git branch --show-current > gen/branch.txt
wg.Add(1)
go func() {
defer wg.Done()

b := runGit("branch", "--show-current")
must.NoError(os.WriteFile(filepath.Join("gen", "branch.txt"), b, 0o666))
saveFile(runGit("branch", "--show-current"), "branch.txt")
}()

wg.Wait()
Expand Down

1 comment on commit b4f603a

@vercel
Copy link

@vercel vercel bot commented on b4f603a Dec 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

ferret-db – ./

ferret-db-git-main-ferretdb.vercel.app
ferret-db-ferretdb.vercel.app
ferret-db.vercel.app

Please sign in to comment.