Skip to content

Commit

Permalink
GitHub Action Workflows - Tagged Releases (#9)
Browse files Browse the repository at this point in the history
- update Dockerfile
- add release.yaml workflow
  • Loading branch information
alehechka authored Jul 31, 2022
1 parent 0c9b6ff commit 2e73bd0
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 7 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Release

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'

permissions:
contents: read

jobs:
goreleaser:
runs-on: ubuntu-latest

permissions:
contents: write

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

- uses: actions/setup-go@v3
with:
go-version: '1.18'

- uses: goreleaser/goreleaser-action@v3
with:
args: release --rm-dist --skip-docker
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

push_bsr_plugins:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- uses: docker/setup-buildx-action@v2

- uses: docker/login-action@v2
with:
registry: plugins.buf.build
username: alehechka
password: ${{ secrets.BUF_BUILD_TOKEN }}

- name: Set protobuf-version
run: echo ::set-output name=version::$(go list -m -f '{{.Version}}' google.golang.org/protobuf)
id: protobuf-version

- name: Set grpc-version
run: echo ::set-output name=version::$(go list -m -f '{{.Version}}' google.golang.org/grpc)
id: grpc-version

- uses: docker/build-push-action@v3
with:
push: true
tags: plugins.buf.build/alehechka/grpc-graphql-gateway:${{ github.ref_name }}-1
platforms: linux/amd64
build-args: |
RELEASE_VERSION=${{ github.ref_name }}
GO_PROTOBUF_RELEASE_VERSION=${{ steps.protobuf-version.outputs.version }}
GO_GRPC_RELEASE_VERSION=${{ steps.grpc-version.outputs.version }}
18 changes: 11 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM golang:1.18-alpine as go-builder

ENV GOOS=linux GOARCH=amd64 CGO_ENABLED=0

ARG VERSION="latest"
ARG RELEASE_VERSION

WORKDIR /app

Expand All @@ -12,17 +12,21 @@ RUN go mod download

COPY . .

RUN cd protoc-gen-graphql ; go build -ldflags "-X main.version=${VERSION}"
RUN cd protoc-gen-graphql ; go build -ldflags "-X main.version=${RELEASE_VERSION}"

FROM scratch

ARG VERSION="latest"
ARG RELEASE_VERSION
ARG GO_PROTOBUF_RELEASE_VERSION
ARG GO_GRPC_RELEASE_VERSION

# Runtime dependencies
LABEL "build.buf.plugins.runtime_library_versions.0.name"="google.golang.org/protobuf"
LABEL "build.buf.plugins.runtime_library_versions.0.version"="v1.28.0"
LABEL "build.buf.plugins.runtime_library_versions.1.name"="github.com/alehechka/grpc-graphql-gateway"
LABEL "build.buf.plugins.runtime_library_versions.1.version"="${VERSION}"
LABEL "build.buf.plugins.runtime_library_versions.0.name"="github.com/alehechka/grpc-graphql-gateway"
LABEL "build.buf.plugins.runtime_library_versions.0.version"="${RELEASE_VERSION}"
LABEL "build.buf.plugins.runtime_library_versions.1.name"="google.golang.org/protobuf"
LABEL "build.buf.plugins.runtime_library_versions.1.version"="${GO_PROTOBUF_RELEASE_VERSION}"
LABEL "build.buf.plugins.runtime_library_versions.2.name"="google.golang.org/grpc"
LABEL "build.buf.plugins.runtime_library_versions.2.version"="${GO_GRPC_RELEASE_VERSION}"

COPY --from=go-builder /app/protoc-gen-graphql/protoc-gen-graphql /

Expand Down

0 comments on commit 2e73bd0

Please sign in to comment.