Skip to content

Commit 29352dc

Browse files
committed
Add GitHub Actions workflow to publish Alpha Docker image
1 parent 8967725 commit 29352dc

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed

.github/workflows/publish-alpha.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Publish Alpha podverse-web Docker image
2+
3+
on:
4+
push:
5+
branches:
6+
- v5-alpha
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v3
15+
16+
- name: Set up Node.js
17+
uses: actions/setup-node@v3
18+
with:
19+
node-version: '22'
20+
21+
- name: Install podverse-helpers latest alpha version
22+
run: npm i podverse-helpers@alpha --save
23+
24+
- name: Install podverse-external-services latest alpha version
25+
run: npm i podverse-external-services@alpha --save
26+
27+
- name: Install podverse-orm latest alpha version
28+
run: npm i podverse-orm@alpha --save
29+
30+
- name: Install podverse-parser latest alpha version
31+
run: npm i podverse-parser@alpha --save
32+
33+
- name: Clean install dependencies
34+
run: npm clean-install
35+
36+
- name: Determine next alpha version
37+
id: version
38+
run: |
39+
BASE_VERSION=$(node -p "require('./package.json').version")
40+
BASE_VERSION=$(echo "$BASE_VERSION" | sed 's/-.*//')
41+
IMAGE_NAME=ghcr.io/${{ github.repository }}/podverse-web
42+
43+
# Use a PAT with read:packages scope
44+
TOKEN="${{ secrets.GHCR_REGISTRY_TOKEN }}"
45+
TAGS_JSON=$(curl -s -H "Authorization: Bearer $TOKEN" \
46+
"https://ghcr.io/v2/${{ github.repository }}/podverse-web/tags/list")
47+
echo "Raw tags JSON: $TAGS_JSON"
48+
TAGS=$(echo "$TAGS_JSON" | jq -r '.tags[]' | grep "alpha" || true)
49+
echo "Filtered alpha tags: $TAGS"
50+
51+
# Try to get the current alpha version (e.g., 5.1.1-alpha.3)
52+
ALPHA_VERSION=$(echo "$TAGS" | grep "^${BASE_VERSION}-alpha\." | sort -V | tail -n1)
53+
echo "Latest alpha version for base $BASE_VERSION: $ALPHA_VERSION"
54+
55+
if [[ -z "$ALPHA_VERSION" ]]; then
56+
echo "No alpha version found. Starting with: $BASE_VERSION-alpha.0"
57+
NEXT_VERSION="$BASE_VERSION-alpha.0"
58+
else
59+
CURRENT_BASE=$(echo "$ALPHA_VERSION" | cut -d '-' -f 1)
60+
CURRENT_ALPHA_NUM=$(echo "$ALPHA_VERSION" | sed -En 's/.*alpha\.([0-9]+)$/\1/p')
61+
62+
if [[ -z "$CURRENT_ALPHA_NUM" ]]; then
63+
NEXT_VERSION="$BASE_VERSION-alpha.0"
64+
elif [[ "$CURRENT_BASE" == "$BASE_VERSION" ]]; then
65+
NEXT_INDEX=$((CURRENT_ALPHA_NUM + 1))
66+
NEXT_VERSION="$BASE_VERSION-alpha.$NEXT_INDEX"
67+
echo "Same base version detected. Incrementing alpha to: $NEXT_VERSION"
68+
else
69+
NEXT_VERSION="$BASE_VERSION-alpha.0"
70+
echo "New base version detected. Resetting alpha to: $NEXT_VERSION"
71+
fi
72+
fi
73+
74+
echo "NEXT_VERSION=$NEXT_VERSION" >> $GITHUB_OUTPUT
75+
76+
- name: Build Docker image
77+
run: |
78+
docker build . -t ghcr.io/${{ github.repository }}/podverse-web:${{ steps.version.outputs.NEXT_VERSION }}
79+
80+
- name: Log in to GitHub Container Registry
81+
uses: docker/login-action@v3
82+
with:
83+
registry: ghcr.io
84+
username: ${{ github.actor }}
85+
password: ${{ secrets.GITHUB_TOKEN }}
86+
87+
- name: Push Docker image
88+
run: |
89+
docker push ghcr.io/${{ github.repository }}/podverse-web:${{ steps.version.outputs.NEXT_VERSION }}

0 commit comments

Comments
 (0)