-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (74 loc) · 2.81 KB
/
Copy pathdockerhub.yml
File metadata and controls
87 lines (74 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
name: Docker (Docker Hub)
on:
push:
tags: ["v*"]
permissions:
contents: write
env:
# Default image name: <dockerhub-username>/hearth
# If your Docker Hub repo name is different, change this to e.g. "${{ secrets.DOCKERHUB_USERNAME }}/<repo>".
IMAGE_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/hearth
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Login to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
flavor: |
latest=true
- name: Determine version
id: version
run: echo "version=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
- name: Build and push (multi-arch)
uses: docker/build-push-action@v7
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: VERSION=${{ steps.version.outputs.version }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build release notes
if: startsWith(github.ref, 'refs/tags/v')
id: notes
run: |
TAG="${GITHUB_REF#refs/tags/}"
PREV_TAG=$(git tag --sort=-v:refname | grep -A1 "^${TAG}$" | tail -1)
# Get commit messages between previous tag and this tag
if [ -n "$PREV_TAG" ] && [ "$PREV_TAG" != "$TAG" ]; then
COMMITS=$(git log --pretty=format:"- %s" "${PREV_TAG}..${TAG}" | grep -v "Co-Authored-By")
BODY=$(printf "## What's Changed\n\n%s\n\n**Full Changelog**: https://github.com/${{ github.repository }}/compare/%s...%s" "$COMMITS" "$PREV_TAG" "$TAG")
else
MSG=$(git log -1 --pretty=format:"%b" "$TAG" | grep -v "Co-Authored-By" || true)
SUBJECT=$(git log -1 --pretty=format:"%s" "$TAG")
BODY=$(printf "## What's Changed\n\n- %s\n\n%s" "$SUBJECT" "$MSG")
fi
# Write to file to preserve newlines
echo "$BODY" > /tmp/release_notes.md
- name: Create GitHub Release
if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@v3
with:
body_path: /tmp/release_notes.md