@@ -3,7 +3,7 @@ name: Release Workflow
33on :
44 push :
55 tags :
6- - ' * '
6+ - " v* "
77
88permissions :
99 id-token : write
@@ -27,33 +27,32 @@ jobs:
2727 - name : Log in to GitHub Container Registry
2828 run : echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
2929
30- - name : Get latest GitHub release tag
31- id : latest_release
32- run : |
33- LATEST_TAG=$(gh release list --limit 1 --json tagName --jq '.[0].tagName')
34- echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV
35- env :
36- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
37-
3830 - name : Build and tag Docker image
3931 run : |
4032 IMAGE_TAG="${GITHUB_REF#refs/tags/}"
33+ REPO="ghcr.io/${{ github.repository_owner }}/expo-open-ota"
4134
42- docker build -t ghcr.io/${{ github.repository_owner }}/expo-open-ota:${IMAGE_TAG} .
43- docker push ghcr.io/${{ github.repository_owner }}/expo-open-ota:${IMAGE_TAG}
35+ echo "🔨 Building Docker image with tag: $IMAGE_TAG"
36+ docker build -t "$REPO:$IMAGE_TAG" .
37+ docker push "$REPO:$IMAGE_TAG"
38+
39+ - name : Check latest version and update latest tag
40+ run : |
41+ REPO="ghcr.io/${{ github.repository_owner }}/expo-open-ota"
4442
45- TAGS=$(gh api -H "Accept: application/vnd.github+json" \
46- / users/${{ github.repository_owner }}/packages/container/expo-open-ota/versions \
47- | jq -r ' .[].metadata.container.tags[]' | sort -V )
43+ echo "📡 Fetching the latest version tag from GHCR..."
44+ LATEST_TAG=$(gh api "https://api.github.com/ users/${{ github.repository_owner }}/packages/container/expo-open-ota/versions" \
45+ -- jq '[ .[].metadata.container.tags[]] | map(select(test("^v[0-9]+\\.[0-9]+\\.[0-9]+$"))) | sort_by(.) | last ' | tr -d '"' )
4846
49- LATEST_TAG=$(echo "$TAGS" | tail -n 1)
47+ echo "🔍 Latest found version: $LATEST_TAG"
48+ echo "🏷️ Current version: $IMAGE_TAG"
5049
51- if [ "$IMAGE_TAG " == "$LATEST_TAG " ]; then
52- echo "This is the highest version. Tagging as ' latest' ."
53- docker tag ghcr.io/${{ github.repository_owner }}/expo-open-ota:${ IMAGE_TAG} ghcr.io/${{ github.repository_owner }}/expo-open-ota :latest
54- docker push ghcr.io/${{ github.repository_owner }}/expo-open-ota :latest
50+ if [ "$LATEST_TAG " = "$IMAGE_TAG " ]; then
51+ echo "✅ $IMAGE_TAG is the latest version. Updating latest tag.. ."
52+ docker tag "$REPO:$ IMAGE_TAG" "$REPO :latest"
53+ docker push "$REPO :latest"
5554 else
56- echo "Skipping 'latest' tag, $IMAGE_TAG is not the highest version, $LATEST_TAG is ."
55+ echo "ℹ️ $IMAGE_TAG is not the latest version. Skipping latest tag update ."
5756 fi
5857
5958 helm :
8382 - name : Setup Node.js
8483 uses : actions/setup-node@v4
8584 with :
86- node-version : ' 20.x'
87- registry-url : ' https://registry.npmjs.org'
85+ node-version : " 20.x"
86+ registry-url : " https://registry.npmjs.org"
8887
8988 - name : Publish NPM package
9089 run : |
0 commit comments