From 4ee7fd4651119b3ad15eb8a79dab688b17fd467d Mon Sep 17 00:00:00 2001 From: Atsushi Watanabe Date: Tue, 28 Mar 2023 15:25:44 +0900 Subject: [PATCH] Write tool versions to release note (#26) --- .github/workflows/ci.yml | 22 +++++++++++++++++----- Dockerfile | 10 +++++++++- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 448c275..5051a19 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,13 +4,13 @@ on: push: branches: - master - tags: - - '*' + release: + types: [published] jobs: build-image: permissions: - contents: read + contents: write packages: write runs-on: ubuntu-latest steps: @@ -27,13 +27,25 @@ jobs: username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: Deploy devel - if: github.event_name == 'push' && github.ref == 'refs/heads/master' + if: github.event_name == 'push' run: | docker tag ghcr.io/seqsense/protoc-assets ghcr.io/seqsense/protoc-assets:devel docker push ghcr.io/seqsense/protoc-assets:devel - name: Deploy release - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') + if: github.event_name == 'release' run: | IMAGE_TAG=${GITHUB_REF#refs/tags/} docker tag ghcr.io/seqsense/protoc-assets ghcr.io/seqsense/protoc-assets:${IMAGE_TAG} docker push ghcr.io/seqsense/protoc-assets:${IMAGE_TAG} + - name: Write tool versions to release notes + if: github.event_name == 'release' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + IMAGE_TAG=${GITHUB_REF#refs/tags/} + echo '## Tool versions' > ./notes + docker run ghcr.io/seqsense/protoc-assets cat /versions | xargs -L1 echo "-" >> ./notes + gh release edit \ + --tag ${IMAGE_TAG} \ + --title ${IMAGE_TAG} \ + --notes-file ./notes diff --git a/Dockerfile b/Dockerfile index ed3daae..32dab10 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,8 @@ RUN --mount=type=cache,target=/etc/apk/cache,id=apk \ protoc \ py3-setuptools \ python3 \ - ruby + ruby \ + && echo "common $(protoc --version)" >> /versions ARG GLIBC_VERSION=2.33-r0 RUN --mount=type=cache,target=/etc/apk/cache,id=apk \ @@ -32,6 +33,8 @@ RUN --mount=type=cache,target=/etc/apk/cache,id=apk \ go \ && go install google.golang.org/protobuf/cmd/protoc-gen-go \ && go install google.golang.org/grpc/cmd/protoc-gen-go-grpc \ + && echo "go $(protoc-gen-go --version)" >> /versions \ + && echo "go $(protoc-gen-go-grpc --version)" >> /versions \ && apk del .builddeps COPY package.json package-lock.json / @@ -39,6 +42,7 @@ RUN --mount=type=cache,target=/etc/apk/cache,id=apk \ apk add --no-cache --virtual .builddeps \ npm \ && npm install \ + && echo "node grpc-tools $(npm view grpc-tools version)" >> /versions \ && apk del .builddeps COPY requirements.txt / @@ -46,6 +50,8 @@ RUN --mount=type=cache,target=/etc/apk/cache,id=apk \ apk add --no-cache --virtual .builddeps \ py3-pip \ && python3 -m pip install -r requirements.txt \ + && python3 -m pip show grpcio_tools \ + | sed -n 's/^Version: \(.*\)$/python grpcio_tools \1/p' >> /versions \ && apk del .builddeps COPY Gemfile Gemfile.lock / @@ -53,6 +59,8 @@ RUN --mount=type=cache,target=/etc/apk/cache,id=apk \ apk add --no-cache --virtual .builddeps \ ruby-bundler \ && bundle install \ + && bundle show grpc-tools \ + | sed -n 's|^/.*/grpc-tools-\(.*\)$|ruby grpc-tools \1|p'>> /versions \ && apk del .builddeps WORKDIR /defs