Skip to content

Commit 2a93fba

Browse files
authored
Merge pull request #207 from fairagro/feature/fix_github_workflows
Feature/fix GitHub workflows
2 parents c441513 + 78ebeca commit 2a93fba

3 files changed

Lines changed: 55 additions & 8 deletions

File tree

.github/workflows/helm-release.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ jobs:
120120
create_annotated_tag: true
121121

122122
- name: Create GitHub Release (Draft)
123+
id: create_release
123124
if: github.ref_name == 'main'
124125
uses: softprops/action-gh-release@v2
125126
with:
@@ -157,10 +158,30 @@ jobs:
157158
env:
158159
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
159160
run: |
160-
RELEASE_ID=$(gh api repos/${{ github.repository }}/releases/tags/${{ steps.timestamp.outputs.value }}-chart-v${{ env.CHART_VERSION }} --jq '.id')
161+
echo "🔍 Finalizing helm release for tag: ${{ steps.timestamp.outputs.value }}-chart-v${{ env.CHART_VERSION }}"
162+
163+
# Give GitHub API a moment to index the new release
164+
sleep 5
165+
166+
# Try to get the release ID from the draft release we just created
167+
if RELEASE_ID=$(gh api repos/${{ github.repository }}/releases/tags/${{ steps.timestamp.outputs.value }}-chart-v${{ env.CHART_VERSION }} --jq '.id' 2>/dev/null); then
168+
echo "✅ Found release ID via tag: $RELEASE_ID"
169+
else
170+
echo "⚠️ Release not found via tag, searching in all releases..."
171+
RELEASE_ID=$(gh api repos/${{ github.repository }}/releases --jq '.[] | select(.tag_name == "${{ steps.timestamp.outputs.value }}-chart-v${{ env.CHART_VERSION }}") | .id')
172+
173+
if [[ -n "$RELEASE_ID" ]]; then
174+
echo "✅ Found release ID via search: $RELEASE_ID"
175+
else
176+
echo "❌ Release not found at all!"
177+
exit 1
178+
fi
179+
fi
180+
161181
gh api repos/${{ github.repository }}/releases/$RELEASE_ID \
162182
--method PATCH \
163183
--field draft=false
184+
echo "🎉 Helm release finalized successfully"
164185
165186
- name: Push Helm chart to Docker Hub
166187
if: env.DOCKERHUB_AVAILABLE == 'true' && github.ref_name == 'main'

.github/workflows/reusable-build.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,16 @@ jobs:
4949
- name: Calculate next version
5050
id: calc-version
5151
run: |
52-
LATEST_TAG=$(git tag --list 'v*' --sort=-version:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -1)
53-
if [ -z "$LATEST_TAG" ]; then LATEST_TAG="v0.0.0"; fi
54-
55-
MAJOR=$(echo "${LATEST_TAG#v}" | cut -d. -f1)
56-
MINOR=$(echo "${LATEST_TAG#v}" | cut -d. -f2)
57-
PATCH=$(echo "${LATEST_TAG#v}" | cut -d. -f3)
52+
LATEST_TAG=$(git tag --list '*-docker-v*' \
53+
| grep -E '^[0-9]+-docker-v[0-9]+\.[0-9]+\.[0-9]+$' \
54+
| sed 's/^[0-9]*-docker-v//' \
55+
| sort -V \
56+
| tail -1)
57+
if [ -z "$LATEST_TAG" ]; then LATEST_TAG="0.0.0"; fi
58+
59+
MAJOR=$(echo "$LATEST_TAG" | cut -d. -f1)
60+
MINOR=$(echo "$LATEST_TAG" | cut -d. -f2)
61+
PATCH=$(echo "$LATEST_TAG" | cut -d. -f3)
5862
5963
case "${{ inputs.version_bump }}" in
6064
major) MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 ;;

.github/workflows/reusable-release.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ jobs:
162162
} > release-body.md
163163
164164
- name: Create GitHub Release (Draft)
165+
id: create_release
165166
uses: softprops/action-gh-release@v2
166167
with:
167168
tag_name: ${{ needs.create-release-tag.outputs.timestamp }}-${{ inputs.tag_prefix }}${{ inputs.version }}
@@ -175,7 +176,28 @@ jobs:
175176
env:
176177
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
177178
run: |
178-
RELEASE_ID=$(gh api repos/${{ github.repository }}/releases/tags/${{ needs.create-release-tag.outputs.timestamp }}-${{ inputs.tag_prefix }}${{ inputs.version }} --jq '.id')
179+
echo "🔍 Finalizing release for tag: ${{ needs.create-release-tag.outputs.timestamp }}-${{ inputs.tag_prefix }}${{ inputs.version }}"
180+
181+
# Give GitHub API a moment to index the new release
182+
sleep 5
183+
184+
# Try to get the release ID from the draft release we just created
185+
if RELEASE_ID=$(gh api repos/${{ github.repository }}/releases/tags/${{ needs.create-release-tag.outputs.timestamp }}-${{ inputs.tag_prefix }}${{ inputs.version }} --jq '.id' 2>/dev/null); then
186+
echo "✅ Found release ID via tag: $RELEASE_ID"
187+
else
188+
echo "⚠️ Release not found via tag, searching in all releases..."
189+
# Search for the release by tag name in all release list (including drafts)
190+
RELEASE_ID=$(gh api repos/${{ github.repository }}/releases --jq '.[] | select(.tag_name == "${{ needs.create-release-tag.outputs.timestamp }}-${{ inputs.tag_prefix }}${{ inputs.version }}") | .id')
191+
192+
if [[ -n "$RELEASE_ID" ]]; then
193+
echo "✅ Found release ID via search: $RELEASE_ID"
194+
else
195+
echo "❌ Release not found at all!"
196+
exit 1
197+
fi
198+
fi
199+
179200
gh api repos/${{ github.repository }}/releases/$RELEASE_ID \
180201
--method PATCH \
181202
--field draft=false
203+
echo "🎉 Release finalized successfully"

0 commit comments

Comments
 (0)