Skip to content

Commit 409d350

Browse files
Wei WengWei Weng
authored andcommitted
release image
Signed-off-by: Wei Weng <Wei.Weng@microsoft.com>
1 parent b2198c0 commit 409d350

File tree

1 file changed

+117
-0
lines changed

1 file changed

+117
-0
lines changed

.github/workflows/release.yml

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
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+
- id: export
33+
run: |
34+
# registry must be in lowercase
35+
echo "registry=$(echo "${{ env.REGISTRY }}/${{ github.repository }}" | tr [:upper:] [:lower:])" >> $GITHUB_OUTPUT
36+
37+
# Extract tag from github ref or workflow input
38+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
39+
TAG="${{ inputs.tag }}"
40+
else
41+
TAG=${GITHUB_REF#refs/tags/}
42+
fi
43+
echo "tag=${TAG}" >> $GITHUB_OUTPUT
44+
echo "Release tag: ${TAG}"
45+
46+
build-and-publish:
47+
needs: export-registry
48+
env:
49+
REGISTRY: ${{ needs.export-registry.outputs.registry }}
50+
TAG: ${{ needs.export-registry.outputs.tag }}
51+
runs-on: ubuntu-latest
52+
steps:
53+
- name: Set up Go ${{ env.GO_VERSION }}
54+
uses: actions/setup-go@v6
55+
with:
56+
go-version: ${{ env.GO_VERSION }}
57+
58+
- name: Checkout code
59+
uses: actions/checkout@v6.0.0
60+
61+
- name: Login to ${{ env.REGISTRY }}
62+
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef
63+
with:
64+
registry: ${{ env.REGISTRY }}
65+
username: ${{ github.actor }}
66+
password: ${{ secrets.GITHUB_TOKEN }}
67+
68+
- name: Build and push images with tag ${{ env.TAG }}
69+
run: |
70+
make push
71+
env:
72+
REGISTRY: ${{ env.REGISTRY }}
73+
TAG: ${{ env.TAG }}
74+
75+
- name: Make hub-agent image public
76+
run: |
77+
# Get package name
78+
PACKAGE_NAME="${{ env.HUB_AGENT_IMAGE_NAME }}"
79+
80+
# Make the package public using GitHub API
81+
curl -X PATCH \
82+
-H "Accept: application/vnd.github+json" \
83+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
84+
-H "X-GitHub-Api-Version: 2022-11-28" \
85+
"https://api.github.com/orgs/${{ github.repository_owner }}/packages/container/${PACKAGE_NAME}" \
86+
-d '{"visibility":"public"}'
87+
88+
- name: Make member-agent image public
89+
run: |
90+
PACKAGE_NAME="${{ env.MEMBER_AGENT_IMAGE_NAME }}"
91+
92+
curl -X PATCH \
93+
-H "Accept: application/vnd.github+json" \
94+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
95+
-H "X-GitHub-Api-Version: 2022-11-28" \
96+
"https://api.github.com/orgs/${{ github.repository_owner }}/packages/container/${PACKAGE_NAME}" \
97+
-d '{"visibility":"public"}'
98+
99+
- name: Make refresh-token image public
100+
run: |
101+
PACKAGE_NAME="${{ env.REFRESH_TOKEN_IMAGE_NAME }}"
102+
103+
curl -X PATCH \
104+
-H "Accept: application/vnd.github+json" \
105+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
106+
-H "X-GitHub-Api-Version: 2022-11-28" \
107+
"https://api.github.com/orgs/${{ github.repository_owner }}/packages/container/${PACKAGE_NAME}" \
108+
-d '{"visibility":"public"}'
109+
110+
- name: Verify images
111+
run: |
112+
echo "✅ Published images:"
113+
echo " - ${{ env.REGISTRY }}/${{ env.HUB_AGENT_IMAGE_NAME }}:${{ env.TAG }}"
114+
echo " - ${{ env.REGISTRY }}/${{ env.MEMBER_AGENT_IMAGE_NAME }}:${{ env.TAG }}"
115+
echo " - ${{ env.REGISTRY }}/${{ env.REFRESH_TOKEN_IMAGE_NAME }}:${{ env.TAG }}"
116+
echo ""
117+
echo "📦 Images are now public!"

0 commit comments

Comments
 (0)