Skip to content

Commit

Permalink
Build packages on CI (FerretDB#938)
Browse files Browse the repository at this point in the history
Closes FerretDB#902.
  • Loading branch information
AlekSi authored Jul 25, 2022
1 parent 77e4370 commit fafa9aa
Show file tree
Hide file tree
Showing 13 changed files with 149 additions and 39 deletions.
19 changes: 10 additions & 9 deletions .github/RELEASE_CHECKLIST.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@
6. Make a signed tag `vX.Y.Z` with the relevant section of the changelog using `--cleanup=verbatim`.
7. Push it!
8. Make [release](https://github.com/FerretDB/FerretDB/releases).
9. Refresh
* `env GOPROXY=https://proxy.golang.org go install -v github.com/FerretDB/FerretDB/cmd/ferretdb@<tag>`
* `env GOPROXY=https://proxy.golang.org go install -v github.com/FerretDB/FerretDB/ferretdb@<tag>`
(expected error message is `package github.com/FerretDB/FerretDB/ferretdb is not a main package`)
* <https://pkg.go.dev/github.com/FerretDB/FerretDB>
10. `task docker-local`
11. `task docker-push` with four tags (`X.Y.Z` without leading `v` and `latest` for both ghcr.io and Docker Hub):
9. Upload .deb and .rpm packages from the CI build for the tag.
10. Refresh
* `env GOPROXY=https://proxy.golang.org go install -v github.com/FerretDB/FerretDB/cmd/ferretdb@<tag>`
* `env GOPROXY=https://proxy.golang.org go install -v github.com/FerretDB/FerretDB/ferretdb@<tag>`
(expected error message is `package github.com/FerretDB/FerretDB/ferretdb is not a main package`)
* <https://pkg.go.dev/github.com/FerretDB/FerretDB>
11. `task docker-local`
12. `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_IMAGE=ferretdb/ferretdb:latest`
* `task docker-push DOCKER_IMAGE=ferretdb/ferretdb:<tag>`
* `task docker-push DOCKER_IMAGE=ghcr.io/ferretdb/ferretdb:latest`
* `task docker-push DOCKER_IMAGE=ghcr.io/ferretdb/ferretdb:<tag>`
12. Close milestone in issues.
13. Announce it!
13. Close milestone in issues.
14. Announce it!
65 changes: 65 additions & 0 deletions .github/workflows/packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
name: Packages
on:
pull_request:
types:
- unlabeled # if GitHub Actions stuck, add and remove "no ci" label to force rebuild
- opened
- reopened
- synchronize
push:
branches:
- main
tags:
- "*"
schedule:
- cron: "12 2 * * *"

env:
GOPATH: /home/runner/go
GOCACHE: /home/runner/go/cache
GOLANGCI_LINT_CACHE: /home/runner/go/cache/lint
GOMODCACHE: /home/runner/go/mod
GOPROXY: https://proxy.golang.org

jobs:
build:
name: Build
runs-on: ubuntu-20.04

if: github.event_name != 'pull_request' || !contains(github.event.pull_request.labels.*.name, 'no ci')

steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Go
uses: FerretDB/github-actions/setup-go@main
with:
cache-key: packages

- name: Install Task
run: go generate -x
working-directory: tools

- name: Run init
run: bin/task init

- name: Build packages
run: bin/task packages

- name: Upload ferretdb.deb
uses: actions/upload-artifact@v3
with:
name: ferretdb.deb
path: build/deb/ferretdb.deb
if-no-files-found: error

- name: Upload ferretdb.rpm
uses: actions/upload-artifact@v3
with:
name: ferretdb.rpm
path: build/rpm/ferretdb.rpm
if-no-files-found: error
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
# Please use global .gitignore file for .vscode/, .idea/, etc.
# See https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files#configuring-ignored-files-for-all-repositories-on-your-computer

# out tools
bin/

# temporary `go mod vendor` directory
vendor/

# task cache
.task/

# packages
*.deb
*.rpm

# test coverage results, generated files like commit.txt, etc.
*.txt

Expand All @@ -13,4 +23,5 @@ vendor/
# for now
testdata/fuzz/

# for local Docker Compse changes; see https://docs.docker.com/compose/extends/#multiple-compose-files
docker-compose.override.yml
14 changes: 0 additions & 14 deletions .nfpm.yml

This file was deleted.

5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ and [contributing guidelines](CONTRIBUTING.md).
### Known differences

1. FerretDB uses the same protocol error names and codes, but the exact error messages may be different in some cases.

2. FerretDB does not support NUL (`\0`) characters in strings.

3. Database and collection names restrictions:

* name cannot start with the reserved prefix `_ferretdb_`.
Expand Down Expand Up @@ -103,6 +101,9 @@ docker run --rm -it --network=ferretdb --entrypoint=mongosh mongo:5 mongodb://fe

<!-- markdownlint-enable MD029 -->

You can also install with FerretDB with the `.deb` and `.rpm` packages
provided for each [release](https://github.com/FerretDB/FerretDB/releases).

## Community

* Website and blog: [https://ferretdb.io](https://ferretdb.io/).
Expand Down
38 changes: 25 additions & 13 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ tasks:
- task: docs

gen-version:
run: once
cmds:
- go generate -x ./internal/util/version

Expand Down Expand Up @@ -186,6 +187,7 @@ tasks:

build-testcover:
desc: "Build bin/ferretdb-testcover"
run: once
deps: [gen-version]
cmds:
- go test -c -o=bin/ferretdb-testcover{{exeExt}} -trimpath -tags=ferretdb_testcover,ferretdb_tigris {{if ne OS "windows"}}-race{{end}} -coverpkg=./... ./cmd/ferretdb
Expand Down Expand Up @@ -293,25 +295,35 @@ tasks:
COMMIT:
sh: cat internal/util/version/gen/commit.txt

nfpm_deb:
packages:
cmds:
- task: packages-deb
- task: packages-rpm

packages-deb:
deps: [build-testcover]
dir: build/deb
dir: build
cmds:
- ../../bin/nfpm pkg --config ../../.nfpm.yml --packager deb --target ferretdb_${VERSION}.deb
- ../bin/nfpm{{exeExt}} package --packager=deb --target=deb/ferretdb.deb
- >
docker-compose run --rm debian /bin/sh -c
'dpkg -i /deb/ferretdb.deb && ferretdb -version'
env:
VERSION:
sh: cat ../../internal/util/version/gen/version.txt
sh: cat ../internal/util/version/gen/version.txt
GOARCH:
sh: go env GOARCH

nfpm_rpm:
packages-rpm:
deps: [build-testcover]
dir: build/rpm
dir: build
cmds:
- ../../bin/nfpm pkg --config ../../.nfpm.yml --packager rpm --target ferretdb_${VERSION}.rpm
- ../bin/nfpm{{exeExt}} package --packager=rpm --target=rpm/ferretdb.rpm
- >
docker-compose run --rm centos /bin/sh -c
'rpm -i /rpm/ferretdb.rpm && ferretdb -version'
env:
VERSION:
sh: cat ../../internal/util/version/gen/version.txt

packager:
cmds:
- task: nfpm_deb
- task: nfpm_rpm
sh: cat ../internal/util/version/gen/version.txt
GOARCH:
sh: go env GOARCH
Empty file added build/deb/.gitkeep
Empty file.
1 change: 1 addition & 0 deletions build/deps/centos7.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM centos:7.9.2009
1 change: 1 addition & 0 deletions build/deps/debian11.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM debian:11.4
File renamed without changes.
16 changes: 16 additions & 0 deletions build/nfpm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
name: ferretdb
arch: ${GOARCH}
platform: linux
version: ${VERSION}
section: database
maintainer: FerretDB packages <packages@ferretdb.com>
description: >
FerretDB (previously MangoDB) was founded to become the de-facto open-source substitute to MongoDB.
FerretDB is an open-source proxy, converting the MongoDB 5.0+ wire protocol queries to SQL -
using PostgreSQL as a database engine.
homepage: https://ferretdb.io
license: Apache License 2.0
contents:
- src: ../bin/ferretdb-testcover
dst: /usr/bin/ferretdb
Empty file added build/rpm/.gitkeep
Empty file.
18 changes: 17 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ services:
mongodb:
build:
context: ./build/deps
dockerfile: mongo.Dockerfile
dockerfile: ${MONGO_DOCKERFILE:-mongo5}.Dockerfile
container_name: ferretdb_mongodb
command: --enableFreeMonitoring off
ports:
Expand All @@ -49,3 +49,19 @@ services:
container_name: ferretdb_markdownlint
volumes:
- .:/workdir

debian:
build:
context: ./build/deps
dockerfile: debian11.Dockerfile
container_name: ferretdb_debian
volumes:
- ./build/deb:/deb

centos:
build:
context: ./build/deps
dockerfile: centos7.Dockerfile
container_name: ferretdb_centos
volumes:
- ./build/rpm:/rpm

0 comments on commit fafa9aa

Please sign in to comment.