Skip to content

Commit 70914a8

Browse files
feat(release): add dual-tag system for OpenUPM compatibility
Create a second preview tag (e.g., v4.0.0-preview.146) alongside beta/alpha/rc tags so OpenUPM can publish Unity-compatible versions. Preview/pre/exp tags are detected and skipped to prevent re-trigger loops. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5e1375b commit 70914a8

File tree

1 file changed

+68
-8
lines changed

1 file changed

+68
-8
lines changed

.github/workflows/release.yml

Lines changed: 68 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ jobs:
3434
is_prerelease: ${{ steps.parse.outputs.is_prerelease }}
3535
release_type: ${{ steps.parse.outputs.release_type }}
3636
full_version: ${{ steps.parse.outputs.full_version }}
37+
unity_version: ${{ steps.parse.outputs.unity_version }}
38+
should_skip: ${{ steps.parse.outputs.should_skip }}
3739

3840
steps:
3941
- name: Parse version from tag
@@ -43,7 +45,15 @@ jobs:
4345
4446
TAG_NAME=${GITHUB_REF#refs/tags/}
4547
echo "Processing tag: $TAG_NAME"
46-
48+
49+
# Skip OpenUPM-only preview/pre/exp tags to prevent re-trigger loops
50+
if [[ $TAG_NAME =~ ^v[0-9]+\.[0-9]+\.[0-9]+-(preview|pre|exp)\.[0-9]+$ ]]; then
51+
echo "Skipping OpenUPM-only tag: $TAG_NAME"
52+
echo "should_skip=true" >> $GITHUB_OUTPUT
53+
exit 0
54+
fi
55+
echo "should_skip=false" >> $GITHUB_OUTPUT
56+
4757
# Security: Validate tag name doesn't contain dangerous characters
4858
if [[ $TAG_NAME =~ [\$\`\;\|\&] ]]; then
4959
echo "❌ Security: Tag contains dangerous characters: $TAG_NAME"
@@ -83,8 +93,22 @@ jobs:
8393
echo "is_prerelease=$IS_PRERELEASE" >> $GITHUB_OUTPUT
8494
echo "release_type=$RELEASE_TYPE" >> $GITHUB_OUTPUT
8595
echo "full_version=$FULL_VERSION" >> $GITHUB_OUTPUT
86-
87-
echo "✅ Valid version tag: $FULL_VERSION (prerelease: $IS_PRERELEASE)"
96+
97+
# Calculate Unity/OpenUPM-compatible version using offset system
98+
# alpha: 0-99, beta: 100-199, rc: 200-299
99+
if [[ "$IS_PRERELEASE" == "true" ]]; then
100+
case "$RELEASE_TYPE" in
101+
"alpha") PREVIEW_NUM=$((PRERELEASE_NUM)) ;;
102+
"beta") PREVIEW_NUM=$((100 + PRERELEASE_NUM)) ;;
103+
"rc") PREVIEW_NUM=$((200 + PRERELEASE_NUM)) ;;
104+
esac
105+
UNITY_VERSION="$VERSION-preview.$PREVIEW_NUM"
106+
else
107+
UNITY_VERSION="$VERSION"
108+
fi
109+
echo "unity_version=$UNITY_VERSION" >> $GITHUB_OUTPUT
110+
111+
echo "✅ Valid version tag: $FULL_VERSION (prerelease: $IS_PRERELEASE, unity: $UNITY_VERSION)"
88112
else
89113
echo "❌ Invalid tag format: $TAG_NAME"
90114
echo "Expected format: v1.2.3 or v1.2.3-beta.1"
@@ -95,6 +119,7 @@ jobs:
95119
name: Verify CI Status
96120
runs-on: ubuntu-latest
97121
needs: [validate-tag]
122+
if: needs.validate-tag.outputs.should_skip != 'true'
98123

99124
steps:
100125
- name: Checkout code
@@ -205,6 +230,7 @@ jobs:
205230
name: Update Version Files
206231
runs-on: ubuntu-latest
207232
needs: [validate-tag, verify-ci-status]
233+
if: needs.validate-tag.outputs.should_skip != 'true'
208234
outputs:
209235
commit_sha: ${{ steps.commit.outputs.commit_sha }}
210236

@@ -357,7 +383,8 @@ jobs:
357383
name: Build Release Artifacts
358384
runs-on: ubuntu-latest
359385
needs: [validate-tag, verify-ci-status, update-versions]
360-
386+
if: needs.validate-tag.outputs.should_skip != 'true'
387+
361388
defaults:
362389
run:
363390
working-directory: ./src
@@ -484,8 +511,36 @@ jobs:
484511
485512
tag_attempt=$((tag_attempt + 1))
486513
done
514+
515+
# Create OpenUPM-compatible preview tag for pre-releases
516+
if [[ "$IS_PRERELEASE" == "true" ]]; then
517+
UNITY_VERSION="${{ needs.validate-tag.outputs.unity_version }}"
518+
UNITY_TAG="v$UNITY_VERSION"
519+
520+
# Remove existing preview tag if present (from a previous failed run)
521+
git push origin --delete "$UNITY_TAG" 2>/dev/null || true
522+
git tag -d "$UNITY_TAG" 2>/dev/null || true
523+
524+
git tag -a "$UNITY_TAG" -m "Release $UNITY_TAG (Unity/OpenUPM)" "$UNITY_DLL_COMMIT"
525+
526+
# Push with retry (non-blocking: failure does NOT fail the release)
527+
preview_attempts=3; preview_attempt=1; preview_delay=5
528+
while [ $preview_attempt -le $preview_attempts ]; do
529+
if git push origin "$UNITY_TAG"; then
530+
echo "✅ Created OpenUPM tag $UNITY_TAG pointing to $UNITY_DLL_COMMIT"
531+
break
532+
fi
533+
if [ $preview_attempt -lt $preview_attempts ]; then
534+
sleep $preview_delay; preview_delay=$((preview_delay * 2))
535+
else
536+
echo "⚠️ Failed to push OpenUPM tag. Manual fix:"
537+
echo " git tag -a $UNITY_TAG -m 'Release $UNITY_TAG' $UNITY_DLL_COMMIT && git push origin $UNITY_TAG"
538+
fi
539+
preview_attempt=$((preview_attempt + 1))
540+
done
541+
fi
487542
fi
488-
543+
489544
# Always clean up the temporary branch (whether push succeeded or failed)
490545
echo "🧹 Cleaning up temporary branch..."
491546
if git push origin --delete temp-unity-dll-update 2>/dev/null; then
@@ -523,6 +578,7 @@ jobs:
523578
name: Create GitHub Release
524579
runs-on: ubuntu-latest
525580
needs: [validate-tag, build-release, update-versions]
581+
if: needs.validate-tag.outputs.should_skip != 'true'
526582
outputs:
527583
release_url: ${{ steps.create_release.outputs.html_url }}
528584

@@ -900,6 +956,7 @@ jobs:
900956
name: Publish to NuGet
901957
runs-on: ubuntu-latest
902958
needs: [validate-tag, create-release]
959+
if: needs.validate-tag.outputs.should_skip != 'true'
903960
environment:
904961
name: nuget-production
905962
url: https://www.nuget.org/packages/Nino
@@ -978,7 +1035,7 @@ jobs:
9781035
name: Trigger Benchmark
9791036
runs-on: ubuntu-latest
9801037
needs: [validate-tag, create-release]
981-
if: success()
1038+
if: success() && needs.validate-tag.outputs.should_skip != 'true'
9821039

9831040
steps:
9841041
- name: Trigger benchmark workflow
@@ -1000,7 +1057,7 @@ jobs:
10001057
name: Notify Release Completion
10011058
runs-on: ubuntu-latest
10021059
needs: [validate-tag, create-release, publish-nuget, trigger-benchmark, cleanup-release-branches]
1003-
if: always()
1060+
if: always() && needs.validate-tag.outputs.should_skip != 'true'
10041061

10051062
steps:
10061063
- name: Release Summary
@@ -1010,6 +1067,9 @@ jobs:
10101067
echo "- **Version**: ${{ needs.validate-tag.outputs.version }}" >> $GITHUB_STEP_SUMMARY
10111068
echo "- **Type**: ${{ needs.validate-tag.outputs.release_type }}" >> $GITHUB_STEP_SUMMARY
10121069
echo "- **Prerelease**: ${{ needs.validate-tag.outputs.is_prerelease }}" >> $GITHUB_STEP_SUMMARY
1070+
if [[ "${{ needs.validate-tag.outputs.is_prerelease }}" == "true" ]]; then
1071+
echo "- **OpenUPM Tag**: v${{ needs.validate-tag.outputs.unity_version }}" >> $GITHUB_STEP_SUMMARY
1072+
fi
10131073
echo "- **Release URL**: ${{ needs.create-release.outputs.release_url }}" >> $GITHUB_STEP_SUMMARY
10141074
echo "" >> $GITHUB_STEP_SUMMARY
10151075
@@ -1029,7 +1089,7 @@ jobs:
10291089
name: Cleanup Old Release Branches
10301090
runs-on: ubuntu-latest
10311091
needs: [validate-tag, create-release]
1032-
if: success()
1092+
if: success() && needs.validate-tag.outputs.should_skip != 'true'
10331093

10341094
steps:
10351095
- name: Checkout code

0 commit comments

Comments
 (0)