Skip to content

Commit 6d6723c

Browse files
authored
fix: semantic release for Docker image
1 parent db22721 commit 6d6723c

File tree

2 files changed

+70
-58
lines changed

2 files changed

+70
-58
lines changed

.github/workflows/docker-publish.yml

Lines changed: 0 additions & 53 deletions
This file was deleted.

.github/workflows/go.yml

Lines changed: 70 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,83 @@ on:
66
- master
77
pull_request:
88

9+
env:
10+
REGISTRY: ghcr.io
11+
IMAGE_NAME: ${{ github.repository }}
12+
913
jobs:
10-
build-and-release:
14+
build_and_release:
1115
runs-on: ubuntu-latest
16+
17+
outputs:
18+
new_release_major_version: ${{ steps.semantic.outputs.new_release_major_version }}
19+
new_release_minor_version: ${{ steps.semantic.outputs.new_release_minor_version }}
20+
new_release_patch_version: ${{ steps.semantic.outputs.new_release_patch_version }}
21+
new_release_version: ${{ steps.semantic.outputs.new_release_version }}
22+
1223
steps:
1324
- uses: actions/checkout@v2
1425
- uses: actions/setup-go@v2
1526
with:
1627
go-version: 1.16
1728
- run: go build -v ./...
1829
- run: go test -v ./...
19-
- uses: go-semantic-release/action@v1
20-
if: ${{ github.ref == 'refs/heads/master' }}
30+
31+
- name: Semantic Release
32+
if: ${{ github.ref == '/refs/heads/master' }}
33+
id: semantic
34+
uses: cycjimmy/semantic-release-action@v2
35+
with:
36+
semantic_version: 16
37+
env:
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
40+
docker_release:
41+
runs-on: ubuntu-latest
42+
43+
if: ${{ github.ref == '/refs/heads/master' }}
44+
45+
needs:
46+
- build_and_release
47+
48+
permissions:
49+
contents: read
50+
packages: write
51+
52+
steps:
53+
- name: Checkout repository
54+
uses: actions/checkout@v2
55+
56+
- name: Log into registry ${{ env.REGISTRY }}
57+
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
58+
with:
59+
registry: ${{ env.REGISTRY }}
60+
username: ${{ github.actor }}
61+
password: ${{ secrets.GITHUB_TOKEN }}
62+
63+
- uses: docker/setup-qemu-action@master
64+
with:
65+
platforms: all
66+
67+
- name: Extract Docker metadata
68+
id: meta
69+
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
70+
with:
71+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
72+
tags: |
73+
type=raw,enable=true,prefix=v,value=${{ needs.build_and_release.new_release_version }}
74+
type=raw,enable=true,prefix=v,value=${{ needs.build_and_release.new_release_major_version }}
75+
type=raw,enable=true,prefix=v,value=${{ needs.build_and_release.new_release_major_version }}.${{ steps.semantic.outputs.new_release_major_version }}
76+
77+
- name: Set up Docker Buildx
78+
id: buildx
79+
uses: docker/setup-buildx-action@master
80+
81+
- name: Build and push Docker image
82+
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
2183
with:
22-
github-token: ${{ secrets.GITHUB_TOKEN }}
23-
allow-initial-development-versions: true
84+
builder: ${{ steps.buildx.outputs.name }}
85+
context: .
86+
tags: ${{ steps.meta.outputs.tags }}
87+
labels: ${{ steps.meta.outputs.labels }}
88+
platforms: linux/amd64,linux/arm64

0 commit comments

Comments
 (0)