-
Notifications
You must be signed in to change notification settings - Fork 128
Release Cron Fix #3595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Release Cron Fix #3595
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,30 +43,53 @@ jobs: | |
| - name: Check for recent commits | ||
| id: check | ||
| run: | | ||
| git fetch --tags | ||
|
|
||
| LATEST_TAG=$(git describe --tags --match "v[0-9]*" --abbrev=0 2>/dev/null || echo "v0.0.0") | ||
| echo "Latest tag: $LATEST_TAG" | ||
|
|
||
| # Prevent double release on the same day (unless manual dispatch) | ||
| if [ "${{ github.event_name }}" != "workflow_dispatch" ] && [ "$LATEST_TAG" != "v0.0.0" ]; then | ||
| TAG_DATE=$(git log -1 --format=%as "$LATEST_TAG") | ||
| TODAY=$(date +%Y-%m-%d) | ||
| echo "Tag Date: $TAG_DATE, Today: $TODAY" | ||
|
|
||
| if [ "$TAG_DATE" = "$TODAY" ]; then | ||
| echo "Already released $LATEST_TAG today. Skipping." | ||
| echo "count=0" >> $GITHUB_OUTPUT | ||
| exit 0 | ||
| fi | ||
| fi | ||
|
|
||
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | ||
| echo "count=1" >> $GITHUB_OUTPUT | ||
| else | ||
| COUNT=$(git log --since="1 week ago" --oneline | wc -l) | ||
| if [ "$LATEST_TAG" = "v0.0.0" ]; then | ||
| COUNT=$(git log --oneline | wc -l) | ||
| else | ||
| COUNT=$(git log "$LATEST_TAG"..HEAD --oneline | wc -l) | ||
| fi | ||
| echo "count=$COUNT" >> $GITHUB_OUTPUT | ||
| fi | ||
|
|
||
| - name: Determine Version Bump | ||
| if: steps.check.outputs.count > 0 | ||
| id: bump_logic | ||
| run: | | ||
| if [ "${{ github.event.inputs.release_tag }}" = "" ]; then | ||
| LATEST_TAG=$(git describe --tags --match "v[0-9]*" --abbrev=0 2>/dev/null || echo "v1.0.0") | ||
| BASE_VERSION=${LATEST_TAG#v} | ||
|
|
||
| IFS='.' read -r major minor patch <<< "$BASE_VERSION" | ||
|
|
||
| if [ "${{ github.event.inputs.release_tag }}" != "" ]; then | ||
| NEW_TAG="${{ github.event.inputs.release_tag }}" | ||
| else | ||
| BUMP="patch" | ||
| if [ "$(date +%d)" = "01" ]; then BUMP="minor"; fi | ||
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | ||
| BUMP="${{ github.event.inputs.version_type }}" | ||
| fi | ||
|
|
||
| LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v1.0.0") | ||
| # Strip the 'v' prefix | ||
| BASE_VERSION=${LATEST_TAG#v} | ||
|
|
||
| IFS='.' read -r major minor patch <<< "$BASE_VERSION" | ||
|
|
||
| if [ "$BUMP" = "major" ]; then | ||
| major=$((major + 1)); minor=0; patch=0 | ||
| elif [ "$BUMP" = "minor" ]; then | ||
|
|
@@ -76,8 +99,6 @@ jobs: | |
| fi | ||
|
|
||
| NEW_TAG="v$major.$minor.$patch" | ||
| else | ||
| NEW_TAG="${{ github.event.inputs.release_tag }}" | ||
| fi | ||
| echo "tag=$NEW_TAG" >> $GITHUB_OUTPUT | ||
| echo "Using version: $NEW_TAG" | ||
|
|
@@ -90,16 +111,6 @@ jobs: | |
| version: ${{ steps.bump_logic.outputs.tag }} | ||
| tag: ${{ steps.bump_logic.outputs.tag }} | ||
|
|
||
| - name: Create GitHub Release | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: why do we no longer need to do this?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm more confused as to why it was necessary in the first place. Isn't it being released in the later code anyways? To be honest, I don't really understand the way CI works here
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So the problem I encountered was that if you try and create a release directly, it won't allow you to append multiple files to the output. You have to create a draft release and attach all the files to it, then release it. Not sure if your fix will run into this issue, but that's why it was there in the first place. |
||
| if: steps.check.outputs.count > 0 | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| gh release create "${{ steps.bump_logic.outputs.tag }}" \ | ||
| --title "${{ steps.bump_logic.outputs.tag }}" \ | ||
| --generate-notes \ | ||
| --draft | ||
|
|
||
| upload_assets: | ||
| needs: prepare_release | ||
| if: needs.prepare_release.outputs.should_release == 'true' | ||
|
|
@@ -128,10 +139,13 @@ jobs: | |
| run: | | ||
| cd src | ||
| TAG="${{ needs.prepare_release.outputs.tag }}" | ||
|
|
||
| bazel build --show_timestamps --copt=-O3 --verbose_failures \ | ||
| -- //software:unix_full_system_tar_gen | ||
| 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" | ||
| gh release upload "$TAG" "${{ runner.temp }}/unix_full_system_${{ needs.prepare_release.outputs.tag }}_${{ matrix.platform }}.tar.gz" | ||
|
|
||
| ARTIFACT_NAME="unix_full_system_${TAG}_${{ matrix.platform }}.tar.gz" | ||
| mv bazel-bin/software/unix_full_system_tar_gen.tar.gz "${{ runner.temp }}/$ARTIFACT_NAME" | ||
| gh release upload "$TAG" "${{ runner.temp }}/$ARTIFACT_NAME" | ||
|
|
||
| publish_release: | ||
| needs: [prepare_release, upload_assets] | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: will we encounter this case? i assume if the daily intersects with the less frequent releases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is to prevent double release when Sunday lines up with first of the month.