Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 41 additions & 9 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ jobs:
check-changes:
name: Check for recent changes
runs-on: ubuntu-latest
permissions:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is tthis for?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put a check in front if release target exists, so that we don't run entire build for a release branch, only to fail it in the end, if it is already published

contents: read
outputs:
should_build: ${{ steps.decide.outputs.should_build }}
is_release: ${{ steps.decide.outputs.is_release }}
Expand Down Expand Up @@ -82,6 +84,31 @@ jobs:
echo "Skipping: no commits in last 24h, force=${FORCE}, release=${IS_RELEASE}"
fi

- name: Verify release target is available
if: steps.decide.outputs.is_release == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ steps.decide.outputs.release_tag }}
run: |
set -euo pipefail
existing_release=$(
gh api --paginate "repos/${GITHUB_REPOSITORY}/releases?per_page=100" \
--jq ".[] | select(.tag_name == \"${TAG}\") | [.id, .draft, .html_url] | @tsv"
)
if [ -n "$existing_release" ]; then
echo "::error::A draft or published release already targets ${TAG}. Delete an obsolete draft explicitly before rebuilding; published releases must not be replaced."
echo "$existing_release"
exit 1
fi
existing_tag=$(
gh api "repos/${GITHUB_REPOSITORY}/git/matching-refs/tags/${TAG}" \
--jq ".[] | select(.ref == \"refs/tags/${TAG}\") | .ref"
)
if [ -n "$existing_tag" ]; then
echo "::error::Git tag ${TAG} already exists. Refusing to move or replace it."
exit 1
fi

build-and-test:
name: "${{ matrix.name }}"
needs: check-changes
Expand Down Expand Up @@ -660,14 +687,8 @@ jobs:
actions: read
contents: write # Required by gh release create below.
steps:
- name: Download release artifacts
uses: actions/download-artifact@v8
with:
pattern: cuvslam-*
path: release-assets
merge-multiple: true

- name: Verify release does not already exist
# Recheck after the matrix to catch a release or tag created since preflight.
- name: Recheck release target is available
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ needs.check-changes.outputs.release_tag }}
Expand All @@ -682,11 +703,22 @@ jobs:
echo "$existing_release"
exit 1
fi
if gh api "repos/${GITHUB_REPOSITORY}/git/ref/tags/${TAG}" >/dev/null 2>&1; then
existing_tag=$(
gh api "repos/${GITHUB_REPOSITORY}/git/matching-refs/tags/${TAG}" \
--jq ".[] | select(.ref == \"refs/tags/${TAG}\") | .ref"
)
if [ -n "$existing_tag" ]; then
echo "::error::Git tag ${TAG} already exists. Refusing to move or replace it."
exit 1
fi

- name: Download release artifacts
uses: actions/download-artifact@v8
with:
pattern: cuvslam-*
path: release-assets
merge-multiple: true

- name: Validate release assets and prepare notes
env:
PACKAGE_VERSION: ${{ needs.check-changes.outputs.package_version }}
Expand Down
Loading