Skip to content

Commit

Permalink
switch to Github Actions CI (#249)
Browse files Browse the repository at this point in the history
* switch to github actions for ci in PRs

* add test to pr ci, remove azure pipeline

* fix env var

* fix env var

* fix env in ci

* fix env

* fix env

* fix env

* add test step back

* fix test permissions

* new line

* update readme

* fix missing var

* adding release configuration

* update readme, adjust manual execution of build

* fix comment, new line

* update readme with better release instructions
  • Loading branch information
ido-namely authored Aug 5, 2021
1 parent 89631f0 commit 4126d22
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 44 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/pr_master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

# build the image on PRs and master

name: PR

on:
pull_request:
push:
branches:
- master
paths-ignore:
- 'README.md'

jobs:
build:
runs-on: ubuntu-latest
env:
COMMIT_HASH: ${{ github.sha }}
steps:
- uses: actions/checkout@v2
with:
submodules: true

- uses: nelonoel/[email protected]

- name: Docker Login
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USER }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
run: docker login --username "$DOCKERHUB_USERNAME" --password "$DOCKERHUB_TOKEN"

- name: Build
env:
BUILD_VERSION: ${{ env.COMMIT_HASH }}
run: make build
47 changes: 47 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Build, Tag & Push a new release to dockerhub off of a tag

name: Release

on:
push:
tags:
- 'v*'


jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true

- uses: nelonoel/[email protected]

- name: Docker Login
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USER }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
run: docker login --username "$DOCKERHUB_USERNAME" --password "$DOCKERHUB_TOKEN"

- name: Create Version
id: version
run: |
# TODO: find a better way to version from tags
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# set to output var
echo ::set-output name=VERSION::${VERSION}
- name: Build and Tag
env:
BUILD_VERSION: ${{ steps.version.outputs.VERSION }}
run: make tag-latest

- name: Push
if: success()
env:
BUILD_VERSION: ${{ steps.version.outputs.VERSION }}
run: make push-latest
40 changes: 23 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# gRPC/Protocol Buffer Compiler Containers

[![Build Status](https://dev.azure.com/namely/protoc-all/_apis/build/status/namely.docker-protoc?branchName=master)](https://dev.azure.com/namely/protoc-all/_build/latest?definitionId=1&branchName=master)
[![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/namely/docker-protoc/Build/master?style=flat-square)](https://github.com/namely/docker-protoc/actions?query=workflow%3ABuild)

This repository contains support for various Docker images that wrap `protoc`,
`prototool`, `grpc_cli` commands with [gRPC](https://github.com/grpc/grpc) support
Expand Down Expand Up @@ -35,8 +35,8 @@ If you're having trouble, see [Docker troubleshooting](#docker-troubleshooting)
## Tag Conventions

For `protoc`, `grpc_cli` and `prototool` a pattern of `<GRPC\_VERSION>_<CONTAINER\_VERSION>` is used for all images.
Example is `namely/protoc-all:1.15_0` for gRPC version `1.15`. The `latest` tag will always point to the most recent version.
For `protoc`, `grpc_cli` and `prototool` a pattern of `<GRPC_VERSION>_<CONTAINER_VERSION>` is used for all images (or `<GRPC_VERSION>_<CONTAINER_VERSION>-rc.<PRERELEASE_NUMBER>`) for pre-releases).
Example is `namely/protoc-all:1.15_0` for gRPC version `1.15` (or `namely/protoc-all:1.15_0-rc.1` for a pre-release). The `latest` tag will always point to the most recent version.

## Usage

Expand Down Expand Up @@ -243,11 +243,15 @@ Thank you for considering a contribution to namely/docker-protoc!

If you'd like to make an enhancement, or add a container for another language compiler, you will
need to run one of the build scripts in this repo. You will also need to be running Mac, Linux,
or WSL 2, and have Docker installed. From the repository root, run this command to build all the
or WSL 2, and have Docker installed.

### Build

From the repository root, run this command to build all the
known containers:

```sh
$ make build
make build
```

Note the version tag in Docker's console output - this image tag is required to run the tests using
Expand All @@ -258,31 +262,33 @@ make command. For example, this would build the containers using Node.js 15 and
interesting variables in [variables.sh](./variables.sh) and [entrypoint.sh](./all/entrypoint.sh).

```sh
$ NODE_VERSION=15 GRPC_VERSION=1.35 make build
NODE_VERSION=15 GRPC_VERSION=1.35 make build
```

### Test

To run the tests, identify your image tag from the build step and run `make test` as below:

```sh
$ CONTAINER=namely/protoc-all:VVV make test
CONTAINER=namely/protoc-all:VVV make test
```

(`VVV` is your version from the tag in the console output when running `make build`). Running this will
demonstrate that your new image can successfully build containers for each language.

Open a PR and ping one of the Namely employees who have worked on this repo recently. We will take
a look as soon as we can. Thank you!!
### Release

Namely employees can merge PRs and the latest version will be pushed up via CI. It is also possible to
do this manually by running this:
#### Contributors

```sh
$ make push
```
Open a PR and ping one of the Namely employees who have worked on this repo recently. We will take a look as soon as we can.
Thank you!!

#### Namely Employees

This will build and push the containers to the Namely registry located on
[DockerHub](https://hub.docker.com/u/namely/). You must be authorized to push to
this repo.
Namely employees can merge PRs and cut a release/pre-release by drafting a new Github release and publishing them.
The release name should follow the same tag conventions described in [this doc](#tag-conventions) and the gRPC version in the release name
must match the `GRPC_VERSION` configured in [variables.sh](./variables.sh).
Once a new Github release is published, new images will be published to [DockerHub](https://hub.docker.com/u/namely/) via CI.

## Docker Troubleshooting

Expand Down
24 changes: 0 additions & 24 deletions azure-pipelines.yml

This file was deleted.

2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
source ./variables.sh

for build in ${BUILDS[@]}; do
tag=${CONTAINER}/${build}:${GRPC_VERSION}_${BUILD_VERSION}
tag=${CONTAINER}/${build}:${BUILD_VERSION}
echo "building ${build} container with tag ${tag}"
docker build -t ${tag} \
-f Dockerfile \
Expand Down
2 changes: 1 addition & 1 deletion push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
source ./variables.sh

for build in ${BUILDS[@]}; do
tag=${CONTAINER}/${build}:${GRPC_VERSION}_${BUILD_VERSION}
tag=${CONTAINER}/${build}:${BUILD_VERSION}
echo "pushing ${tag}"
docker push ${tag}

Expand Down
2 changes: 1 addition & 1 deletion variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
BUILDS=("protoc-all" "protoc" "prototool" "grpc-cli" "gen-grpc-gateway")
DOCKER_REPO=${DOCKER_REPO}
NAMESPACE=${NAMESPACE:-namely}
BUILD_VERSION=${BUILD_VERSION:-1}
CONTAINER=${DOCKER_REPO}${NAMESPACE}
LATEST=${1:false}

Expand All @@ -18,3 +17,4 @@ NODE_VERSION=${NODE_VERSION:-14}
NODE_GRPC_TOOLS_NODE_PROTOC_TS_VERSION=${NODE_GRPC_TOOLS_NODE_PROTOC_TS_VERSION:-5.1.3}
NODE_GRPC_TOOLS_VERSION=${NODE_GRPC_TOOLS_VERSION:-1.11.1}
NODE_PROTOC_GET_GRPC_WEB_VERSION=${NODE_PROTOC_GET_GRPC_WEB_VERSION:-1.2.1}
BUILD_VERSION="${BUILD_VERSION:-${GRPC_VERSION}_0}"

0 comments on commit 4126d22

Please sign in to comment.