|
| 1 | +name: Create TOX Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + |
| 8 | + |
| 9 | +jobs: |
| 10 | + Build_tox: |
| 11 | + runs-on: [self-hosted, Windows, TouchDesigner] |
| 12 | + steps: |
| 13 | + - name: Check out repository code |
| 14 | + uses: actions/checkout@v4 |
| 15 | + with: |
| 16 | + fetch-depth: 0 |
| 17 | + fetch-tags: true |
| 18 | + submodules: true |
| 19 | + |
| 20 | + - name: SudoMagic TD Package Builder |
| 21 | + uses: SudoMagicCode/action-build-td-tox-package@v0.0.5 |
| 22 | + with: |
| 23 | + build_settings: ./buildSettings.json |
| 24 | + |
| 25 | + - name: Generate Hybrid Version |
| 26 | + id: semver |
| 27 | + run: | |
| 28 | + # This pattern matches v, digits, a literal dot, and digits. |
| 29 | + # It effectively blocks v1.0.1 because the * after the second number |
| 30 | + # would usually allow another dot, but we want to anchor strictly. |
| 31 | + $BASE_TAG = git describe --tags --abbrev=0 --match "v[0-9]*.[0-9]*" --exclude "v*.*.*" 2>$null |
| 32 | + |
| 33 | + if ($LASTEXITCODE -ne 0) { |
| 34 | + Write-Host "No base tag found, defaulting to v0.0" |
| 35 | + $BASE_TAG = "v0.0" |
| 36 | + } |
| 37 | +
|
| 38 | + # 2. Count commits since that base tag. |
| 39 | + # If the current commit is the tag itself, COUNT will be 0. |
| 40 | + if ($BASE_TAG -eq "v0.0") { |
| 41 | + $COUNT = git rev-list --count HEAD |
| 42 | + } else { |
| 43 | + $COUNT = git rev-list --count "$($BASE_TAG)..HEAD" |
| 44 | + } |
| 45 | +
|
| 46 | + # 3. Construct the hybrid VERSION (vX.Y.Z) |
| 47 | + $VERSION = "$BASE_TAG.$COUNT" |
| 48 | + |
| 49 | + Write-Host "Base Tag: $BASE_TAG" |
| 50 | + Write-Host "Commits since base: $COUNT" |
| 51 | + Write-Host "Final Release Version: $VERSION" |
| 52 | + |
| 53 | + echo "VERSION=$VERSION" >> $env:GITHUB_OUTPUT |
| 54 | + |
| 55 | + - name: Create Github Release |
| 56 | + uses: softprops/action-gh-release@v2 |
| 57 | + with: |
| 58 | + tag_name: ${{ steps.semver.outputs.VERSION }} |
| 59 | + name: Release ${{ steps.semver.outputs.VERSION }} |
| 60 | + # Generates "What's Changed" section automatically from PRs/commits |
| 61 | + generate_release_notes: true |
| 62 | + # Set to true if you want it to stay hidden until you review it |
| 63 | + draft: false |
| 64 | + prerelease: false |
| 65 | + files: ./release/package.zip |
0 commit comments