From 6c9de8df73bdede277b9dfe98cc781bb0f85fb1c Mon Sep 17 00:00:00 2001 From: yue9944882 <291271447@qq.com> Date: Wed, 15 Dec 2021 14:04:32 +0800 Subject: [PATCH] gh-action: releases-job Signed-off-by: yue9944882 <291271447@qq.com> --- .github/workflows/go-postsubmit.yml | 3 +- .github/workflows/go-release.yml | 50 +++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/go-release.yml diff --git a/.github/workflows/go-postsubmit.yml b/.github/workflows/go-postsubmit.yml index 782f9526..6efe77d9 100644 --- a/.github/workflows/go-postsubmit.yml +++ b/.github/workflows/go-postsubmit.yml @@ -35,4 +35,5 @@ jobs: - name: push run: | echo ${{ secrets.DOCKER_PASSWORD }} | docker login --username ${{ secrets.DOCKER_USER }} --password-stdin - docker push oamdev/cluster-gateway:latest \ No newline at end of file + docker push oamdev/cluster-gateway:latest + docker push oamdev/cluster-gateway-addon-manager:latest diff --git a/.github/workflows/go-release.yml b/.github/workflows/go-release.yml new file mode 100644 index 00000000..0e2b508e --- /dev/null +++ b/.github/workflows/go-release.yml @@ -0,0 +1,50 @@ +name: GoRelease + +on: + push: + tags: + - 'v*.*.*' +env: + # Common versions + GO_VERSION: '1.16' + GO_REQUIRED_MIN_VERSION: '' + GOPATH: '/home/runner/work/oamdev/cluster-gateway/go' + GITHUB_REF: ${{ github.ref }} + +defaults: + run: + working-directory: go/src/oamdev/cluster-gateway + +jobs: + release: + name: release + runs-on: ubuntu-latest + steps: + - name: checkout code + uses: actions/checkout@v2 + with: + fetch-depth: 1 + path: go/src/oamdev/cluster-gateway + - name: install Go + uses: actions/setup-go@v2 + with: + go-version: ${{ env.GO_VERSION }} + - name: images + run: make image + - name: get release version + run: | + echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + - name: get major release version + run: | + echo "MAJOR_RELEASE_VERSION=${RELEASE_VERSION%.*}" >> $GITHUB_ENV + - name: push image + run: | + echo ${{ secrets.DOCKER_PASSWORD }} | docker login --username ${{ secrets.DOCKER_USER }} --password-stdin + docker tag oamdev/cluster-gateway:latest oamdev/cluster-gateway:$RELEASE_VERSION + docker tag oamdev/cluster-gateway-addon-manager:latest oamdev/cluster-gateway-addon-manager:$RELEASE_VERSION + docker push oamdev/cluster-gateway:$RELEASE_VERSION + docker push oamdev/cluster-gateway-addon-manager:$RELEASE_VERSION + - name: publish release + uses: softprops/action-gh-release@v0.1.5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file