From 55264ea14937e261d3e1601f73914a994898919d Mon Sep 17 00:00:00 2001 From: Nasr Date: Tue, 26 Aug 2025 15:58:37 +0100 Subject: [PATCH 1/2] chore(workflows): prepare release --- .github/workflows/README.md | 192 ++++++++++++++++++++++ .github/workflows/manual-release.yml | 148 +++++++++++++++++ .github/workflows/prepare-release.yml | 206 +++++++++++++++++++++++ .github/workflows/release-on-merge.yml | 217 +++++++++++++++++++++++++ .github/workflows/release.yml | 45 +++-- 5 files changed, 797 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/README.md create mode 100644 .github/workflows/manual-release.yml create mode 100644 .github/workflows/prepare-release.yml create mode 100644 .github/workflows/release-on-merge.yml diff --git a/.github/workflows/README.md b/.github/workflows/README.md new file mode 100644 index 00000000..8f3933ae --- /dev/null +++ b/.github/workflows/README.md @@ -0,0 +1,192 @@ +# GitHub Workflows for Dojo Unity SDK + +This directory contains the GitHub Actions workflows for managing releases and CI/CD for the Dojo Unity SDK. + +## Workflows Overview + +### 1. `prepare-release.yml` - Prepare Release +**Trigger:** Manual workflow dispatch +**Purpose:** Prepares a new release by updating version numbers and creating a PR + +**Usage:** +```bash +# Go to Actions tab → Prepare Release → Run workflow +# Choose version bump type: patch, minor, or major +# Or provide a custom version override +``` + +**What it does:** +- ✅ Updates `package.json` version +- ✅ Updates Unity package files +- ✅ Creates a release branch (`release/vX.X.X`) +- ✅ Generates changelog from git commits +- ✅ Creates a PR with all changes +- ✅ Adds helpful comments and labels + +### 2. `release-on-merge.yml` - Create Release on Merge +**Trigger:** Automatic when release PR is merged to main +**Purpose:** Automatically creates a draft release when a release PR is merged + +**What it does:** +- ✅ Detects release PRs (title: "Release vX.X.X" or branch: "release/vX.X.X") +- ✅ Verifies version consistency +- ✅ Creates and pushes git tag +- ✅ Builds Unity package +- ✅ Creates draft release with changelog +- ✅ Uploads Unity package to release +- ✅ Comments on the merged PR with next steps + +### 3. `manual-release.yml` - Manual Release +**Trigger:** Manual workflow dispatch +**Purpose:** Create a release manually for an existing tag + +**Usage:** +```bash +# Go to Actions tab → Manual Release → Run workflow +# Provide the tag (e.g., v1.4.0) +# Choose draft/prerelease options +``` + +### 4. `release.yml` - Legacy Release Build +**Trigger:** Automatic when a release is published (not draft) +**Purpose:** Builds and uploads Unity package to published releases + +**What it does:** +- ✅ Builds Unity package when release is published +- ✅ Uploads package with versioned filename + +## Complete Release Process + +### Option A: Automated Release Process (Recommended) + +1. **Prepare Release** + ```bash + # Go to GitHub Actions → Prepare Release → Run workflow + # Select version bump type or provide custom version + ``` + +2. **Review and Merge PR** + - Review the automatically created PR + - Check version updates and changelog + - Merge the PR to main + +3. **Publish Release** + - A draft release is automatically created + - Review the draft release + - Click "Publish release" when ready + +### Option B: Manual Release Process + +1. **Update version manually** in `package.json` +2. **Create and push tag** + ```bash + git tag -a v1.4.0 -m "Release v1.4.0" + git push origin v1.4.0 + ``` +3. **Run Manual Release workflow** + - Go to Actions → Manual Release + - Provide the tag name + - Choose options and run + +## Workflow Features + +### 🚀 Version Management +- Automatic semantic versioning (patch/minor/major) +- Custom version override support +- Consistent version updates across all files + +### 📋 Changelog Generation +- Automatic changelog from git commits +- Categorized by commit types (features, fixes, docs) +- Links to commits and comparisons + +### 🏷️ Git Tagging +- Automatic tag creation and pushing +- Annotated tags with release messages +- Tag verification and validation + +### 📦 Unity Package Building +- Automatic Unity package compilation +- LFS support for large assets +- Caching for faster builds +- Versioned package filenames + +### 🔄 PR Management +- Automatic PR creation for releases +- Helpful descriptions and comments +- Proper labeling and reviewer assignment +- Status updates throughout process + +## Configuration Requirements + +### Repository Secrets +Make sure these secrets are configured in your repository: + +- `UNITY_LICENSE` - Your Unity license +- `UNITY_EMAIL` - Unity account email +- `UNITY_PASSWORD` - Unity account password +- `GITHUB_TOKEN` - Automatically provided by GitHub + +### Permissions +The workflows require these permissions: +- Contents: write (for creating tags and releases) +- Pull requests: write (for creating PRs) +- Actions: read (for workflow status) + +## File Structure + +``` +.github/workflows/ +├── README.md # This file +├── prepare-release.yml # Prepare new release +├── release-on-merge.yml # Auto-create release on merge +├── manual-release.yml # Manual release creation +├── release.yml # Legacy release build +├── ci.yml # Existing CI workflow +└── dojoc.yml # Existing dojo.c workflow +``` + +## Troubleshooting + +### Common Issues + +1. **Version mismatch error** + - Ensure package.json version matches the expected version + - Check that the release PR was merged properly + +2. **Unity build fails** + - Check Unity license secrets + - Verify Unity project configuration + - Check for compilation errors in Unity + +3. **Tag already exists** + - Use a different version number + - Delete the existing tag if needed: `git tag -d v1.4.0 && git push origin :refs/tags/v1.4.0` + +4. **PR not detected as release PR** + - Ensure PR title follows format: "Release vX.X.X" + - Or use branch name format: "release/vX.X.X" + +### Debug Tips + +- Check workflow logs in the Actions tab +- Verify repository permissions and secrets +- Test with a patch version first +- Use draft releases for testing + +## Customization + +To customize the workflows for your needs: + +1. **Changelog format** - Edit the changelog generation sections +2. **Version files** - Add more files to update in `prepare-release.yml` +3. **Build process** - Modify the Unity build steps +4. **Notifications** - Add Slack/Discord notifications +5. **Validation** - Add additional checks and tests + +## Support + +For issues with these workflows: +1. Check the workflow logs in GitHub Actions +2. Review this README for configuration requirements +3. Open an issue with workflow logs and error details diff --git a/.github/workflows/manual-release.yml b/.github/workflows/manual-release.yml new file mode 100644 index 00000000..a4f862fd --- /dev/null +++ b/.github/workflows/manual-release.yml @@ -0,0 +1,148 @@ +name: Manual Release + +on: + workflow_dispatch: + inputs: + tag: + description: 'Release tag (e.g., v1.4.0)' + required: true + type: string + prerelease: + description: 'Mark as pre-release' + required: false + default: false + type: boolean + draft: + description: 'Create as draft' + required: false + default: true + type: boolean + +jobs: + manual-release: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + fetch-depth: 0 + + - name: Validate tag format + run: | + TAG="${{ github.event.inputs.tag }}" + if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "❌ Invalid tag format. Expected format: v1.2.3" + exit 1 + fi + echo "✅ Tag format is valid: $TAG" + + - name: Check if tag exists + run: | + TAG="${{ github.event.inputs.tag }}" + if git rev-parse "$TAG" >/dev/null 2>&1; then + echo "✅ Tag $TAG exists" + else + echo "❌ Tag $TAG does not exist. Please create the tag first or use the prepare-release workflow." + exit 1 + fi + + - name: Generate changelog + id: changelog + run: | + TAG="${{ github.event.inputs.tag }}" + + echo "# Release $TAG" > CHANGELOG.md + echo "" >> CHANGELOG.md + + # Get the previous tag + PREVIOUS_TAG=$(git describe --tags --abbrev=0 $TAG~1 2>/dev/null || echo "") + + if [ -n "$PREVIOUS_TAG" ]; then + echo "## Changes since $PREVIOUS_TAG" >> CHANGELOG.md + echo "" >> CHANGELOG.md + git log --pretty=format:"- %s ([%h](https://github.com/${{ github.repository }}/commit/%H))" $PREVIOUS_TAG..$TAG >> CHANGELOG.md + else + echo "## Initial Release" >> CHANGELOG.md + echo "" >> CHANGELOG.md + echo "This is the initial release of the Dojo Unity SDK." >> CHANGELOG.md + fi + + echo "" >> CHANGELOG.md + echo "---" >> CHANGELOG.md + echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/$PREVIOUS_TAG...$TAG" >> CHANGELOG.md + + { + echo 'changelog<> $GITHUB_OUTPUT + + # Git LFS setup + - name: Create LFS file list + run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id + + - name: Restore LFS cache + uses: actions/cache@v3 + id: lfs-cache + 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 + - uses: actions/cache@v3 + with: + path: Library + key: Library-Build-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }} + restore-keys: | + Library-Build- + + # 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 Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.event.inputs.tag }} + release_name: Release ${{ github.event.inputs.tag }} + body: ${{ steps.changelog.outputs.changelog }} + draft: ${{ github.event.inputs.draft }} + prerelease: ${{ github.event.inputs.prerelease }} + + - name: Upload Unity Package to Release + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./Build/dojo.unitypackage + asset_name: dojo-${{ github.event.inputs.tag }}.unitypackage + asset_content_type: application/octet-stream + + - name: Release Summary + run: | + echo "🎉 **Manual Release Created!**" + echo "" + echo "**Tag:** ${{ github.event.inputs.tag }}" + echo "**Draft:** ${{ github.event.inputs.draft }}" + echo "**Pre-release:** ${{ github.event.inputs.prerelease }}" + echo "**Release URL:** https://github.com/${{ github.repository }}/releases/tag/${{ github.event.inputs.tag }}" + echo "" + echo "The Unity package has been built and attached to the release." diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml new file mode 100644 index 00000000..6c332723 --- /dev/null +++ b/.github/workflows/prepare-release.yml @@ -0,0 +1,206 @@ +name: Prepare Release + +on: + workflow_dispatch: + inputs: + version_type: + description: 'Version bump type' + required: true + default: 'patch' + type: choice + options: + - patch + - minor + - major + version_override: + description: 'Override version (optional, e.g., 1.4.0)' + required: false + type: string + +jobs: + prepare-release: + runs-on: ubuntu-latest + outputs: + new_version: ${{ steps.version.outputs.new_version }} + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + fetch-depth: 0 + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: '18' + + - name: Configure Git + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + + - name: Get current version + id: current_version + run: | + CURRENT_VERSION=$(jq -r '.version' package.json) + echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT + echo "Current version: $CURRENT_VERSION" + + - name: Calculate new version + id: version + run: | + CURRENT_VERSION="${{ steps.current_version.outputs.current_version }}" + + if [ -n "${{ github.event.inputs.version_override }}" ]; then + NEW_VERSION="${{ github.event.inputs.version_override }}" + echo "Using override version: $NEW_VERSION" + else + # Parse current version + IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_VERSION" + MAJOR=${VERSION_PARTS[0]} + MINOR=${VERSION_PARTS[1]} + PATCH=${VERSION_PARTS[2]} + + # Bump version based on type + case "${{ github.event.inputs.version_type }}" in + "major") + MAJOR=$((MAJOR + 1)) + MINOR=0 + PATCH=0 + ;; + "minor") + MINOR=$((MINOR + 1)) + PATCH=0 + ;; + "patch") + PATCH=$((PATCH + 1)) + ;; + esac + + NEW_VERSION="$MAJOR.$MINOR.$PATCH" + fi + + echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT + echo "New version: $NEW_VERSION" + + - name: Create release branch + run: | + BRANCH_NAME="release/v${{ steps.version.outputs.new_version }}" + git checkout -b "$BRANCH_NAME" + echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV + + - name: Update package.json version + run: | + NEW_VERSION="${{ steps.version.outputs.new_version }}" + jq --arg version "$NEW_VERSION" '.version = $version' package.json > package.json.tmp + mv package.json.tmp package.json + echo "Updated package.json to version $NEW_VERSION" + + - name: Update Unity package.json files + run: | + NEW_VERSION="${{ steps.version.outputs.new_version }}" + + # Update WebGL template package.json if it exists + if [ -f "Assets/WebGLTemplates/Dojo/TemplateData/dojo.js/package.json" ]; then + jq --arg version "$NEW_VERSION" '.version = $version' "Assets/WebGLTemplates/Dojo/TemplateData/dojo.js/package.json" > temp.json + mv temp.json "Assets/WebGLTemplates/Dojo/TemplateData/dojo.js/package.json" + echo "Updated WebGL template package.json" + fi + + # Update artifact package.json if it exists + if [ -f "artifacts/wasm-artifact/package.json" ]; then + jq --arg version "$NEW_VERSION" '.version = $version' "artifacts/wasm-artifact/package.json" > temp.json + mv temp.json "artifacts/wasm-artifact/package.json" + echo "Updated artifacts package.json" + fi + + - name: Generate changelog + id: changelog + run: | + NEW_VERSION="${{ steps.version.outputs.new_version }}" + CURRENT_VERSION="${{ steps.current_version.outputs.current_version }}" + + echo "## Changes in v$NEW_VERSION" > RELEASE_NOTES.md + echo "" >> RELEASE_NOTES.md + + # Get commits since last tag + LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") + if [ -n "$LAST_TAG" ]; then + echo "### Commits since $LAST_TAG:" >> RELEASE_NOTES.md + git log --pretty=format:"- %s (%h)" $LAST_TAG..HEAD >> RELEASE_NOTES.md + else + echo "### Recent commits:" >> RELEASE_NOTES.md + git log --pretty=format:"- %s (%h)" -10 >> RELEASE_NOTES.md + fi + + echo "" >> RELEASE_NOTES.md + echo "### Version Bump" >> RELEASE_NOTES.md + echo "- Updated from v$CURRENT_VERSION to v$NEW_VERSION" >> RELEASE_NOTES.md + + # Set output for PR description + { + echo 'changelog<> $GITHUB_OUTPUT + + - name: Commit changes + run: | + git add . + git commit -m "chore: bump version to ${{ steps.version.outputs.new_version }}" + git push origin "$BRANCH_NAME" + + - name: Create Pull Request + id: create_pr + uses: peter-evans/create-pull-request@v5 + with: + token: ${{ secrets.GITHUB_TOKEN }} + branch: ${{ env.BRANCH_NAME }} + title: "Release v${{ steps.version.outputs.new_version }}" + body: | + ## Release Preparation for v${{ steps.version.outputs.new_version }} + + This PR prepares the release for version ${{ steps.version.outputs.new_version }}. + + ### Changes: + - ✅ Updated package.json version to ${{ steps.version.outputs.new_version }} + - ✅ Updated Unity package files + - ✅ Generated changelog + + ### Next Steps: + 1. Review and merge this PR + 2. The release workflow will automatically trigger to create a draft release + 3. Review and publish the release + + --- + + ${{ steps.changelog.outputs.changelog }} + labels: | + release + automated + reviewers: | + ${{ github.actor }} + + - name: Comment on PR + if: steps.create_pr.outputs.pull-request-number + uses: peter-evans/create-or-update-comment@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + issue-number: ${{ steps.create_pr.outputs.pull-request-number }} + body: | + 🚀 **Release Preparation Complete!** + + **Version:** v${{ steps.version.outputs.new_version }} + **Type:** ${{ github.event.inputs.version_type }} bump + + **What happens next:** + 1. ✅ This PR contains all version updates + 2. 🔍 Review the changes in this PR + 3. ✅ Merge this PR to trigger the release workflow + 4. 📦 A draft release will be automatically created + 5. 🎉 Publish the release when ready + + The release workflow will automatically: + - Create a git tag + - Build the Unity package + - Create a draft release with the changelog diff --git a/.github/workflows/release-on-merge.yml b/.github/workflows/release-on-merge.yml new file mode 100644 index 00000000..bf69b07a --- /dev/null +++ b/.github/workflows/release-on-merge.yml @@ -0,0 +1,217 @@ +name: Create Release on Merge + +on: + pull_request: + types: [closed] + branches: [main] + +jobs: + check-release-pr: + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + outputs: + is_release_pr: ${{ steps.check.outputs.is_release_pr }} + version: ${{ steps.check.outputs.version }} + steps: + - name: Check if this is a release PR + id: check + run: | + PR_TITLE="${{ github.event.pull_request.title }}" + PR_BRANCH="${{ github.event.pull_request.head.ref }}" + + echo "PR Title: $PR_TITLE" + echo "PR Branch: $PR_BRANCH" + + # Check if this is a release PR (title starts with "Release v" or branch starts with "release/") + if [[ "$PR_TITLE" =~ ^Release\ v[0-9]+\.[0-9]+\.[0-9]+$ ]] || [[ "$PR_BRANCH" =~ ^release/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "is_release_pr=true" >> $GITHUB_OUTPUT + + # Extract version from title or branch + if [[ "$PR_TITLE" =~ ^Release\ v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then + VERSION="${BASH_REMATCH[1]}" + elif [[ "$PR_BRANCH" =~ ^release/v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then + VERSION="${BASH_REMATCH[1]}" + fi + + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "Detected release PR for version: $VERSION" + else + echo "is_release_pr=false" >> $GITHUB_OUTPUT + echo "Not a release PR" + fi + + create-release: + needs: check-release-pr + if: needs.check-release-pr.outputs.is_release_pr == 'true' + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + fetch-depth: 0 + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: '18' + + - name: Verify version in package.json + id: verify_version + run: | + PACKAGE_VERSION=$(jq -r '.version' package.json) + EXPECTED_VERSION="${{ needs.check-release-pr.outputs.version }}" + + echo "Package.json version: $PACKAGE_VERSION" + echo "Expected version: $EXPECTED_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" + echo "verified_version=$PACKAGE_VERSION" >> $GITHUB_OUTPUT + + - name: Create and push tag + run: | + VERSION="v${{ steps.verify_version.outputs.verified_version }}" + + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + + # Create annotated tag + git tag -a "$VERSION" -m "Release $VERSION" + git push origin "$VERSION" + + echo "Created and pushed tag: $VERSION" + + - name: Generate detailed changelog + id: changelog + run: | + VERSION="v${{ steps.verify_version.outputs.verified_version }}" + + echo "# Release $VERSION" > FULL_CHANGELOG.md + echo "" >> FULL_CHANGELOG.md + + # Get the previous tag + PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD~1 2>/dev/null || echo "") + + if [ -n "$PREVIOUS_TAG" ]; then + echo "## Changes since $PREVIOUS_TAG" >> FULL_CHANGELOG.md + echo "" >> FULL_CHANGELOG.md + + # Get commits with more detail + echo "### 🚀 Features and Improvements" >> FULL_CHANGELOG.md + git log --pretty=format:"- %s ([%h](https://github.com/${{ github.repository }}/commit/%H))" $PREVIOUS_TAG..HEAD --grep="feat" --grep="add" --grep="implement" >> FULL_CHANGELOG.md || true + echo "" >> FULL_CHANGELOG.md + + echo "### 🐛 Bug Fixes" >> FULL_CHANGELOG.md + git log --pretty=format:"- %s ([%h](https://github.com/${{ github.repository }}/commit/%H))" $PREVIOUS_TAG..HEAD --grep="fix" --grep="bug" >> FULL_CHANGELOG.md || true + echo "" >> FULL_CHANGELOG.md + + echo "### 📚 Documentation" >> FULL_CHANGELOG.md + git log --pretty=format:"- %s ([%h](https://github.com/${{ github.repository }}/commit/%H))" $PREVIOUS_TAG..HEAD --grep="doc" >> FULL_CHANGELOG.md || true + echo "" >> FULL_CHANGELOG.md + + echo "### 🔧 Other Changes" >> FULL_CHANGELOG.md + git log --pretty=format:"- %s ([%h](https://github.com/${{ github.repository }}/commit/%H))" $PREVIOUS_TAG..HEAD --invert-grep --grep="feat" --grep="add" --grep="implement" --grep="fix" --grep="bug" --grep="doc" >> FULL_CHANGELOG.md || true + else + echo "## Initial Release" >> FULL_CHANGELOG.md + echo "" >> FULL_CHANGELOG.md + echo "This is the initial release of the Dojo Unity SDK." >> FULL_CHANGELOG.md + fi + + echo "" >> FULL_CHANGELOG.md + echo "---" >> FULL_CHANGELOG.md + echo "" >> FULL_CHANGELOG.md + echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/$PREVIOUS_TAG...$VERSION" >> FULL_CHANGELOG.md + + # Set output for release description + { + echo 'changelog<> $GITHUB_OUTPUT + + # Git LFS setup (copied from existing release.yml) + - name: Create LFS file list + run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id + + - name: Restore LFS cache + uses: actions/cache@v3 + id: lfs-cache + 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 (copied from existing release.yml) + - uses: actions/cache@v3 + with: + path: Library + key: Library-Build-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }} + restore-keys: | + Library-Build- + + # Build Unity Package (copied from existing release.yml) + - 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 + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: v${{ steps.verify_version.outputs.verified_version }} + release_name: Release v${{ steps.verify_version.outputs.verified_version }} + body: ${{ steps.changelog.outputs.changelog }} + draft: true + prerelease: false + + - name: Upload Unity Package to Release + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./Build/dojo.unitypackage + asset_name: dojo-v${{ steps.verify_version.outputs.verified_version }}.unitypackage + asset_content_type: application/octet-stream + + - name: Comment on merged PR + uses: peter-evans/create-or-update-comment@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + issue-number: ${{ github.event.pull_request.number }} + body: | + 🎉 **Release Created Successfully!** + + **Version:** v${{ steps.verify_version.outputs.verified_version }} + **Tag:** Created and pushed + **Release:** [Draft Release](https://github.com/${{ github.repository }}/releases/tag/v${{ steps.verify_version.outputs.verified_version }}) + **Package:** Built and uploaded + + ### Next Steps: + 1. ✅ Git tag `v${{ steps.verify_version.outputs.verified_version }}` has been created + 2. ✅ Unity package has been built and attached to the release + 3. 📝 Draft release is ready for review + 4. 🚀 **[Review and publish the release](https://github.com/${{ github.repository }}/releases/tag/v${{ steps.verify_version.outputs.verified_version }})** when ready + + The release includes: + - 📦 Unity package (`dojo-v${{ steps.verify_version.outputs.verified_version }}.unitypackage`) + - 📋 Generated changelog + - 🏷️ Git tag for version tracking diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1b9fbd2d..b37714f5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,19 +1,31 @@ -name: Release +name: Legacy Release Build +# This workflow is triggered when a release is published (not draft) +# It builds and uploads the Unity package to the existing release on: release: - types: [created] + types: [published] jobs: - build: - name: Build Package + build-and-upload: + name: Build and Upload Package runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - name: Checkout code + uses: actions/checkout@v3 with: lfs: true + fetch-depth: 0 - # Git LFS + - name: Get release info + id: release_info + run: | + echo "tag_name=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT + echo "release_name=${{ github.event.release.name }}" >> $GITHUB_OUTPUT + echo "Release: ${{ github.event.release.name }}" + echo "Tag: ${{ github.event.release.tag_name }}" + + # Git LFS setup - name: Create LFS file list run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id @@ -31,14 +43,15 @@ jobs: git reset --hard # Unity Cache - - uses: actions/cache@v3 + - name: Cache Unity Library + uses: actions/cache@v3 with: path: Library key: Library-Build-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }} restore-keys: | Library-Build- - # Build + # Build Unity Package - name: Build Unity Package uses: game-ci/unity-builder@v4 env: @@ -49,7 +62,7 @@ jobs: targetPlatform: StandaloneLinux64 buildMethod: Editor.Builder.BuildPackage - # Upload package to release + # Upload package to the published release - name: Upload Release Asset uses: actions/upload-release-asset@v1 env: @@ -57,5 +70,15 @@ jobs: with: upload_url: ${{ github.event.release.upload_url }} asset_path: ./Build/dojo.unitypackage - asset_name: dojo.unitypackage - asset_content_type: application/octet-stream \ No newline at end of file + asset_name: dojo-${{ steps.release_info.outputs.tag_name }}.unitypackage + asset_content_type: application/octet-stream + + - name: Build Summary + run: | + echo "✅ **Unity Package Built Successfully!**" + echo "" + echo "**Release:** ${{ steps.release_info.outputs.release_name }}" + echo "**Tag:** ${{ steps.release_info.outputs.tag_name }}" + echo "**Package:** dojo-${{ steps.release_info.outputs.tag_name }}.unitypackage" + echo "" + echo "The package has been uploaded to the release." \ No newline at end of file From a4d02e44cb13afdf31d9f350d915ef11ccba8466 Mon Sep 17 00:00:00 2001 From: Nasr Date: Mon, 8 Sep 2025 12:10:13 +0100 Subject: [PATCH 2/2] update workflows --- .github/workflows/README.md | 372 +++++++++++++++---------- .github/workflows/ci.yml | 124 ++++----- .github/workflows/manual-release.yml | 148 ---------- .github/workflows/prepare-release.yml | 206 -------------- .github/workflows/release-dispatch.yml | 247 ++++++++++++++++ .github/workflows/release-on-merge.yml | 202 ++++---------- .github/workflows/release.yml | 84 ------ 7 files changed, 589 insertions(+), 794 deletions(-) delete mode 100644 .github/workflows/manual-release.yml delete mode 100644 .github/workflows/prepare-release.yml create mode 100644 .github/workflows/release-dispatch.yml delete mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/README.md b/.github/workflows/README.md index 8f3933ae..52fd3206 100644 --- a/.github/workflows/README.md +++ b/.github/workflows/README.md @@ -1,192 +1,260 @@ # GitHub Workflows for Dojo Unity SDK -This directory contains the GitHub Actions workflows for managing releases and CI/CD for the Dojo Unity SDK. +This directory contains streamlined GitHub Actions workflows for managing releases and CI/CD for the Dojo Unity SDK. -## Workflows Overview +## 🚀 Quick Start -### 1. `prepare-release.yml` - Prepare Release -**Trigger:** Manual workflow dispatch -**Purpose:** Prepares a new release by updating version numbers and creating a PR +### Creating a Release (Recommended Flow) -**Usage:** -```bash -# Go to Actions tab → Prepare Release → Run workflow -# Choose version bump type: patch, minor, or major -# Or provide a custom version override -``` +1. **Go to GitHub Actions** → **Release Dispatch** → **Run workflow** +2. **Enter version** (e.g., `1.4.0` or `patch`/`minor`/`major`) +3. **Review the auto-created PR** and merge it +4. **Publish the draft release** when ready -**What it does:** -- ✅ Updates `package.json` version -- ✅ Updates Unity package files -- ✅ Creates a release branch (`release/vX.X.X`) -- ✅ Generates changelog from git commits -- ✅ Creates a PR with all changes -- ✅ Adds helpful comments and labels +That's it! 🎉 -### 2. `release-on-merge.yml` - Create Release on Merge -**Trigger:** Automatic when release PR is merged to main -**Purpose:** Automatically creates a draft release when a release PR is merged +## 📋 Workflows Overview -**What it does:** -- ✅ Detects release PRs (title: "Release vX.X.X" or branch: "release/vX.X.X") -- ✅ Verifies version consistency -- ✅ Creates and pushes git tag -- ✅ Builds Unity package -- ✅ Creates draft release with changelog -- ✅ Uploads Unity package to release -- ✅ Comments on the merged PR with next steps - -### 3. `manual-release.yml` - Manual Release +### 1. `release-dispatch.yml` - Release Dispatch (Main Workflow) **Trigger:** Manual workflow dispatch -**Purpose:** Create a release manually for an existing tag +**Purpose:** One-stop workflow for creating releases -**Usage:** -```bash -# Go to Actions tab → Manual Release → Run workflow -# Provide the tag (e.g., v1.4.0) -# Choose draft/prerelease options -``` +**How it works:** +- Creates a release branch with version updates +- Generates changelog from git commits +- Creates a PR with all changes +- Optionally builds and creates the release immediately + +### 2. `release-on-merge.yml` - Release on Merge +**Trigger:** Automatic when release PR is merged +**Purpose:** Automatically creates draft release when release PR is merged -### 4. `release.yml` - Legacy Release Build -**Trigger:** Automatic when a release is published (not draft) -**Purpose:** Builds and uploads Unity package to published releases +**How it works:** +- Detects release PRs (title: "Release vX.X.X") +- Creates git tag +- Builds Unity package +- Creates draft release +- Comments on PR with next steps + +### 3. `ci.yml` - Continuous Integration +**Trigger:** Push/PR to main branch +**Purpose:** Code quality checks and build verification **What it does:** -- ✅ Builds Unity package when release is published -- ✅ Uploads package with versioned filename +- Code formatting checks (C#) +- Unity package build verification +- (Tests commented out until ready) -## Complete Release Process +### 4. `dojoc.yml` - DojoC Artifacts +**Trigger:** Changes to `Bindings/dojo.c/**` or manual dispatch +**Purpose:** Generates C# bindings and native libraries -### Option A: Automated Release Process (Recommended) +## 📖 Step-by-Step Release Guide -1. **Prepare Release** - ```bash - # Go to GitHub Actions → Prepare Release → Run workflow - # Select version bump type or provide custom version +### Option A: Automatic Version Bumping + +1. **Navigate to GitHub Actions** + ``` + GitHub Repository → Actions tab → Release Dispatch → Run workflow ``` -2. **Review and Merge PR** - - Review the automatically created PR - - Check version updates and changelog - - Merge the PR to main +2. **Choose Version Type** + - `patch` - Bug fixes (1.2.3 → 1.2.4) + - `minor` - New features (1.2.3 → 1.3.0) + - `major` - Breaking changes (1.2.3 → 2.0.0) + +3. **Configure Options** + - ✅ **Draft**: `true` (recommended) - Creates draft for review + - ❌ **Pre-release**: `false` (unless it's a beta/alpha) + +4. **Run the Workflow** + - Click "Run workflow" + - Wait for completion (~2-3 minutes) + +5. **Review the PR** + - A PR titled "Release vX.X.X" will be created + - Review version changes in `package.json` + - Review generated changelog + - Merge the PR when satisfied -3. **Publish Release** - - A draft release is automatically created - - Review the draft release - - Click "Publish release" when ready +6. **Publish the Release** + - Navigate to Releases tab + - Find the draft release + - Review release notes and attached Unity package + - Click "Publish release" -### Option B: Manual Release Process +### Option B: Custom Version -1. **Update version manually** in `package.json` -2. **Create and push tag** +1. **Navigate to GitHub Actions** + ``` + GitHub Repository → Actions tab → Release Dispatch → Run workflow + ``` + +2. **Enter Custom Version** + - Type exact version: `1.4.0` + - Set options as desired + +3. **Follow steps 4-6 from Option A** + +### Option C: Manual Process + +1. **Update Version Manually** + ```bash + # Edit package.json + vim package.json + # Change version field to desired version + ``` + +2. **Create Release Branch** ```bash - git tag -a v1.4.0 -m "Release v1.4.0" - git push origin v1.4.0 + git checkout -b release/v1.4.0 + git add package.json + git commit -m "chore: bump version to 1.4.0" + git push origin release/v1.4.0 ``` -3. **Run Manual Release workflow** - - Go to Actions → Manual Release - - Provide the tag name - - Choose options and run - -## Workflow Features - -### 🚀 Version Management -- Automatic semantic versioning (patch/minor/major) -- Custom version override support -- Consistent version updates across all files - -### 📋 Changelog Generation -- Automatic changelog from git commits -- Categorized by commit types (features, fixes, docs) -- Links to commits and comparisons - -### 🏷️ Git Tagging -- Automatic tag creation and pushing -- Annotated tags with release messages -- Tag verification and validation - -### 📦 Unity Package Building -- Automatic Unity package compilation -- LFS support for large assets -- Caching for faster builds -- Versioned package filenames - -### 🔄 PR Management -- Automatic PR creation for releases -- Helpful descriptions and comments -- Proper labeling and reviewer assignment -- Status updates throughout process - -## Configuration Requirements - -### Repository Secrets -Make sure these secrets are configured in your repository: - -- `UNITY_LICENSE` - Your Unity license -- `UNITY_EMAIL` - Unity account email -- `UNITY_PASSWORD` - Unity account password -- `GITHUB_TOKEN` - Automatically provided by GitHub - -### Permissions -The workflows require these permissions: -- Contents: write (for creating tags and releases) -- Pull requests: write (for creating PRs) -- Actions: read (for workflow status) - -## File Structure + +3. **Create PR** + - Create PR with title "Release v1.4.0" + - Merge when ready + +4. **The rest is automatic!** + - `release-on-merge.yml` will trigger + - Draft release will be created + - Publish when ready + +## 🔧 Workflow Configuration + +### Required Repository Secrets + +```yaml +UNITY_LICENSE: Your Unity license key +UNITY_EMAIL: Unity account email +UNITY_PASSWORD: Unity account password +GITHUB_TOKEN: Automatically provided +``` + +### Required Permissions + +```yaml +Contents: write # Create tags and releases +Pull requests: write # Create PRs +Actions: read # Read workflow status +``` + +## 📁 File Structure After Cleanup ``` .github/workflows/ -├── README.md # This file -├── prepare-release.yml # Prepare new release -├── release-on-merge.yml # Auto-create release on merge -├── manual-release.yml # Manual release creation -├── release.yml # Legacy release build -├── ci.yml # Existing CI workflow -└── dojoc.yml # Existing dojo.c workflow +├── README.md # This guide +├── release-dispatch.yml # 🚀 Main release workflow +├── release-on-merge.yml # 🔄 Auto-release on PR merge +├── ci.yml # ✅ Code quality & build checks +└── dojoc.yml # 🔧 Native bindings generation ``` -## Troubleshooting +## 🎯 Key Improvements -### Common Issues +### ✅ What's Better Now -1. **Version mismatch error** - - Ensure package.json version matches the expected version - - Check that the release PR was merged properly +- **Simplified**: 4 workflows instead of 7 +- **Modern**: Uses latest GitHub Actions (v4) +- **Reliable**: Better error handling and validation +- **Flexible**: Support both semantic and custom versioning +- **Automated**: Less manual work, more automation +- **Clear**: Better naming and documentation -2. **Unity build fails** - - Check Unity license secrets - - Verify Unity project configuration - - Check for compilation errors in Unity +### 🗑️ What Was Removed -3. **Tag already exists** - - Use a different version number - - Delete the existing tag if needed: `git tag -d v1.4.0 && git push origin :refs/tags/v1.4.0` +- `release.yml` - Merged into `release-dispatch.yml` +- `manual-release.yml` - Functionality in `release-dispatch.yml` +- `prepare-release.yml` - Functionality in `release-dispatch.yml` -4. **PR not detected as release PR** - - Ensure PR title follows format: "Release vX.X.X" - - Or use branch name format: "release/vX.X.X" +## 🚨 Common Scenarios -### Debug Tips +### Hotfix Release -- Check workflow logs in the Actions tab -- Verify repository permissions and secrets -- Test with a patch version first -- Use draft releases for testing +```bash +# For urgent bug fixes +GitHub Actions → Release Dispatch → Run workflow +Version: "patch" +Draft: true +→ Review → Merge PR → Publish Release +``` -## Customization +### Feature Release -To customize the workflows for your needs: +```bash +# For new features +GitHub Actions → Release Dispatch → Run workflow +Version: "minor" +Draft: true +→ Review → Merge PR → Publish Release +``` -1. **Changelog format** - Edit the changelog generation sections -2. **Version files** - Add more files to update in `prepare-release.yml` -3. **Build process** - Modify the Unity build steps -4. **Notifications** - Add Slack/Discord notifications -5. **Validation** - Add additional checks and tests +### Major Release + +```bash +# For breaking changes +GitHub Actions → Release Dispatch → Run workflow +Version: "major" +Draft: true +→ Extra review → Merge PR → Publish Release +``` + +### Pre-release/Beta + +```bash +GitHub Actions → Release Dispatch → Run workflow +Version: "1.4.0-beta.1" +Pre-release: true +Draft: false +→ Creates immediate pre-release +``` + +## 🔍 Troubleshooting + +### "Version mismatch" Error +- Check that `package.json` version matches expected version +- Ensure release PR was merged properly + +### Unity Build Fails +- Verify Unity license secrets are correct +- Check Unity project for compilation errors +- Review workflow logs for specific errors + +### PR Not Detected as Release PR +- Ensure PR title is exactly "Release vX.X.X" +- Check branch name follows "release/vX.X.X" format + +### Permission Denied +- Verify repository has required permissions +- Check if branch protection rules are blocking + +## 💡 Pro Tips + +1. **Always use draft releases** for review before publishing +2. **Test with patch versions** before major releases +3. **Review generated changelogs** and edit if needed +4. **Use semantic versioning** for consistency +5. **Monitor workflow logs** for any issues + +## 🆘 Emergency Procedures + +### Rollback a Release +```bash +# Delete tag and release if needed +git tag -d v1.4.0 +git push origin :refs/tags/v1.4.0 +# Then delete release from GitHub UI +``` + +### Fix Failed Release +```bash +# If release workflow failed +GitHub Actions → Release Dispatch → Run workflow +# Use same version, it will overwrite +``` -## Support +--- -For issues with these workflows: -1. Check the workflow logs in GitHub Actions -2. Review this README for configuration requirements -3. Open an issue with workflow logs and error details +**Need help?** Check workflow logs in GitHub Actions or open an issue with error details. \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2a667869..dd8b1a4a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,66 +7,67 @@ on: branches: [ main ] jobs: -# test: -# name: Run Tests -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v3 - -# # Git LFS -# - name: Create LFS file list -# run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id - -# - name: Restore LFS cache -# uses: actions/cache@v3 -# id: lfs-cache -# 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 - -# # Cache -# - uses: actions/cache@v3 -# with: -# path: Library -# key: Library-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }} -# restore-keys: | -# Library- - -# - name: Run Unity Tests -# uses: game-ci/unity-test-runner@v4 -# env: -# UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} -# UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} -# UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} -# with: -# projectPath: . -# testMode: all -# artifactsPath: TestResults -# githubToken: ${{ secrets.GITHUB_TOKEN }} - -# - name: Upload Test Results -# uses: actions/upload-artifact@v3 -# if: always() -# with: -# name: Test Results -# path: TestResults + # Commented out until tests are ready + # test: + # name: Run Tests + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v4 + # with: + # lfs: true + + # - 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 + + # - name: Cache Unity Library + # uses: actions/cache@v4 + # with: + # path: Library + # key: Library-${{ runner.os }}-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }} + # restore-keys: | + # Library-${{ runner.os }}- + + # - name: Run Unity Tests + # uses: game-ci/unity-test-runner@v4 + # env: + # UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} + # UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} + # UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} + # with: + # projectPath: . + # testMode: all + # artifactsPath: TestResults + # githubToken: ${{ secrets.GITHUB_TOKEN }} + + # - name: Upload Test Results + # uses: actions/upload-artifact@v4 + # if: always() + # with: + # name: test-results + # path: TestResults format: name: Check Code Format runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup .NET - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v4 with: - dotnet-version: '6.0.x' + dotnet-version: '8.0.x' - name: Install dotnet-format run: dotnet tool install -g dotnet-format @@ -105,17 +106,15 @@ jobs: name: Build Package runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: lfs: true - # Git LFS - - name: Create LFS file list + - name: Setup Git LFS run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id - - name: Restore LFS cache - uses: actions/cache@v3 - id: lfs-cache + - name: Cache Git LFS + uses: actions/cache@v4 with: path: .git/lfs key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }} @@ -126,15 +125,14 @@ jobs: git add . git reset --hard - # Unity Cache - - uses: actions/cache@v3 + - name: Cache Unity Library + uses: actions/cache@v4 with: path: Library - key: Library-Build-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }} + key: Library-${{ runner.os }}-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }} restore-keys: | - Library-Build- + Library-${{ runner.os }}- - # Build - name: Build Unity Package uses: game-ci/unity-builder@v4 env: diff --git a/.github/workflows/manual-release.yml b/.github/workflows/manual-release.yml deleted file mode 100644 index a4f862fd..00000000 --- a/.github/workflows/manual-release.yml +++ /dev/null @@ -1,148 +0,0 @@ -name: Manual Release - -on: - workflow_dispatch: - inputs: - tag: - description: 'Release tag (e.g., v1.4.0)' - required: true - type: string - prerelease: - description: 'Mark as pre-release' - required: false - default: false - type: boolean - draft: - description: 'Create as draft' - required: false - default: true - type: boolean - -jobs: - manual-release: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v3 - with: - token: ${{ secrets.GITHUB_TOKEN }} - fetch-depth: 0 - - - name: Validate tag format - run: | - TAG="${{ github.event.inputs.tag }}" - if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - echo "❌ Invalid tag format. Expected format: v1.2.3" - exit 1 - fi - echo "✅ Tag format is valid: $TAG" - - - name: Check if tag exists - run: | - TAG="${{ github.event.inputs.tag }}" - if git rev-parse "$TAG" >/dev/null 2>&1; then - echo "✅ Tag $TAG exists" - else - echo "❌ Tag $TAG does not exist. Please create the tag first or use the prepare-release workflow." - exit 1 - fi - - - name: Generate changelog - id: changelog - run: | - TAG="${{ github.event.inputs.tag }}" - - echo "# Release $TAG" > CHANGELOG.md - echo "" >> CHANGELOG.md - - # Get the previous tag - PREVIOUS_TAG=$(git describe --tags --abbrev=0 $TAG~1 2>/dev/null || echo "") - - if [ -n "$PREVIOUS_TAG" ]; then - echo "## Changes since $PREVIOUS_TAG" >> CHANGELOG.md - echo "" >> CHANGELOG.md - git log --pretty=format:"- %s ([%h](https://github.com/${{ github.repository }}/commit/%H))" $PREVIOUS_TAG..$TAG >> CHANGELOG.md - else - echo "## Initial Release" >> CHANGELOG.md - echo "" >> CHANGELOG.md - echo "This is the initial release of the Dojo Unity SDK." >> CHANGELOG.md - fi - - echo "" >> CHANGELOG.md - echo "---" >> CHANGELOG.md - echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/$PREVIOUS_TAG...$TAG" >> CHANGELOG.md - - { - echo 'changelog<> $GITHUB_OUTPUT - - # Git LFS setup - - name: Create LFS file list - run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id - - - name: Restore LFS cache - uses: actions/cache@v3 - id: lfs-cache - 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 - - uses: actions/cache@v3 - with: - path: Library - key: Library-Build-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }} - restore-keys: | - Library-Build- - - # 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 Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.event.inputs.tag }} - release_name: Release ${{ github.event.inputs.tag }} - body: ${{ steps.changelog.outputs.changelog }} - draft: ${{ github.event.inputs.draft }} - prerelease: ${{ github.event.inputs.prerelease }} - - - name: Upload Unity Package to Release - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./Build/dojo.unitypackage - asset_name: dojo-${{ github.event.inputs.tag }}.unitypackage - asset_content_type: application/octet-stream - - - name: Release Summary - run: | - echo "🎉 **Manual Release Created!**" - echo "" - echo "**Tag:** ${{ github.event.inputs.tag }}" - echo "**Draft:** ${{ github.event.inputs.draft }}" - echo "**Pre-release:** ${{ github.event.inputs.prerelease }}" - echo "**Release URL:** https://github.com/${{ github.repository }}/releases/tag/${{ github.event.inputs.tag }}" - echo "" - echo "The Unity package has been built and attached to the release." diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml deleted file mode 100644 index 6c332723..00000000 --- a/.github/workflows/prepare-release.yml +++ /dev/null @@ -1,206 +0,0 @@ -name: Prepare Release - -on: - workflow_dispatch: - inputs: - version_type: - description: 'Version bump type' - required: true - default: 'patch' - type: choice - options: - - patch - - minor - - major - version_override: - description: 'Override version (optional, e.g., 1.4.0)' - required: false - type: string - -jobs: - prepare-release: - runs-on: ubuntu-latest - outputs: - new_version: ${{ steps.version.outputs.new_version }} - steps: - - name: Checkout code - uses: actions/checkout@v3 - with: - token: ${{ secrets.GITHUB_TOKEN }} - fetch-depth: 0 - - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version: '18' - - - name: Configure Git - run: | - git config --local user.email "action@github.com" - git config --local user.name "GitHub Action" - - - name: Get current version - id: current_version - run: | - CURRENT_VERSION=$(jq -r '.version' package.json) - echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT - echo "Current version: $CURRENT_VERSION" - - - name: Calculate new version - id: version - run: | - CURRENT_VERSION="${{ steps.current_version.outputs.current_version }}" - - if [ -n "${{ github.event.inputs.version_override }}" ]; then - NEW_VERSION="${{ github.event.inputs.version_override }}" - echo "Using override version: $NEW_VERSION" - else - # Parse current version - IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_VERSION" - MAJOR=${VERSION_PARTS[0]} - MINOR=${VERSION_PARTS[1]} - PATCH=${VERSION_PARTS[2]} - - # Bump version based on type - case "${{ github.event.inputs.version_type }}" in - "major") - MAJOR=$((MAJOR + 1)) - MINOR=0 - PATCH=0 - ;; - "minor") - MINOR=$((MINOR + 1)) - PATCH=0 - ;; - "patch") - PATCH=$((PATCH + 1)) - ;; - esac - - NEW_VERSION="$MAJOR.$MINOR.$PATCH" - fi - - echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT - echo "New version: $NEW_VERSION" - - - name: Create release branch - run: | - BRANCH_NAME="release/v${{ steps.version.outputs.new_version }}" - git checkout -b "$BRANCH_NAME" - echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV - - - name: Update package.json version - run: | - NEW_VERSION="${{ steps.version.outputs.new_version }}" - jq --arg version "$NEW_VERSION" '.version = $version' package.json > package.json.tmp - mv package.json.tmp package.json - echo "Updated package.json to version $NEW_VERSION" - - - name: Update Unity package.json files - run: | - NEW_VERSION="${{ steps.version.outputs.new_version }}" - - # Update WebGL template package.json if it exists - if [ -f "Assets/WebGLTemplates/Dojo/TemplateData/dojo.js/package.json" ]; then - jq --arg version "$NEW_VERSION" '.version = $version' "Assets/WebGLTemplates/Dojo/TemplateData/dojo.js/package.json" > temp.json - mv temp.json "Assets/WebGLTemplates/Dojo/TemplateData/dojo.js/package.json" - echo "Updated WebGL template package.json" - fi - - # Update artifact package.json if it exists - if [ -f "artifacts/wasm-artifact/package.json" ]; then - jq --arg version "$NEW_VERSION" '.version = $version' "artifacts/wasm-artifact/package.json" > temp.json - mv temp.json "artifacts/wasm-artifact/package.json" - echo "Updated artifacts package.json" - fi - - - name: Generate changelog - id: changelog - run: | - NEW_VERSION="${{ steps.version.outputs.new_version }}" - CURRENT_VERSION="${{ steps.current_version.outputs.current_version }}" - - echo "## Changes in v$NEW_VERSION" > RELEASE_NOTES.md - echo "" >> RELEASE_NOTES.md - - # Get commits since last tag - LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") - if [ -n "$LAST_TAG" ]; then - echo "### Commits since $LAST_TAG:" >> RELEASE_NOTES.md - git log --pretty=format:"- %s (%h)" $LAST_TAG..HEAD >> RELEASE_NOTES.md - else - echo "### Recent commits:" >> RELEASE_NOTES.md - git log --pretty=format:"- %s (%h)" -10 >> RELEASE_NOTES.md - fi - - echo "" >> RELEASE_NOTES.md - echo "### Version Bump" >> RELEASE_NOTES.md - echo "- Updated from v$CURRENT_VERSION to v$NEW_VERSION" >> RELEASE_NOTES.md - - # Set output for PR description - { - echo 'changelog<> $GITHUB_OUTPUT - - - name: Commit changes - run: | - git add . - git commit -m "chore: bump version to ${{ steps.version.outputs.new_version }}" - git push origin "$BRANCH_NAME" - - - name: Create Pull Request - id: create_pr - uses: peter-evans/create-pull-request@v5 - with: - token: ${{ secrets.GITHUB_TOKEN }} - branch: ${{ env.BRANCH_NAME }} - title: "Release v${{ steps.version.outputs.new_version }}" - body: | - ## Release Preparation for v${{ steps.version.outputs.new_version }} - - This PR prepares the release for version ${{ steps.version.outputs.new_version }}. - - ### Changes: - - ✅ Updated package.json version to ${{ steps.version.outputs.new_version }} - - ✅ Updated Unity package files - - ✅ Generated changelog - - ### Next Steps: - 1. Review and merge this PR - 2. The release workflow will automatically trigger to create a draft release - 3. Review and publish the release - - --- - - ${{ steps.changelog.outputs.changelog }} - labels: | - release - automated - reviewers: | - ${{ github.actor }} - - - name: Comment on PR - if: steps.create_pr.outputs.pull-request-number - uses: peter-evans/create-or-update-comment@v3 - with: - token: ${{ secrets.GITHUB_TOKEN }} - issue-number: ${{ steps.create_pr.outputs.pull-request-number }} - body: | - 🚀 **Release Preparation Complete!** - - **Version:** v${{ steps.version.outputs.new_version }} - **Type:** ${{ github.event.inputs.version_type }} bump - - **What happens next:** - 1. ✅ This PR contains all version updates - 2. 🔍 Review the changes in this PR - 3. ✅ Merge this PR to trigger the release workflow - 4. 📦 A draft release will be automatically created - 5. 🎉 Publish the release when ready - - The release workflow will automatically: - - Create a git tag - - Build the Unity package - - Create a draft release with the changelog diff --git a/.github/workflows/release-dispatch.yml b/.github/workflows/release-dispatch.yml new file mode 100644 index 00000000..41c56958 --- /dev/null +++ b/.github/workflows/release-dispatch.yml @@ -0,0 +1,247 @@ +name: Release Dispatch + +on: + workflow_dispatch: + inputs: + version: + description: 'Release version (e.g., 1.4.0 or patch/minor/major)' + required: true + type: string + prerelease: + description: 'Create as pre-release' + required: false + default: false + type: boolean + draft: + description: 'Create as draft' + required: false + default: true + type: boolean + +jobs: + prepare-release: + name: Prepare Release + runs-on: ubuntu-latest + outputs: + version: ${{ steps.version.outputs.version }} + tag: ${{ steps.version.outputs.tag }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + + - name: Configure Git + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + + - name: Calculate version + id: version + run: | + INPUT_VERSION="${{ github.event.inputs.version }}" + CURRENT_VERSION=$(jq -r '.version' package.json) + + if [[ "$INPUT_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+(\.[0-9]+)?)?$ ]]; then + # Direct version specified (supports pre-release: 1.2.3, 1.2.3-alpha, 1.2.3-alpha.1, 1.2.3-beta.2) + NEW_VERSION="$INPUT_VERSION" + elif [[ "$INPUT_VERSION" == "patch" || "$INPUT_VERSION" == "minor" || "$INPUT_VERSION" == "major" ]]; then + # Semantic version bump + IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_VERSION" + MAJOR=${VERSION_PARTS[0]} + MINOR=${VERSION_PARTS[1]} + PATCH=${VERSION_PARTS[2]} + + case "$INPUT_VERSION" in + "major") MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 ;; + "minor") MINOR=$((MINOR + 1)); PATCH=0 ;; + "patch") PATCH=$((PATCH + 1)) ;; + esac + + NEW_VERSION="$MAJOR.$MINOR.$PATCH" + else + echo "❌ Invalid version format. Use semantic version (1.4.0) or bump type (patch/minor/major)" + exit 1 + fi + + echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT + echo "tag=v$NEW_VERSION" >> $GITHUB_OUTPUT + echo "Current: $CURRENT_VERSION → New: $NEW_VERSION" + + - name: Create release branch + run: | + BRANCH_NAME="release/${{ steps.version.outputs.tag }}" + git checkout -b "$BRANCH_NAME" + echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV + + - name: Update version files + run: | + NEW_VERSION="${{ steps.version.outputs.version }}" + + # Update main package.json + jq --arg version "$NEW_VERSION" '.version = $version' package.json > package.json.tmp + mv package.json.tmp package.json + + # Update WebGL template package.json if exists + if [ -f "Assets/WebGLTemplates/Dojo/TemplateData/dojo.js/package.json" ]; then + jq --arg version "$NEW_VERSION" '.version = $version' "Assets/WebGLTemplates/Dojo/TemplateData/dojo.js/package.json" > temp.json + mv temp.json "Assets/WebGLTemplates/Dojo/TemplateData/dojo.js/package.json" + fi + + # Update artifact package.json if exists + if [ -f "artifacts/wasm-artifact/package.json" ]; then + jq --arg version "$NEW_VERSION" '.version = $version' "artifacts/wasm-artifact/package.json" > temp.json + mv temp.json "artifacts/wasm-artifact/package.json" + fi + + - name: Generate changelog + id: changelog + run: | + TAG="${{ steps.version.outputs.tag }}" + PREVIOUS_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") + + echo "# Release $TAG" > CHANGELOG.md + echo "" >> CHANGELOG.md + + if [ -n "$PREVIOUS_TAG" ]; then + echo "## Changes since $PREVIOUS_TAG" >> CHANGELOG.md + echo "" >> CHANGELOG.md + + # Categorize commits + echo "### 🚀 Features" >> CHANGELOG.md + git log --pretty=format:"- %s ([%h](https://github.com/${{ github.repository }}/commit/%H))" $PREVIOUS_TAG..HEAD --grep="feat" --grep="add" >> CHANGELOG.md 2>/dev/null || echo "- No new features" >> CHANGELOG.md + echo "" >> CHANGELOG.md + + echo "### 🐛 Bug Fixes" >> CHANGELOG.md + git log --pretty=format:"- %s ([%h](https://github.com/${{ github.repository }}/commit/%H))" $PREVIOUS_TAG..HEAD --grep="fix" --grep="bug" >> CHANGELOG.md 2>/dev/null || echo "- No bug fixes" >> CHANGELOG.md + echo "" >> CHANGELOG.md + + echo "### 🔧 Other Changes" >> CHANGELOG.md + git log --pretty=format:"- %s ([%h](https://github.com/${{ github.repository }}/commit/%H))" $PREVIOUS_TAG..HEAD --invert-grep --grep="feat" --grep="add" --grep="fix" --grep="bug" >> CHANGELOG.md 2>/dev/null || echo "- No other changes" >> CHANGELOG.md + else + echo "## Initial Release" >> CHANGELOG.md + echo "" >> CHANGELOG.md + echo "This is the initial release of the Dojo Unity SDK." >> CHANGELOG.md + fi + + echo "" >> CHANGELOG.md + echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/$PREVIOUS_TAG...$TAG" >> CHANGELOG.md + + - name: Commit and push changes + run: | + git add . + git commit -m "chore: bump version to ${{ steps.version.outputs.version }}" + git push origin "$BRANCH_NAME" + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v5 + with: + token: ${{ secrets.GITHUB_TOKEN }} + branch: ${{ env.BRANCH_NAME }} + title: "Release ${{ steps.version.outputs.tag }}" + body: | + ## 🚀 Release ${{ steps.version.outputs.tag }} + + This PR prepares the release for version ${{ steps.version.outputs.version }}. + + ### ✅ Changes Made: + - Updated `package.json` version to ${{ steps.version.outputs.version }} + - Updated Unity package files + - Generated release changelog + + ### 📋 Release Notes: + + $(cat CHANGELOG.md) + + ### 🔄 Next Steps: + 1. Review and merge this PR + 2. Release workflow will automatically create a draft release + 3. Review and publish the release when ready + labels: | + release + automated + + build-and-release: + name: Build and Release + needs: prepare-release + runs-on: ubuntu-latest + if: github.event.inputs.draft == 'false' || github.event.inputs.prerelease == 'true' + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + ref: release/${{ needs.prepare-release.outputs.tag }} + lfs: true + fetch-depth: 0 + + - name: Create and push tag + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git tag -a "${{ needs.prepare-release.outputs.tag }}" -m "Release ${{ needs.prepare-release.outputs.tag }}" + git push origin "${{ needs.prepare-release.outputs.tag }}" + + # 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 Release + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ needs.prepare-release.outputs.tag }} + name: Release ${{ needs.prepare-release.outputs.tag }} + body_path: CHANGELOG.md + draft: ${{ github.event.inputs.draft }} + prerelease: ${{ github.event.inputs.prerelease }} + files: | + ./Build/dojo.unitypackage + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Summary + run: | + echo "🎉 **Release ${{ needs.prepare-release.outputs.tag }} Created!**" + echo "" + echo "**Version:** ${{ needs.prepare-release.outputs.version }}" + echo "**Tag:** ${{ needs.prepare-release.outputs.tag }}" + echo "**Draft:** ${{ github.event.inputs.draft }}" + echo "**Pre-release:** ${{ github.event.inputs.prerelease }}" + echo "**Release URL:** https://github.com/${{ github.repository }}/releases/tag/${{ needs.prepare-release.outputs.tag }}" diff --git a/.github/workflows/release-on-merge.yml b/.github/workflows/release-on-merge.yml index bf69b07a..b3a14ac1 100644 --- a/.github/workflows/release-on-merge.yml +++ b/.github/workflows/release-on-merge.yml @@ -1,4 +1,4 @@ -name: Create Release on Merge +name: Release on Merge on: pull_request: @@ -6,141 +6,77 @@ on: branches: [main] jobs: - check-release-pr: - if: github.event.pull_request.merged == true + release: + name: Create Release + if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.title, 'Release v') runs-on: ubuntu-latest - outputs: - is_release_pr: ${{ steps.check.outputs.is_release_pr }} - version: ${{ steps.check.outputs.version }} steps: - - name: Check if this is a release PR - id: check + - 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 }}" - PR_BRANCH="${{ github.event.pull_request.head.ref }}" - - echo "PR Title: $PR_TITLE" - echo "PR Branch: $PR_BRANCH" - - # Check if this is a release PR (title starts with "Release v" or branch starts with "release/") - if [[ "$PR_TITLE" =~ ^Release\ v[0-9]+\.[0-9]+\.[0-9]+$ ]] || [[ "$PR_BRANCH" =~ ^release/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - echo "is_release_pr=true" >> $GITHUB_OUTPUT - - # Extract version from title or branch - if [[ "$PR_TITLE" =~ ^Release\ v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then - VERSION="${BASH_REMATCH[1]}" - elif [[ "$PR_BRANCH" =~ ^release/v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then - VERSION="${BASH_REMATCH[1]}" - fi - + 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 "Detected release PR for version: $VERSION" + echo "tag=v$VERSION" >> $GITHUB_OUTPUT + echo "Detected version: $VERSION" else - echo "is_release_pr=false" >> $GITHUB_OUTPUT - echo "Not a release PR" + 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 - create-release: - needs: check-release-pr - if: needs.check-release-pr.outputs.is_release_pr == 'true' - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v3 - with: - token: ${{ secrets.GITHUB_TOKEN }} - fetch-depth: 0 - - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version: '18' - - name: Verify version in package.json - id: verify_version run: | PACKAGE_VERSION=$(jq -r '.version' package.json) - EXPECTED_VERSION="${{ needs.check-release-pr.outputs.version }}" - - echo "Package.json version: $PACKAGE_VERSION" - echo "Expected version: $EXPECTED_VERSION" + 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" - echo "verified_version=$PACKAGE_VERSION" >> $GITHUB_OUTPUT - name: Create and push tag run: | - VERSION="v${{ steps.verify_version.outputs.verified_version }}" - git config --local user.email "action@github.com" git config --local user.name "GitHub Action" - - # Create annotated tag - git tag -a "$VERSION" -m "Release $VERSION" - git push origin "$VERSION" - - echo "Created and pushed tag: $VERSION" + git tag -a "${{ steps.version.outputs.tag }}" -m "Release ${{ steps.version.outputs.tag }}" + git push origin "${{ steps.version.outputs.tag }}" - - name: Generate detailed changelog - id: changelog + - name: Generate changelog run: | - VERSION="v${{ steps.verify_version.outputs.verified_version }}" - - echo "# Release $VERSION" > FULL_CHANGELOG.md - echo "" >> FULL_CHANGELOG.md - - # Get the previous tag + 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" >> FULL_CHANGELOG.md - echo "" >> FULL_CHANGELOG.md - - # Get commits with more detail - echo "### 🚀 Features and Improvements" >> FULL_CHANGELOG.md - git log --pretty=format:"- %s ([%h](https://github.com/${{ github.repository }}/commit/%H))" $PREVIOUS_TAG..HEAD --grep="feat" --grep="add" --grep="implement" >> FULL_CHANGELOG.md || true - echo "" >> FULL_CHANGELOG.md - - echo "### 🐛 Bug Fixes" >> FULL_CHANGELOG.md - git log --pretty=format:"- %s ([%h](https://github.com/${{ github.repository }}/commit/%H))" $PREVIOUS_TAG..HEAD --grep="fix" --grep="bug" >> FULL_CHANGELOG.md || true - echo "" >> FULL_CHANGELOG.md - - echo "### 📚 Documentation" >> FULL_CHANGELOG.md - git log --pretty=format:"- %s ([%h](https://github.com/${{ github.repository }}/commit/%H))" $PREVIOUS_TAG..HEAD --grep="doc" >> FULL_CHANGELOG.md || true - echo "" >> FULL_CHANGELOG.md - - echo "### 🔧 Other Changes" >> FULL_CHANGELOG.md - git log --pretty=format:"- %s ([%h](https://github.com/${{ github.repository }}/commit/%H))" $PREVIOUS_TAG..HEAD --invert-grep --grep="feat" --grep="add" --grep="implement" --grep="fix" --grep="bug" --grep="doc" >> FULL_CHANGELOG.md || true + 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" >> FULL_CHANGELOG.md - echo "" >> FULL_CHANGELOG.md - echo "This is the initial release of the Dojo Unity SDK." >> FULL_CHANGELOG.md + 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 "" >> FULL_CHANGELOG.md - echo "---" >> FULL_CHANGELOG.md - echo "" >> FULL_CHANGELOG.md - echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/$PREVIOUS_TAG...$VERSION" >> FULL_CHANGELOG.md - - # Set output for release description - { - echo 'changelog<> $GITHUB_OUTPUT + echo "" >> RELEASE_NOTES.md + echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/$PREVIOUS_TAG...$TAG" >> RELEASE_NOTES.md - # Git LFS setup (copied from existing release.yml) - - name: Create LFS file list + # Git LFS setup + - name: Setup Git LFS run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id - - name: Restore LFS cache - uses: actions/cache@v3 - id: lfs-cache + - name: Cache Git LFS + uses: actions/cache@v4 with: path: .git/lfs key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }} @@ -151,15 +87,16 @@ jobs: git add . git reset --hard - # Unity Cache (copied from existing release.yml) - - uses: actions/cache@v3 + # Unity Cache + - name: Cache Unity Library + uses: actions/cache@v4 with: path: Library - key: Library-Build-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }} + key: Library-${{ runner.os }}-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }} restore-keys: | - Library-Build- + Library-${{ runner.os }}- - # Build Unity Package (copied from existing release.yml) + # Build Unity Package - name: Build Unity Package uses: game-ci/unity-builder@v4 env: @@ -171,47 +108,30 @@ jobs: buildMethod: Editor.Builder.BuildPackage - name: Create Draft Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: softprops/action-gh-release@v1 with: - tag_name: v${{ steps.verify_version.outputs.verified_version }} - release_name: Release v${{ steps.verify_version.outputs.verified_version }} - body: ${{ steps.changelog.outputs.changelog }} + tag_name: ${{ steps.version.outputs.tag }} + name: Release ${{ steps.version.outputs.tag }} + body_path: RELEASE_NOTES.md draft: true - prerelease: false - - - name: Upload Unity Package to Release - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./Build/dojo.unitypackage - asset_name: dojo-v${{ steps.verify_version.outputs.verified_version }}.unitypackage - asset_content_type: application/octet-stream + files: | + ./Build/dojo.unitypackage + token: ${{ secrets.GITHUB_TOKEN }} - - name: Comment on merged PR + - name: Comment on PR uses: peter-evans/create-or-update-comment@v3 with: - token: ${{ secrets.GITHUB_TOKEN }} issue-number: ${{ github.event.pull_request.number }} body: | 🎉 **Release Created Successfully!** - **Version:** v${{ steps.verify_version.outputs.verified_version }} - **Tag:** Created and pushed - **Release:** [Draft Release](https://github.com/${{ github.repository }}/releases/tag/v${{ steps.verify_version.outputs.verified_version }}) - **Package:** Built and uploaded + **Version:** ${{ steps.version.outputs.tag }} + **Release:** [Draft Release](https://github.com/${{ github.repository }}/releases/tag/${{ steps.version.outputs.tag }}) - ### Next Steps: - 1. ✅ Git tag `v${{ steps.verify_version.outputs.verified_version }}` has been created - 2. ✅ Unity package has been built and attached to the release - 3. 📝 Draft release is ready for review - 4. 🚀 **[Review and publish the release](https://github.com/${{ github.repository }}/releases/tag/v${{ steps.verify_version.outputs.verified_version }})** when ready + ### ✅ Completed: + - Git tag `${{ steps.version.outputs.tag }}` created and pushed + - Unity package built and uploaded + - Draft release created with changelog - The release includes: - - 📦 Unity package (`dojo-v${{ steps.verify_version.outputs.verified_version }}.unitypackage`) - - 📋 Generated changelog - - 🏷️ Git tag for version tracking + ### 🚀 Next Steps: + **[Review and publish the release](https://github.com/${{ github.repository }}/releases/tag/${{ steps.version.outputs.tag }})** when ready! \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index b37714f5..00000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,84 +0,0 @@ -name: Legacy Release Build - -# This workflow is triggered when a release is published (not draft) -# It builds and uploads the Unity package to the existing release -on: - release: - types: [published] - -jobs: - build-and-upload: - name: Build and Upload Package - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v3 - with: - lfs: true - fetch-depth: 0 - - - name: Get release info - id: release_info - run: | - echo "tag_name=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT - echo "release_name=${{ github.event.release.name }}" >> $GITHUB_OUTPUT - echo "Release: ${{ github.event.release.name }}" - echo "Tag: ${{ github.event.release.tag_name }}" - - # Git LFS setup - - name: Create LFS file list - run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id - - - name: Restore LFS cache - uses: actions/cache@v3 - id: lfs-cache - 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@v3 - with: - path: Library - key: Library-Build-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }} - restore-keys: | - Library-Build- - - # 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 - - # Upload package to the published release - - name: Upload Release Asset - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ github.event.release.upload_url }} - asset_path: ./Build/dojo.unitypackage - asset_name: dojo-${{ steps.release_info.outputs.tag_name }}.unitypackage - asset_content_type: application/octet-stream - - - name: Build Summary - run: | - echo "✅ **Unity Package Built Successfully!**" - echo "" - echo "**Release:** ${{ steps.release_info.outputs.release_name }}" - echo "**Tag:** ${{ steps.release_info.outputs.tag_name }}" - echo "**Package:** dojo-${{ steps.release_info.outputs.tag_name }}.unitypackage" - echo "" - echo "The package has been uploaded to the release." \ No newline at end of file