-
Notifications
You must be signed in to change notification settings - Fork 314
132 lines (118 loc) · 4.31 KB
/
_reusable-docker-release.yaml
File metadata and controls
132 lines (118 loc) · 4.31 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
name: Reusable Docker Release
on:
workflow_call:
inputs:
image_name:
description: "Docker image name (e.g. acontext-core)"
required: true
type: string
context:
description: "Docker build context path (e.g. ./src/server/core)"
required: true
type: string
file:
description: "Dockerfile path (defaults to {context}/Dockerfile)"
required: false
type: string
default: ""
tag_prefix:
description: "Git tag prefix (e.g. core/v)"
required: true
type: string
display_name:
description: "Human-readable component name (e.g. Core)"
required: true
type: string
source_dir:
description: "Source directory for changelog scoping (e.g. src/server/core)"
required: true
type: string
permissions:
contents: write
packages: write
jobs:
build:
runs-on: ${{ matrix.runner }}
timeout-minutes: 30
strategy:
fail-fast: true
matrix:
include:
- platform: linux/amd64
runner: ubuntu-latest
suffix: amd64
- platform: linux/arm64
runner: ubuntu-24.04-arm
suffix: arm64
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Log in to GitHub Container Registry
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf
with:
images: ghcr.io/memodb-io/${{ inputs.image_name }}
tags: |
type=sha
- name: Build and Push Docker image
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f
with:
platforms: ${{ matrix.platform }}
context: ${{ inputs.context }}
file: ${{ inputs.file || '' }}
push: true
tags: ghcr.io/memodb-io/${{ inputs.image_name }}:sha-${{ github.sha }}-${{ matrix.suffix }}
labels: ${{ steps.meta.outputs.labels }}
sbom: true
provenance: mode=max
cache-from: type=gha,scope=${{ inputs.image_name }}-${{ matrix.suffix }}
cache-to: type=gha,mode=max,scope=${{ inputs.image_name }}-${{ matrix.suffix }}
merge:
runs-on: ubuntu-latest
timeout-minutes: 10
needs: build
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
fetch-depth: 0
- name: Log in to GitHub Container Registry
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract version from tag
id: version
run: |
VERSION="${GITHUB_REF_NAME#${{ inputs.tag_prefix }}}"
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
- name: Create multi-arch manifest
run: |
IMAGE="ghcr.io/memodb-io/${{ inputs.image_name }}"
SHA_SHORT="$(echo "$GITHUB_SHA" | head -c 7)"
docker buildx imagetools create \
--tag "${IMAGE}:${{ steps.version.outputs.version }}" \
--tag "${IMAGE}:sha-${SHA_SHORT}" \
"${IMAGE}:sha-${GITHUB_SHA}-amd64" \
"${IMAGE}:sha-${GITHUB_SHA}-arm64"
- name: Generate Changelog
run: |
bash .github/scripts/generate-changelog.sh \
--tag-prefix "${{ inputs.tag_prefix }}" \
--source-dir "${{ inputs.source_dir }}" \
--display-name "${{ inputs.display_name }}" \
--output "${{ github.workspace }}-CHANGELOG.txt" \
--footer "Published to https://github.com/memodb-io/Acontext/pkgs/container/${{ inputs.image_name }}"
- name: Create Release
uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda
with:
body_path: ${{ github.workspace }}-CHANGELOG.txt