Release v1.7.0 #4
Workflow file for this run
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
| name: Release on Merge | |
| on: | |
| pull_request: | |
| types: [closed] | |
| branches: [main] | |
| jobs: | |
| release: | |
| name: Create Release | |
| if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.title, 'Release v') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| lfs: true | |
| fetch-depth: 0 | |
| - name: Extract version | |
| id: version | |
| run: | | |
| PR_TITLE="${{ github.event.pull_request.title }}" | |
| if [[ "$PR_TITLE" =~ ^Release\ v([0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+(\.[0-9]+)?)?)$ ]]; then | |
| VERSION="${BASH_REMATCH[1]}" | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "tag=v$VERSION" >> $GITHUB_OUTPUT | |
| echo "Detected version: $VERSION" | |
| else | |
| echo "❌ Could not extract version from PR title: $PR_TITLE" | |
| echo "Expected format: 'Release vX.Y.Z' or 'Release vX.Y.Z-prerelease'" | |
| exit 1 | |
| fi | |
| - name: Verify version in package.json | |
| run: | | |
| PACKAGE_VERSION=$(jq -r '.version' package.json) | |
| EXPECTED_VERSION="${{ steps.version.outputs.version }}" | |
| if [ "$PACKAGE_VERSION" != "$EXPECTED_VERSION" ]; then | |
| echo "❌ Version mismatch! Expected $EXPECTED_VERSION but found $PACKAGE_VERSION in package.json" | |
| exit 1 | |
| fi | |
| echo "✅ Version verified: $PACKAGE_VERSION" | |
| - name: Create and push tag | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| git tag -a "${{ steps.version.outputs.tag }}" -m "Release ${{ steps.version.outputs.tag }}" | |
| git push origin "${{ steps.version.outputs.tag }}" | |
| - name: Generate changelog | |
| run: | | |
| TAG="${{ steps.version.outputs.tag }}" | |
| PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD~1 2>/dev/null || echo "") | |
| echo "# Release $TAG" > RELEASE_NOTES.md | |
| echo "" >> RELEASE_NOTES.md | |
| if [ -n "$PREVIOUS_TAG" ]; then | |
| echo "## Changes since $PREVIOUS_TAG" >> RELEASE_NOTES.md | |
| echo "" >> RELEASE_NOTES.md | |
| git log --pretty=format:"- %s ([%h](https://github.com/${{ github.repository }}/commit/%H))" $PREVIOUS_TAG..HEAD >> RELEASE_NOTES.md | |
| else | |
| echo "## Initial Release" >> RELEASE_NOTES.md | |
| echo "" >> RELEASE_NOTES.md | |
| echo "This is the initial release of the Dojo Unity SDK." >> RELEASE_NOTES.md | |
| fi | |
| echo "" >> RELEASE_NOTES.md | |
| echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/$PREVIOUS_TAG...$TAG" >> RELEASE_NOTES.md | |
| # Git LFS setup | |
| - name: Setup Git LFS | |
| run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id | |
| - name: Cache Git LFS | |
| uses: actions/cache@v4 | |
| with: | |
| path: .git/lfs | |
| key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }} | |
| - name: Git LFS Pull | |
| run: | | |
| git lfs pull | |
| git add . | |
| git reset --hard | |
| # Unity Cache | |
| - name: Cache Unity Library | |
| uses: actions/cache@v4 | |
| with: | |
| path: Library | |
| key: Library-${{ runner.os }}-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }} | |
| restore-keys: | | |
| Library-${{ runner.os }}- | |
| # Build Unity Package | |
| - name: Build Unity Package | |
| uses: game-ci/unity-builder@v4 | |
| env: | |
| UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} | |
| UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} | |
| UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} | |
| with: | |
| targetPlatform: StandaloneLinux64 | |
| buildMethod: Editor.Builder.BuildPackage | |
| - name: Create Draft Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: ${{ steps.version.outputs.tag }} | |
| name: Release ${{ steps.version.outputs.tag }} | |
| body_path: RELEASE_NOTES.md | |
| draft: true | |
| files: | | |
| ./Build/dojo.unitypackage | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Comment on PR | |
| uses: peter-evans/create-or-update-comment@v3 | |
| with: | |
| issue-number: ${{ github.event.pull_request.number }} | |
| body: | | |
| 🎉 **Release Created Successfully!** | |
| **Version:** ${{ steps.version.outputs.tag }} | |
| **Release:** [Draft Release](https://github.com/${{ github.repository }}/releases/tag/${{ steps.version.outputs.tag }}) | |
| ### ✅ Completed: | |
| - Git tag `${{ steps.version.outputs.tag }}` created and pushed | |
| - Unity package built and uploaded | |
| - Draft release created with changelog | |
| ### 🚀 Next Steps: | |
| **[Review and publish the release](https://github.com/${{ github.repository }}/releases/tag/${{ steps.version.outputs.tag }})** when ready! |