Skip to content

Commit e451dea

Browse files
committed
Docker image build and release improvements
1 parent 3ec028a commit e451dea

File tree

2 files changed

+53
-25
lines changed

2 files changed

+53
-25
lines changed

.github/workflows/release.yml

Lines changed: 53 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,64 @@ on:
77

88
jobs:
99
release:
10-
name: Docker
1110
runs-on: ubuntu-latest
1211
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v2
14+
with:
15+
fetch-depth: 0
16+
17+
- name: Fetch tags
18+
run: git fetch --force --tags
19+
1320
- name: Setup QEMU
14-
uses: docker/setup-qemu-action@v1
21+
uses: docker/setup-qemu-action@v2
1522

1623
- name: Setup Docker Buildx
17-
uses: docker/setup-buildx-action@v1
24+
uses: docker/setup-buildx-action@v2
25+
id: buildx
1826

19-
- name: Check out code
20-
uses: actions/checkout@v2
27+
- name: Login to container Registry
28+
uses: docker/login-action@v2
29+
with:
30+
username: ${{ github.repository_owner }}
31+
password: ${{ secrets.GITHUB_TOKEN }}
32+
registry: ghcr.io
33+
34+
- name: Prepare
35+
id: prep
36+
run: |
37+
VERSION=sha-${GITHUB_SHA::8}
38+
if [[ $GITHUB_REF == refs/tags/* ]]; then
39+
VERSION=${GITHUB_REF/refs\/tags\//}
40+
fi
41+
echo ::set-output name=BUILD_DATE::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
42+
echo ::set-output name=VERSION::${VERSION}
43+
44+
- name: Publish multi-arch Docker image
45+
uses: docker/build-push-action@v4
46+
with:
47+
push: true
48+
builder: ${{ steps.buildx.outputs.name }}
49+
context: .
50+
file: ./Dockerfile
51+
platforms: linux/arm64,linux/amd64
52+
tags: |
53+
ghcr.io/${{ github.repository_owner }}/bankroach:${{ steps.prep.outputs.VERSION }}
54+
ghcr.io/${{ github.repository_owner }}/bankroach:latest
55+
labels: |
56+
org.opencontainers.image.title=${{ github.event.repository.name }}
57+
org.opencontainers.image.description=${{ github.event.repository.description }}
58+
org.opencontainers.image.source=${{ github.event.repository.html_url }}
59+
org.opencontainers.image.url=${{ github.event.repository.html_url }}
60+
org.opencontainers.image.revision=${{ github.sha }}
61+
org.opencontainers.image.version=${{ steps.prep.outputs.VERSION }}
62+
org.opencontainers.image.created=${{ steps.prep.outputs.BUILD_DATE }}
2163
22-
- name: Release
64+
- name: GoReleaser
65+
uses: goreleaser/goreleaser-action@v3
66+
with:
67+
version: latest
68+
args: release
2369
env:
24-
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
25-
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
26-
run: ./scripts/release.sh
70+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

scripts/release.sh

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

0 commit comments

Comments
 (0)