Skip to content

Commit 3b2b14f

Browse files
release: added GitHub release workflow (#44)
Signed-off-by: wangxiaoxuan273 <wangxiaoxuan119@gmail.com>
1 parent 8c6c680 commit 3b2b14f

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

.github/workflows/oras-release.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Release oras-project/registry container image
2+
3+
on:
4+
push:
5+
tags:
6+
- "v[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+"
7+
8+
jobs:
9+
publish:
10+
name: Build and publish container image
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
packages: write
15+
env:
16+
REGISTRY: ghcr.io
17+
REPOSITORY: ${{ format('{0}/registry', github.repository_owner) }}
18+
DOCKER_BUILDTAGS: "include_oss include_gcs"
19+
CGO_ENABLED: 1
20+
GO111MODULE: "auto"
21+
GOPATH: ${{ github.workspace }}
22+
GOOS: linux
23+
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) }}
24+
25+
steps:
26+
- name: Get git tag
27+
id: get_git_tag
28+
run: echo ::set-output name=git_tag::${GITHUB_REF#refs/tags/}
29+
30+
- name: Check out source code
31+
if: ${{ success() }}
32+
uses: actions/checkout@v2
33+
with:
34+
ref: ${{ steps.get_git_tag.outputs.git_tag }}
35+
36+
- name: Set docker image tag
37+
env:
38+
GIT_TAG: ${{ steps.get_git_tag.outputs.git_tag }}
39+
id: get_image_tag
40+
run: echo ::set-output name=docker_tag::${GIT_TAG}
41+
42+
- name: Login to GitHub Container Registry
43+
uses: docker/login-action@v1
44+
with:
45+
registry: ${{ env.REGISTRY }}
46+
username: ${{ github.actor }}
47+
password: ${{ secrets.GITHUB_TOKEN }}
48+
49+
- name: Build and push
50+
if: ${{ success() }}
51+
uses: docker/build-push-action@v2
52+
with:
53+
context: .
54+
file: ./Dockerfile
55+
platforms: linux/amd64
56+
push: true
57+
tags: |
58+
${{ env.REGISTRY }}/${{ env.REPOSITORY }}:${{ steps.get_image_tag.outputs.docker_tag }}
59+
${{ env.REGISTRY }}/${{ env.REPOSITORY }}:latest

0 commit comments

Comments
 (0)