Skip to content

Commit e49f39e

Browse files
authored
fix: nightly release job only manages a single 'nightly' tag (#83)
Signed-off-by: Calum Murray <cmurray@redhat.com>
1 parent 3dad7e8 commit e49f39e

File tree

1 file changed

+30
-18
lines changed

1 file changed

+30
-18
lines changed

.github/workflows/nightly-release.yaml

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
id: check_commits
2626
run: |
2727
# Find the latest release tag (any x.y.z release)
28-
LATEST_RELEASE=$(git tag -l 'v*.*.*' --sort=-version:refname | grep -v 'prerelease' | grep -v 'nightly' | head -n1)
28+
LATEST_RELEASE=$(git tag -l 'v*.*.*' --sort=-version:refname | grep -v 'prerelease' | grep -v '^nightly' | head -n1)
2929
3030
if [ -z "$LATEST_RELEASE" ]; then
3131
echo "No existing releases found, creating first nightly"
@@ -45,30 +45,22 @@ jobs:
4545
exit 0
4646
fi
4747
48-
# Check if there's already a nightly for today's commits
49-
TODAY=$(date -u +%Y%m%d)
5048
CURRENT_COMMIT=$(git rev-parse HEAD)
51-
SHORT_COMMIT=$(git rev-parse --short HEAD)
5249
5350
# Check for existing nightly with same commit
54-
EXISTING_NIGHTLY=$(git tag -l "*nightly*" | while read tag; do
55-
if [ -n "$tag" ]; then
56-
tag_commit=$(git rev-list -n 1 "$tag" 2>/dev/null || echo "")
57-
if [ "$tag_commit" = "$CURRENT_COMMIT" ]; then
58-
echo "$tag"
59-
break
60-
fi
61-
fi
62-
done)
51+
EXISTING_NIGHTLY_COMMIT=""
52+
if git rev-parse --verify nightly >/dev/null 2>&1; then
53+
EXISTING_NIGHTLY_COMMIT=$(git rev-list -n 1 nightly 2>/dev/null || echo "")
54+
fi
6355
64-
if [ -n "$EXISTING_NIGHTLY" ]; then
65-
echo "Nightly release already exists for current commit: $EXISTING_NIGHTLY"
56+
if [ "$EXISTING_NIGHTLY_COMMIT" = "$CURRENT_COMMIT" ]; then
57+
echo "Nightly release already exists for current commit"
6658
echo "SKIP_NIGHTLY=true" >> "$GITHUB_ENV"
6759
exit 0
6860
fi
6961
70-
# Create nightly version
71-
NIGHTLY_VERSION="nightly-${TODAY}-${SHORT_COMMIT}"
62+
# Use fixed nightly tag name
63+
NIGHTLY_VERSION="nightly"
7264
echo "NIGHTLY_VERSION=$NIGHTLY_VERSION" >> "$GITHUB_ENV"
7365
echo "Creating nightly release: $NIGHTLY_VERSION"
7466
@@ -91,14 +83,34 @@ jobs:
9183
echo 'EOF'
9284
} >> "$GITHUB_ENV"
9385
86+
- name: Delete existing nightly release and tag
87+
if: env.SKIP_NIGHTLY != 'true'
88+
run: |
89+
# Delete existing nightly release if it exists
90+
if gh release view nightly >/dev/null 2>&1; then
91+
echo "Deleting existing nightly release"
92+
gh release delete nightly --yes
93+
fi
94+
95+
# Delete existing nightly tag if it exists
96+
if git rev-parse --verify nightly >/dev/null 2>&1; then
97+
echo "Deleting existing nightly tag"
98+
git tag -d nightly
99+
git push origin :refs/tags/nightly || true
100+
fi
101+
env:
102+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
103+
94104
- name: Create nightly release
95105
if: env.SKIP_NIGHTLY != 'true'
96106
run: |
97107
VERSION="${{ env.NIGHTLY_VERSION }}"
108+
CURRENT_DATE=$(date -u +%Y-%m-%d)
109+
SHORT_COMMIT=$(git rev-parse --short HEAD)
98110
99111
echo "Creating nightly release: $VERSION"
100112
gh release create "$VERSION" \
101-
--title "Nightly Release $VERSION" \
113+
--title "Nightly Release ($CURRENT_DATE - $SHORT_COMMIT)" \
102114
--notes "${{ env.CHANGELOG_BODY }}" \
103115
--prerelease
104116
env:

0 commit comments

Comments
 (0)