Skip to content

LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows

[MISC] Reject no-op OSS releases when there are no new commits (#2117)

Ritwik G0a997e9433fe
diff --git a/.github/workflows/create-release.yaml b/.github/workflows/create-release.yaml
index 3f913bbac..c30c43fe9 100644
--- a/.github/workflows/create-release.yaml
+++ b/.github/workflows/create-release.yaml
@@ -126,6 +126,38 @@ jobs:
echo "latest_tag=$LATEST_TAG" >> "$GITHUB_OUTPUT"
echo "Base release: $LATEST_TAG"
+ - name: Ensure there are new commits to release
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ LATEST_TAG: ${{ steps.get-latest.outputs.latest_tag }}
+ BRANCH: ${{ github.ref_name }}
+ DRY_RUN: ${{ github.event.inputs.dry_run }}
+ run: |
+ # Reject a no-op release: if the branch has no commits beyond the last release
+ # tag (e.g. main is already at v0.177.0), there is nothing to release. This
+ # prevents empty releases such as v0.177.1 pointing at the same commit as
+ # v0.177.0. The workflow has no local checkout, so use the compare API's
+ # `ahead_by` (commits on BRANCH not in LATEST_TAG). `// empty` stops a null/
+ # absent value from reaching the comparison as the literal "null"; we then
+ # require a non-negative integer and fail loudly on anything unexpected, so a
+ # transient API error is never mistaken for "no new commits".
+ AHEAD=$(gh api "repos/${{ github.repository }}/compare/${LATEST_TAG}...${BRANCH}" --jq '.ahead_by // empty') \
+ || { echo "::error::Could not query commits since $LATEST_TAG (compare API failed)."; exit 1; }
+ if ! [[ "$AHEAD" =~ ^[0-9]+$ ]]; then
+ echo "::error::Unexpected ahead_by='${AHEAD:-<empty>}' from compare ${LATEST_TAG}...${BRANCH}; refusing to guess."
+ exit 1
+ fi
+ if [[ "$AHEAD" == "0" ]]; then
+ if [[ "$DRY_RUN" == "true" ]]; then
+ echo "::warning::No new commits on '$BRANCH' since $LATEST_TAG — a real run would be rejected (nothing to release)."
+ else
+ echo "::error::No new commits on '$BRANCH' since $LATEST_TAG — nothing to release. Aborting to avoid an empty release."
+ exit 1
+ fi
+ else
+ echo "✅ $AHEAD new commit(s) on '$BRANCH' since $LATEST_TAG"
+ fi
+
- name: Compute next version
id: compute-version
env: