Skip to content

Commit 0f64a4e

Browse files
authored
Release Cron Fix (UBC-Thunderbots#3595)
* cron fix * naming
1 parent a35ae66 commit 0f64a4e

1 file changed

Lines changed: 36 additions & 22 deletions

File tree

.github/workflows/release.yml

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -43,30 +43,53 @@ jobs:
4343
- name: Check for recent commits
4444
id: check
4545
run: |
46+
git fetch --tags
47+
48+
LATEST_TAG=$(git describe --tags --match "v[0-9]*" --abbrev=0 2>/dev/null || echo "v0.0.0")
49+
echo "Latest tag: $LATEST_TAG"
50+
51+
# Prevent double release on the same day (unless manual dispatch)
52+
if [ "${{ github.event_name }}" != "workflow_dispatch" ] && [ "$LATEST_TAG" != "v0.0.0" ]; then
53+
TAG_DATE=$(git log -1 --format=%as "$LATEST_TAG")
54+
TODAY=$(date +%Y-%m-%d)
55+
echo "Tag Date: $TAG_DATE, Today: $TODAY"
56+
57+
if [ "$TAG_DATE" = "$TODAY" ]; then
58+
echo "Already released $LATEST_TAG today. Skipping."
59+
echo "count=0" >> $GITHUB_OUTPUT
60+
exit 0
61+
fi
62+
fi
63+
4664
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
4765
echo "count=1" >> $GITHUB_OUTPUT
4866
else
49-
COUNT=$(git log --since="1 week ago" --oneline | wc -l)
67+
if [ "$LATEST_TAG" = "v0.0.0" ]; then
68+
COUNT=$(git log --oneline | wc -l)
69+
else
70+
COUNT=$(git log "$LATEST_TAG"..HEAD --oneline | wc -l)
71+
fi
5072
echo "count=$COUNT" >> $GITHUB_OUTPUT
5173
fi
5274
5375
- name: Determine Version Bump
5476
if: steps.check.outputs.count > 0
5577
id: bump_logic
5678
run: |
57-
if [ "${{ github.event.inputs.release_tag }}" = "" ]; then
79+
LATEST_TAG=$(git describe --tags --match "v[0-9]*" --abbrev=0 2>/dev/null || echo "v1.0.0")
80+
BASE_VERSION=${LATEST_TAG#v}
81+
82+
IFS='.' read -r major minor patch <<< "$BASE_VERSION"
83+
84+
if [ "${{ github.event.inputs.release_tag }}" != "" ]; then
85+
NEW_TAG="${{ github.event.inputs.release_tag }}"
86+
else
5887
BUMP="patch"
5988
if [ "$(date +%d)" = "01" ]; then BUMP="minor"; fi
6089
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
6190
BUMP="${{ github.event.inputs.version_type }}"
6291
fi
6392
64-
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v1.0.0")
65-
# Strip the 'v' prefix
66-
BASE_VERSION=${LATEST_TAG#v}
67-
68-
IFS='.' read -r major minor patch <<< "$BASE_VERSION"
69-
7093
if [ "$BUMP" = "major" ]; then
7194
major=$((major + 1)); minor=0; patch=0
7295
elif [ "$BUMP" = "minor" ]; then
@@ -76,8 +99,6 @@ jobs:
7699
fi
77100
78101
NEW_TAG="v$major.$minor.$patch"
79-
else
80-
NEW_TAG="${{ github.event.inputs.release_tag }}"
81102
fi
82103
echo "tag=$NEW_TAG" >> $GITHUB_OUTPUT
83104
echo "Using version: $NEW_TAG"
@@ -90,16 +111,6 @@ jobs:
90111
version: ${{ steps.bump_logic.outputs.tag }}
91112
tag: ${{ steps.bump_logic.outputs.tag }}
92113

93-
- name: Create GitHub Release
94-
if: steps.check.outputs.count > 0
95-
env:
96-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
97-
run: |
98-
gh release create "${{ steps.bump_logic.outputs.tag }}" \
99-
--title "${{ steps.bump_logic.outputs.tag }}" \
100-
--generate-notes \
101-
--draft
102-
103114
upload_assets:
104115
needs: prepare_release
105116
if: needs.prepare_release.outputs.should_release == 'true'
@@ -128,10 +139,13 @@ jobs:
128139
run: |
129140
cd src
130141
TAG="${{ needs.prepare_release.outputs.tag }}"
142+
131143
bazel build --show_timestamps --copt=-O3 --verbose_failures \
132144
-- //software:unix_full_system_tar_gen
133-
mv bazel-bin/software/unix_full_system_tar_gen.tar.gz "${{ runner.temp }}/unix_full_system_${{ needs.prepare_release.outputs.tag }}_${{ matrix.platform }}.tar.gz"
134-
gh release upload "$TAG" "${{ runner.temp }}/unix_full_system_${{ needs.prepare_release.outputs.tag }}_${{ matrix.platform }}.tar.gz"
145+
146+
ARTIFACT_NAME="unix_full_system_${TAG}_${{ matrix.platform }}.tar.gz"
147+
mv bazel-bin/software/unix_full_system_tar_gen.tar.gz "${{ runner.temp }}/$ARTIFACT_NAME"
148+
gh release upload "$TAG" "${{ runner.temp }}/$ARTIFACT_NAME"
135149
136150
publish_release:
137151
needs: [prepare_release, upload_assets]

0 commit comments

Comments
 (0)