diff --git a/.github/workflows/README.md b/.github/workflows/README.md new file mode 100644 index 00000000..52fd3206 --- /dev/null +++ b/.github/workflows/README.md @@ -0,0 +1,260 @@ +# GitHub Workflows for Dojo Unity SDK + +This directory contains streamlined GitHub Actions workflows for managing releases and CI/CD for the Dojo Unity SDK. + +## 🚀 Quick Start + +### Creating a Release (Recommended Flow) + +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 + +That's it! 🎉 + +## 📋 Workflows Overview + +### 1. `release-dispatch.yml` - Release Dispatch (Main Workflow) +**Trigger:** Manual workflow dispatch +**Purpose:** One-stop workflow for creating releases + +**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 + +**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:** +- Code formatting checks (C#) +- Unity package build verification +- (Tests commented out until ready) + +### 4. `dojoc.yml` - DojoC Artifacts +**Trigger:** Changes to `Bindings/dojo.c/**` or manual dispatch +**Purpose:** Generates C# bindings and native libraries + +## 📖 Step-by-Step Release Guide + +### Option A: Automatic Version Bumping + +1. **Navigate to GitHub Actions** + ``` + GitHub Repository → Actions tab → Release Dispatch → Run workflow + ``` + +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 + +6. **Publish the Release** + - Navigate to Releases tab + - Find the draft release + - Review release notes and attached Unity package + - Click "Publish release" + +### Option B: Custom Version + +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 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. **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 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 +``` + +## 🎯 Key Improvements + +### ✅ What's Better Now + +- **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 + +### 🗑️ What Was Removed + +- `release.yml` - Merged into `release-dispatch.yml` +- `manual-release.yml` - Functionality in `release-dispatch.yml` +- `prepare-release.yml` - Functionality in `release-dispatch.yml` + +## 🚨 Common Scenarios + +### Hotfix Release + +```bash +# For urgent bug fixes +GitHub Actions → Release Dispatch → Run workflow +Version: "patch" +Draft: true +→ Review → Merge PR → Publish Release +``` + +### Feature Release + +```bash +# For new features +GitHub Actions → Release Dispatch → Run workflow +Version: "minor" +Draft: true +→ Review → Merge PR → Publish Release +``` + +### 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 +``` + +--- + +**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/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 new file mode 100644 index 00000000..b3a14ac1 --- /dev/null +++ b/.github/workflows/release-on-merge.yml @@ -0,0 +1,137 @@ +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! \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 1b9fbd2d..00000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,61 +0,0 @@ -name: Release - -on: - release: - types: [created] - -jobs: - build: - name: Build Package - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - lfs: true - - # 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 - - # Unity Cache - - uses: actions/cache@v3 - with: - path: Library - key: Library-Build-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }} - restore-keys: | - Library-Build- - - # Build - - 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 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.unitypackage - asset_content_type: application/octet-stream \ No newline at end of file