1- name : Build and Push Docker image
1+ name : Build and Push Docker images
22
33# CalVer Release Workflow
4- #
4+ #
55# Automatically creates a CalVer release on every push to main.
66# Version format: YYYY.MM.DD (e.g., 2026.01.16)
77# If multiple releases happen on the same day, adds sequence: YYYY.MM.DD.2, YYYY.MM.DD.3, etc.
88#
9- # Docker tags created:
9+ # Two separate images are built and pushed:
10+ # vcon-server-api — lightweight FastAPI/uvicorn image (main deps only)
11+ # vcon-server-conserver — full processing image (main + links + storage deps)
12+ #
13+ # Docker tags created for each image:
1014# - CalVer tag (e.g., 2026.01.16)
1115# - Branch name (e.g., main)
1216# - Git short hash (e.g., main-a1b2c3d)
1822 tags : ['v*']
1923
2024jobs :
21- build :
25+ prepare :
2226 runs-on : ubuntu-latest
2327 permissions :
24- contents : write # Need write for creating tags
25- packages : write
26-
28+ contents : write
29+ outputs :
30+ version : ${{ steps.calver.outputs.version }}
31+ short_sha : ${{ steps.git.outputs.short_sha }}
32+ build_time : ${{ steps.git.outputs.build_time }}
2733 steps :
2834 - name : Checkout code
2935 uses : actions/checkout@v4
3036 with :
31- fetch-depth : 0 # Fetch all history for tags
37+ fetch-depth : 0
3238
3339 - name : Generate CalVer version
3440 id : calver
3541 run : |
36- # Get today's date in YYYY.MM.DD format
3742 TODAY=$(date +"%Y.%m.%d")
38-
39- # Get all existing tags for today
4043 EXISTING_TAGS=$(git tag -l "${TODAY}*" | sort -V)
41-
44+
4245 if [ -z "$EXISTING_TAGS" ]; then
43- # No tags for today, use base date
4446 VERSION="${TODAY}"
4547 else
46- # Find the highest sequence number
4748 LAST_TAG=$(echo "$EXISTING_TAGS" | tail -1)
48-
4949 if [[ "$LAST_TAG" == "$TODAY" ]]; then
50- # First tag was just the date, next is .2
5150 VERSION="${TODAY}.2"
5251 elif [[ "$LAST_TAG" =~ ^${TODAY}\.([0-9]+)$ ]]; then
53- # Extract sequence number and increment
5452 SEQ="${BASH_REMATCH[1]}"
5553 NEXT_SEQ=$((SEQ + 1))
5654 VERSION="${TODAY}.${NEXT_SEQ}"
5755 else
58- # Fallback
5956 VERSION="${TODAY}.2"
6057 fi
6158 fi
62-
59+
6360 echo "version=${VERSION}" >> $GITHUB_OUTPUT
6461 echo "Generated CalVer version: ${VERSION}"
6562
6663 - name : Get git commit info
6764 id : git
6865 run : |
6966 echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
70- echo "full_sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
7167 echo "build_time=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> $GITHUB_OUTPUT
7268
7369 - name : Create git tag
7470 if : github.ref == 'refs/heads/main'
7571 run : |
7672 git config user.name "github-actions[bot]"
7773 git config user.email "github-actions[bot]@users.noreply.github.com"
78-
79- # Check if tag already exists
74+
8075 if git rev-parse "${{ steps.calver.outputs.version }}" >/dev/null 2>&1; then
8176 echo "Tag ${{ steps.calver.outputs.version }} already exists, skipping"
8277 else
8580 echo "Created and pushed tag ${{ steps.calver.outputs.version }}"
8681 fi
8782
83+ build :
84+ needs : prepare
85+ runs-on : ubuntu-latest
86+ permissions :
87+ contents : read
88+ packages : write
89+ strategy :
90+ matrix :
91+ include :
92+ - service : api
93+ dockerfile : ./docker/Dockerfile.api
94+ image : public.ecr.aws/r4g1k2s3/vcon-dev/vcon-server-api
95+ - service : conserver
96+ dockerfile : ./docker/Dockerfile.conserver
97+ image : public.ecr.aws/r4g1k2s3/vcon-dev/vcon-server-conserver
98+
99+ steps :
100+ - name : Checkout code
101+ uses : actions/checkout@v4
102+
88103 - name : Set up Docker Buildx
89104 uses : docker/setup-buildx-action@v3
90105
@@ -99,66 +114,62 @@ jobs:
99114 id : meta
100115 uses : docker/metadata-action@v5
101116 with :
102- images : |
103- public.ecr.aws/r4g1k2s3/vcon-dev/vcon-server
117+ images : ${{ matrix.image }}
104118 tags : |
105- # CalVer tag (e.g., 2026.01.16)
106- type=raw,value=${{ steps.calver.outputs.version }},enable=${{ github.ref == 'refs/heads/main' }}
107- # Branch name
119+ type=raw,value=${{ needs.prepare.outputs.version }},enable=${{ github.ref == 'refs/heads/main' }}
108120 type=ref,event=branch
109- # PR number
110121 type=ref,event=pr
111- # Semver tags (for manual v* tags)
112122 type=semver,pattern={{version}}
113123 type=semver,pattern={{major}}.{{minor}}
114- # Git sha with branch prefix
115124 type=sha,prefix={{branch}}-
116- # Latest tag for main branch
117125 type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
118126
119- - name : Build and push Docker image
127+ - name : Build and push ${{ matrix.service }} image
120128 uses : docker/build-push-action@v5
121129 with :
122130 context : .
123- file : ./docker/Dockerfile
131+ file : ${{ matrix.dockerfile }}
124132 platforms : linux/amd64
125133 push : true
126- cache-from : type=gha
127- cache-to : type=gha,mode=max
134+ cache-from : type=gha,scope=${{ matrix.service }}
135+ cache-to : type=gha,mode=max,scope=${{ matrix.service }}
128136 tags : ${{ steps.meta.outputs.tags }}
129137 labels : ${{ steps.meta.outputs.labels }}
130138 build-args : |
131- VCON_SERVER_VERSION=${{ steps.calver .outputs.version }}
132- VCON_SERVER_GIT_COMMIT=${{ steps.git .outputs.short_sha }}
133- VCON_SERVER_BUILD_TIME=${{ steps.git .outputs.build_time }}
139+ VCON_SERVER_VERSION=${{ needs.prepare .outputs.version }}
140+ VCON_SERVER_GIT_COMMIT=${{ needs.prepare .outputs.short_sha }}
141+ VCON_SERVER_BUILD_TIME=${{ needs.prepare .outputs.build_time }}
134142
143+ release :
144+ needs : [prepare, build]
145+ runs-on : ubuntu-latest
146+ if : github.ref == 'refs/heads/main'
147+ permissions :
148+ contents : write
149+ steps :
135150 - name : Create GitHub Release
136- if : github.ref == 'refs/heads/main'
137151 uses : softprops/action-gh-release@v1
138152 with :
139- tag_name : ${{ steps.calver .outputs.version }}
140- name : Release ${{ steps.calver .outputs.version }}
153+ tag_name : ${{ needs.prepare .outputs.version }}
154+ name : Release ${{ needs.prepare .outputs.version }}
141155 body : |
142- ## Release ${{ steps.calver .outputs.version }}
143-
144- **Commit:** ${{ steps.git .outputs.short_sha }}
145- **Build Time:** ${{ steps.git .outputs.build_time }}
146-
156+ ## Release ${{ needs.prepare .outputs.version }}
157+
158+ **Commit:** ${{ needs.prepare .outputs.short_sha }}
159+ **Build Time:** ${{ needs.prepare .outputs.build_time }}
160+
147161 ### Docker Images
148-
149- Pull using CalVer:
150- ```bash
151- docker pull public.ecr.aws/r4g1k2s3/vcon-dev/vcon-server:${{ steps.calver.outputs.version }}
152- ```
153-
154- Pull using git hash:
162+
163+ **API service** (FastAPI/uvicorn, lightweight):
155164 ```bash
156- docker pull public.ecr.aws/r4g1k2s3/vcon-dev/vcon-server:main-${{ steps.git.outputs.short_sha }}
165+ docker pull public.ecr.aws/r4g1k2s3/vcon-dev/vcon-server-api:${{ needs.prepare.outputs.version }}
166+ docker pull public.ecr.aws/r4g1k2s3/vcon-dev/vcon-server-api:latest
157167 ```
158-
159- Pull latest :
168+
169+ **Conserver service** (processing pipeline, full dependencies) :
160170 ```bash
161- docker pull public.ecr.aws/r4g1k2s3/vcon-dev/vcon-server:latest
171+ docker pull public.ecr.aws/r4g1k2s3/vcon-dev/vcon-server-conserver:${{ needs.prepare.outputs.version }}
172+ docker pull public.ecr.aws/r4g1k2s3/vcon-dev/vcon-server-conserver:latest
162173 ```
163174 draft : false
164175 prerelease : false
@@ -171,12 +182,11 @@ jobs:
171182 echo "" >> $GITHUB_STEP_SUMMARY
172183 echo "| Property | Value |" >> $GITHUB_STEP_SUMMARY
173184 echo "|----------|-------|" >> $GITHUB_STEP_SUMMARY
174- echo "| **Version** | ${{ steps.calver .outputs.version }} |" >> $GITHUB_STEP_SUMMARY
175- echo "| **Git Commit** | ${{ steps.git .outputs.short_sha }} |" >> $GITHUB_STEP_SUMMARY
176- echo "| **Build Time** | ${{ steps.git .outputs.build_time }} |" >> $GITHUB_STEP_SUMMARY
185+ echo "| **Version** | ${{ needs.prepare .outputs.version }} |" >> $GITHUB_STEP_SUMMARY
186+ echo "| **Git Commit** | ${{ needs.prepare .outputs.short_sha }} |" >> $GITHUB_STEP_SUMMARY
187+ echo "| **Build Time** | ${{ needs.prepare .outputs.build_time }} |" >> $GITHUB_STEP_SUMMARY
177188 echo "| **Branch** | ${{ github.ref_name }} |" >> $GITHUB_STEP_SUMMARY
178189 echo "" >> $GITHUB_STEP_SUMMARY
179- echo "### Docker Tags" >> $GITHUB_STEP_SUMMARY
180- echo '```' >> $GITHUB_STEP_SUMMARY
181- echo "${{ steps.meta.outputs.tags }}" >> $GITHUB_STEP_SUMMARY
182- echo '```' >> $GITHUB_STEP_SUMMARY
190+ echo "### Docker Images Built" >> $GITHUB_STEP_SUMMARY
191+ echo "- \`vcon-server-api\` — API service (main deps only)" >> $GITHUB_STEP_SUMMARY
192+ echo "- \`vcon-server-conserver\` — Conserver service (main + links + storage)" >> $GITHUB_STEP_SUMMARY
0 commit comments