Skip to content

Commit

Permalink
chore(cd): add cd workflow to slash branch (#8698)
Browse files Browse the repository at this point in the history
### Remarks

- Only need to push amd docker image
- Do not need Badger CLI tools for slash release
- We will never push latest tag from this branch, so omit such logic
entirely
  • Loading branch information
joshua-goldstein committed Mar 3, 2023
1 parent dc32d85 commit 65fff46
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 11 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/cd-dgraph.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: cd-dgraph
on:
workflow_dispatch:
inputs:
releasetag:
description: releasetag
required: true
type: string
jobs:
dgraph-build-amd64:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
ref: '${{ github.event.inputs.releasetag }}'
- name: Get Go Version
run: |
#!/bin/bash
GOVERSION=$({ [ -f .go-version ] && cat .go-version; })
echo "GOVERSION=$GOVERSION" >> $GITHUB_ENV
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GOVERSION }}
- name: Install protobuf-compiler
run: sudo apt-get install -y protobuf-compiler
- name: Check protobuf
run: |
cd ./protos
go mod tidy
make regenerate
git diff --exit-code -- .
- name: Set Dgraph Release Version
run: |
#!/bin/bash
GIT_TAG_NAME='${{ github.event.inputs.releasetag }}'
if [[ "$GIT_TAG_NAME" == "v"* ]];
then
echo "this is a release tag"
else
echo "this is NOT a release tag"
exit 1
fi
DGRAPH_RELEASE_VERSION='${{ github.event.inputs.releasetag }}'
echo "making a new release for dgraph "$DGRAPH_RELEASE_VERSION
echo "DGRAPH_RELEASE_VERSION=$DGRAPH_RELEASE_VERSION" >> $GITHUB_ENV
- name: Make Dgraph Linux Build
run: make dgraph DGRAPH_VERSION=${{ env.DGRAPH_RELEASE_VERSION }}
- name: Generate SHA for Dgraph Linux Build
run: cd dgraph && sha256sum dgraph | cut -c-64 > dgraph-checksum-linux-amd64.sha256
- name: Tar Archive for Dgraph Linux Build
run: cd dgraph && tar -zcvf dgraph-linux-amd64.tar.gz dgraph
- name: Upload Build Artifacts
uses: actions/upload-artifact@v3
with:
path: |
dgraph/dgraph-checksum-linux-amd64.sha256
dgraph/dgraph-linux-amd64.tar.gz
- name: Make Dgraph Docker Image
run: |
make docker-image DGRAPH_VERSION=${{ env.DGRAPH_RELEASE_VERSION }}
- name: Make Dgraph Standalone Docker Image with Version
run: |
make docker-image-standalone DGRAPH_VERSION=${{ env.DGRAPH_RELEASE_VERSION }}
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD_TOKEN }}
- name: Push Images to DockerHub
run: |
docker push dgraph/standalone:${{ env.DGRAPH_RELEASE_VERSION }}
docker push dgraph/dgraph:${{ env.DGRAPH_RELEASE_VERSION }}
2 changes: 1 addition & 1 deletion .go-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.18.5
1.18
22 changes: 18 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2022 Dgraph Labs, Inc. and Contributors
# Copyright 2023 Dgraph Labs, Inc. and Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -18,7 +18,7 @@ BUILD ?= $(shell git rev-parse --short HEAD)
BUILD_CODENAME = dgraph
BUILD_DATE ?= $(shell git log -1 --format=%ci)
BUILD_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
#BUILD_VERSION ?= $(shell git describe --always --tags)
BUILD_VERSION ?= $(shell git describe --always --tags)

GOPATH ?= $(shell go env GOPATH)

Expand All @@ -30,64 +30,77 @@ GOPATH ?= $(shell go env GOPATH)
######################
DGRAPH_VERSION ?= local

.PHONY: dgraph dgraph-coverage all oss version install install_oss oss_install uninstall test help image image-local local-image docker-image docker-image-standalone
.PHONY: all
all: dgraph

.PHONY: dgraph
dgraph:
$(MAKE) -w -C $@ all

.PHONY: dgraph-coverage
dgraph-coverage:
$(MAKE) -w -C dgraph test-coverage-binary

.PHONY: oss
oss:
$(MAKE) BUILD_TAGS=oss

.PHONY: version
version:
@echo Dgraph ${BUILD_VERSION}
@echo Dgraph: ${BUILD_VERSION}
@echo Build: ${BUILD}
@echo Codename: ${BUILD_CODENAME}
@echo Build date: ${BUILD_DATE}
@echo Branch: ${BUILD_BRANCH}
@echo Go version: $(shell go version)

.PHONY: install
install:
@echo "Installing Dgraph..."; \
$(MAKE) -C dgraph install; \

.PHONY: install_oss oss_install
install_oss oss_install:
$(MAKE) BUILD_TAGS=oss install

.PHONY: uninstall
uninstall:
@echo "Uninstalling Dgraph ..."; \
$(MAKE) -C dgraph uninstall; \

.PHONY: test
test: docker-image
@mv dgraph/dgraph ${GOPATH}/bin/dgraph
@$(MAKE) -C t test

.PHONY: image-local local-image
image-local local-image:
@GOOS=linux GOARCH=amd64 $(MAKE) dgraph
@mkdir -p linux
@mv ./dgraph/dgraph ./linux/dgraph
@docker build -f contrib/Dockerfile -t dgraph/dgraph:local .
@rm -r linux

.PHONY: docker-image
docker-image: dgraph
@mkdir -p linux
@cp ./dgraph/dgraph ./linux/dgraph
docker build -f contrib/Dockerfile -t dgraph/dgraph:$(DGRAPH_VERSION) .

.PHONY: docker-image-standalone
docker-image-standalone: dgraph docker-image
@mkdir -p linux
@cp ./dgraph/dgraph ./linux/dgraph
$(MAKE) -w -C contrib/standalone all DOCKER_TAG=$(DGRAPH_VERSION) DGRAPH_VERSION=$(DGRAPH_VERSION)

.PHONY: coverage-docker-image
coverage-docker-image: dgraph-coverage
@mkdir -p linux
@cp ./dgraph/dgraph ./linux/dgraph
docker build -f contrib/Dockerfile -t dgraph/dgraph:$(DGRAPH_VERSION) .

# build and run dependencies for ubuntu linux
.PHONY: linux-dependency
linux-dependency:
sudo apt-get update
sudo apt-get -y upgrade
Expand All @@ -98,6 +111,7 @@ linux-dependency:
sudo apt-get -y install build-essential
sudo apt-get -y install protobuf-compiler

.PHONY: help
help:
@echo
@echo Build commands:
Expand Down
11 changes: 6 additions & 5 deletions dgraph/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2022 Dgraph Labs, Inc. and Contributors
# Copyright 2023 Dgraph Labs, Inc. and Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -20,11 +20,12 @@ BUILD ?= $(shell git rev-parse --short HEAD)
BUILD_CODENAME ?= dgraph
BUILD_DATE ?= $(shell git log -1 --format=%ci)
BUILD_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
BUILD_VERSION ?= $(shell git describe --always --tags)

ifeq ($(DGRAPH_VERSION),)
BUILD_VERSION ?= local
else
BUILD_VERSION ?= $(DGRAPH_VERSION)
# check if DGRAPH_VERSION flag is set (used for release pipeline)
ifneq ($(DGRAPH_VERSION),)
# remove arch suffix from DGRAPH_VERSION for CD steps only
BUILD_VERSION := $(DGRAPH_VERSION)
endif

GOOS ?= $(shell go env GOOS)
Expand Down
6 changes: 5 additions & 1 deletion graphql/e2e/custom_logic/cmd/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@

FROM golang:1.14.2-alpine3.11
FROM golang:1.19-alpine3.17

COPY . .

RUN apk update && apk add git && apk add nodejs && apk add npm

# As of Go 1.16 modules are always on by default
# See https://go.dev/blog/go116-module-changes
RUN go env -w GO111MODULE=auto

RUN go get gopkg.in/yaml.v2

RUN go get github.com/graph-gophers/graphql-go
Expand Down

0 comments on commit 65fff46

Please sign in to comment.