From 3b2b14f640ca2be8dc2b429997a2791d8087abae Mon Sep 17 00:00:00 2001 From: Xiaoxuan Wang <103478229+wangxiaoxuan273@users.noreply.github.com> Date: Fri, 2 Dec 2022 17:20:41 +0800 Subject: [PATCH] release: added GitHub release workflow (#44) Signed-off-by: wangxiaoxuan273 --- .github/workflows/oras-release.yml | 59 ++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .github/workflows/oras-release.yml diff --git a/.github/workflows/oras-release.yml b/.github/workflows/oras-release.yml new file mode 100644 index 00000000000..a2ab92d8d44 --- /dev/null +++ b/.github/workflows/oras-release.yml @@ -0,0 +1,59 @@ +name: Release oras-project/registry container image + +on: + push: + tags: + - "v[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+" + +jobs: + publish: + name: Build and publish container image + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + env: + REGISTRY: ghcr.io + REPOSITORY: ${{ format('{0}/registry', github.repository_owner) }} + DOCKER_BUILDTAGS: "include_oss include_gcs" + CGO_ENABLED: 1 + GO111MODULE: "auto" + GOPATH: ${{ github.workspace }} + GOOS: linux + COMMIT_RANGE: ${{ github.event_name == 'pull_request' && format('{0}..{1}',github.event.pull_request.base.sha, github.event.pull_request.head.sha) || format('{0}..{1}', github.event.before, github.event.after) }} + + steps: + - name: Get git tag + id: get_git_tag + run: echo ::set-output name=git_tag::${GITHUB_REF#refs/tags/} + + - name: Check out source code + if: ${{ success() }} + uses: actions/checkout@v2 + with: + ref: ${{ steps.get_git_tag.outputs.git_tag }} + + - name: Set docker image tag + env: + GIT_TAG: ${{ steps.get_git_tag.outputs.git_tag }} + id: get_image_tag + run: echo ::set-output name=docker_tag::${GIT_TAG} + + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + if: ${{ success() }} + uses: docker/build-push-action@v2 + with: + context: . + file: ./Dockerfile + platforms: linux/amd64 + push: true + tags: | + ${{ env.REGISTRY }}/${{ env.REPOSITORY }}:${{ steps.get_image_tag.outputs.docker_tag }} + ${{ env.REGISTRY }}/${{ env.REPOSITORY }}:latest \ No newline at end of file