Repository navigation
Release Auto-Tag #139
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | |
| # SPDX-License-Identifier: Apache-2.0 | |
| name: Release Auto-Tag | |
| on: | |
| workflow_dispatch: {} | |
| schedule: | |
| - cron: "0 14 * * 1-5" | |
| timezone: "Europe/Zurich" | |
| permissions: | |
| contents: write | |
| actions: write | |
| concurrency: | |
| group: release-auto-tag | |
| cancel-in-progress: false | |
| jobs: | |
| create-tag: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| ref: main | |
| fetch-depth: 0 | |
| - name: Determine next pre-release version | |
| id: version | |
| run: | | |
| set -euo pipefail | |
| tags=$(git tag -l) | |
| latest=$(printf '%s\n' "$tags" | \ | |
| { grep -E '^v[0-9]+\.[0-9]+\.[0-9]+(-pre\.[1-9][0-9]*)?$' || true; } | \ | |
| sort -V | tail -1) | |
| if [[ ! "$latest" =~ ^(v[0-9]+\.[0-9]+\.[0-9]+)-pre\.([1-9][0-9]*)$ ]]; then | |
| echo "No active pre-release series — skipping tag creation" | |
| echo "skip=true" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| base=${BASH_REMATCH[1]} | |
| number=${BASH_REMATCH[2]} | |
| if ! git show-ref --verify --quiet "refs/tags/${base}-pre.1"; then | |
| echo "No ${base}-pre.1 seed — skipping tag creation" | |
| echo "skip=true" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| if git show-ref --verify --quiet "refs/tags/${base}"; then | |
| echo "$base is already stable — skipping tag creation" | |
| echo "skip=true" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| if ! git merge-base --is-ancestor "$latest" HEAD; then | |
| echo "::error::Latest pre-release $latest is not an ancestor of main" | |
| exit 1 | |
| fi | |
| echo "Latest tag: $latest" | |
| # Skip if no new commits since the latest tag | |
| commit_count=$(git rev-list "${latest}..HEAD" --count) | |
| echo "Commits since $latest: $commit_count" | |
| if [ "$commit_count" -eq 0 ]; then | |
| echo "No new commits since $latest — skipping tag creation" | |
| echo "skip=true" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| next="${base}-pre.$((number + 1))" | |
| if git tag -l "$next" | grep -q .; then | |
| echo "::error::Tag $next already exists" | |
| exit 1 | |
| fi | |
| echo "next=$next" >> "$GITHUB_OUTPUT" | |
| echo "Next tag: $next" | |
| - name: Create and push tag | |
| if: steps.version.outputs.skip != 'true' | |
| env: | |
| NEXT_TAG: ${{ steps.version.outputs.next }} | |
| run: | | |
| git tag "$NEXT_TAG" | |
| git push origin "refs/tags/$NEXT_TAG" | |
| - name: Trigger Release Tag workflow | |
| if: steps.version.outputs.skip != 'true' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| NEXT_TAG: ${{ steps.version.outputs.next }} | |
| run: | | |
| gh workflow run release-tag.yml \ | |
| --ref main \ | |
| -f tag="$NEXT_TAG" |