Skip to content

Commit 151c0d1

Browse files
authored
Merge pull request #107 from antigenomics/github-ci-publish
Add publish steps (only on tag creation)
2 parents f438171 + d4a3be9 commit 151c0d1

File tree

1 file changed

+51
-1
lines changed

1 file changed

+51
-1
lines changed

.github/workflows/ci.yml

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ name: Build and Test
33
on:
44
push:
55
branches: [ main, master ]
6+
tags:
7+
- "v*"
68
pull_request:
79
branches: [ main, master ]
810

911
jobs:
10-
build:
12+
build-publish:
1113
runs-on: ubuntu-latest
1214

1315
steps:
@@ -63,3 +65,51 @@ jobs:
6365
name: vdjdb-server
6466
path: target/universal/*.zip
6567

68+
# -------------------------------
69+
# Version check (TAG ONLY)
70+
# -------------------------------
71+
- name: Check numeric version matches sbt version
72+
if: github.ref_type == 'tag'
73+
shell: bash
74+
run: |
75+
set -e
76+
77+
TAG="$GITHUB_REF_NAME"
78+
79+
# Enforce basic tag shape: vX.Y.Z(-anything)?
80+
if ! [[ "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then
81+
echo "Invalid tag format: $TAG"
82+
exit 1
83+
fi
84+
85+
# Extract numeric core from tag
86+
TAG_NUMERIC=$(echo "$TAG" | sed -E 's/^v([0-9]+\.[0-9]+\.[0-9]+).*/\1/')
87+
echo "Tag numeric version: $TAG_NUMERIC"
88+
89+
# Extract numeric core from sbt version
90+
SBT_VERSION=$(sbt -Dsbt.supershell=false 'print version' | tail -n 1 | tr -d '[:space:]')
91+
SBT_NUMERIC=$(echo "$SBT_VERSION" | sed -E 's/^([0-9]+\.[0-9]+\.[0-9]+).*/\1/')
92+
echo "sbt numeric version: $SBT_NUMERIC"
93+
94+
if [ "$TAG_NUMERIC" != "$SBT_NUMERIC" ]; then
95+
echo "Numeric version mismatch"
96+
echo "Tag: $TAG_NUMERIC"
97+
echo "sbt: $SBT_NUMERIC"
98+
exit 1
99+
fi
100+
101+
echo "Numeric versions match"
102+
103+
# -------------------------------
104+
# Docker publish (TAG ONLY)
105+
# -------------------------------
106+
- name: Log in to Docker Hub
107+
if: github.ref_type == 'tag'
108+
uses: docker/login-action@v3
109+
with:
110+
username: ${{ secrets.DOCKERHUB_USERNAME }}
111+
password: ${{ secrets.DOCKERHUB_TOKEN }}
112+
113+
- name: Publish Docker image
114+
if: github.ref_type == 'tag'
115+
run: sbt Docker/publish

0 commit comments

Comments
 (0)