Skip to content

Commit d5fcf88

Browse files
weng271190436Wei Weng
andauthored
feat: publish image to ghcr with tag (#353)
* publish image with tag Signed-off-by: Wei Weng <Wei.Weng@microsoft.com> * fix unknown/unknown Signed-off-by: Wei Weng <Wei.Weng@microsoft.com> * comment Signed-off-by: Wei Weng <Wei.Weng@microsoft.com> * commit suggestions Signed-off-by: Wei Weng <Wei.Weng@microsoft.com> * remove provenance=false Signed-off-by: Wei Weng <Wei.Weng@microsoft.com> --------- Signed-off-by: Wei Weng <Wei.Weng@microsoft.com> Co-authored-by: Wei Weng <Wei.Weng@microsoft.com>
1 parent 5832681 commit d5fcf88

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed

.github/workflows/release.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Release Images
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
workflow_dispatch:
8+
inputs:
9+
tag:
10+
description: 'Release tag (e.g., v1.0.0)'
11+
required: true
12+
type: string
13+
14+
permissions:
15+
contents: read
16+
packages: write
17+
18+
env:
19+
REGISTRY: ghcr.io
20+
HUB_AGENT_IMAGE_NAME: hub-agent
21+
MEMBER_AGENT_IMAGE_NAME: member-agent
22+
REFRESH_TOKEN_IMAGE_NAME: refresh-token
23+
GO_VERSION: '1.24.9'
24+
25+
jobs:
26+
export-registry:
27+
runs-on: ubuntu-latest
28+
outputs:
29+
registry: ${{ steps.export.outputs.registry }}
30+
tag: ${{ steps.export.outputs.tag }}
31+
steps:
32+
- name: Checkout code
33+
uses: actions/checkout@v6.0.0
34+
35+
- id: export
36+
run: |
37+
# registry must be in lowercase
38+
echo "registry=$(echo "${{ env.REGISTRY }}/${{ github.repository }}" | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
39+
40+
# Extract tag from github ref or workflow input
41+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
42+
TAG="${{ inputs.tag }}"
43+
elif [[ "${{ github.ref }}" == refs/tags/* ]]; then
44+
TAG=${GITHUB_REF#refs/tags/}
45+
else
46+
echo "Error: Workflow triggered by unsupported event or ref"
47+
echo "Event: ${{ github.event_name }}"
48+
echo "Ref: ${{ github.ref }}"
49+
exit 1
50+
fi
51+
echo "tag=${TAG}" >> $GITHUB_OUTPUT
52+
echo "Release tag: ${TAG}"
53+
54+
build-and-publish:
55+
needs: export-registry
56+
env:
57+
REGISTRY: ${{ needs.export-registry.outputs.registry }}
58+
TAG: ${{ needs.export-registry.outputs.tag }}
59+
runs-on: ubuntu-latest
60+
steps:
61+
- name: Set up Go ${{ env.GO_VERSION }}
62+
uses: actions/setup-go@v6
63+
with:
64+
go-version: ${{ env.GO_VERSION }}
65+
66+
- name: Checkout code
67+
uses: actions/checkout@v6.0.0
68+
69+
- name: Login to ghcr.io
70+
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef
71+
with:
72+
registry: ghcr.io
73+
username: ${{ github.actor }}
74+
password: ${{ secrets.GITHUB_TOKEN }}
75+
76+
- name: Build and push images with tag ${{ env.TAG }}
77+
run: |
78+
make push
79+
80+
- name: Verify images
81+
run: |
82+
echo "✅ Published images:"
83+
echo " - ${{ env.REGISTRY }}/${{ env.HUB_AGENT_IMAGE_NAME }}:${{ env.TAG }}"
84+
echo " - ${{ env.REGISTRY }}/${{ env.MEMBER_AGENT_IMAGE_NAME }}:${{ env.TAG }}"
85+
echo " - ${{ env.REGISTRY }}/${{ env.REFRESH_TOKEN_IMAGE_NAME }}:${{ env.TAG }}"
86+
echo ""
87+
echo "📦 Images are now public!"

0 commit comments

Comments
 (0)