From 2e73bd07b19e258a55c0366afb53254553fed950 Mon Sep 17 00:00:00 2001 From: Adam Lehechka <42357034+alehechka@users.noreply.github.com> Date: Sat, 30 Jul 2022 22:28:56 -0500 Subject: [PATCH] GitHub Action Workflows - Tagged Releases (#9) - update Dockerfile - add release.yaml workflow --- .github/workflows/release.yaml | 63 ++++++++++++++++++++++++++++++++++ Dockerfile | 18 ++++++---- 2 files changed, 74 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..47875ed --- /dev/null +++ b/.github/workflows/release.yaml @@ -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 }} diff --git a/Dockerfile b/Dockerfile index 64b9611..c7fda74 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 @@ -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 /