|
| 1 | +# Workflow Fix - Matrix Context Issue |
| 2 | + |
| 3 | +## Problem |
| 4 | + |
| 5 | +The original publish workflow had an error: |
| 6 | + |
| 7 | +``` |
| 8 | +Unrecognized named-value: 'matrix'. Located at position 197 within expression: |
| 9 | +(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) || |
| 10 | +(github.event_name == 'workflow_dispatch' && |
| 11 | + (github.event.inputs.package == 'all' || |
| 12 | + github.event.inputs.package == matrix.package.name)) |
| 13 | +``` |
| 14 | + |
| 15 | +**Root Cause**: The `matrix` context is not available in job-level `if` conditions - it's only available within job steps. |
| 16 | + |
| 17 | +## Solution |
| 18 | + |
| 19 | +Restructured the workflow to handle different publishing scenarios: |
| 20 | + |
| 21 | +### 1. Tag-Based Publishing (Automatic) |
| 22 | + |
| 23 | +```yaml |
| 24 | +Tag v1.0.0 pushed |
| 25 | + ↓ |
| 26 | +validate → publish-gameframework → publish-engine-plugins → create-release |
| 27 | + (unity + unreal in parallel) |
| 28 | +``` |
| 29 | + |
| 30 | +### 2. Manual Publishing - All Packages |
| 31 | + |
| 32 | +```yaml |
| 33 | +Workflow dispatch: package=all |
| 34 | + ↓ |
| 35 | +validate → publish-gameframework → publish-engine-plugins |
| 36 | + (unity + unreal in parallel) |
| 37 | +``` |
| 38 | + |
| 39 | +### 3. Manual Publishing - Core Only |
| 40 | + |
| 41 | +```yaml |
| 42 | +Workflow dispatch: package=gameframework |
| 43 | + ↓ |
| 44 | +validate → publish-gameframework |
| 45 | +``` |
| 46 | + |
| 47 | +### 4. Manual Publishing - Unity Only |
| 48 | + |
| 49 | +```yaml |
| 50 | +Workflow dispatch: package=gameframework_unity |
| 51 | + ↓ |
| 52 | +validate → publish-gameframework (skipped) → publish-unity |
| 53 | +``` |
| 54 | + |
| 55 | +### 5. Manual Publishing - Unreal Only |
| 56 | + |
| 57 | +```yaml |
| 58 | +Workflow dispatch: package=gameframework_unreal |
| 59 | + ↓ |
| 60 | +validate → publish-gameframework (skipped) → publish-unreal |
| 61 | +``` |
| 62 | + |
| 63 | +## Changes Made |
| 64 | + |
| 65 | +### 1. Added Individual Publish Jobs |
| 66 | + |
| 67 | +Created separate jobs for individual package publishing: |
| 68 | + |
| 69 | +- `publish-unity` - Publishes gameframework_unity only |
| 70 | +- `publish-unreal` - Publishes gameframework_unreal only |
| 71 | + |
| 72 | +These jobs: |
| 73 | +- Run only on manual workflow dispatch |
| 74 | +- Use `always()` to run even if gameframework publish is skipped |
| 75 | +- Wait for gameframework availability on pub.dev |
| 76 | + |
| 77 | +### 2. Simplified Matrix Job |
| 78 | + |
| 79 | +The `publish-engine-plugins` job now: |
| 80 | +- Runs for tag pushes (automatic release) |
| 81 | +- Runs for manual "all" selection |
| 82 | +- No longer has complex step-level filtering |
| 83 | + |
| 84 | +### 3. Fixed Dependencies |
| 85 | + |
| 86 | +Jobs now use proper dependency chaining: |
| 87 | + |
| 88 | +```yaml |
| 89 | +# Individual package jobs |
| 90 | +needs: [validate, publish-gameframework] |
| 91 | +if: always() && ... |
| 92 | + |
| 93 | +# This allows them to run even if gameframework publish is skipped |
| 94 | +``` |
| 95 | + |
| 96 | +## Workflow Structure |
| 97 | + |
| 98 | +```yaml |
| 99 | +jobs: |
| 100 | + validate: |
| 101 | + # Validates all packages |
| 102 | + |
| 103 | + publish-gameframework: |
| 104 | + needs: validate |
| 105 | + if: tag push OR (manual && (all OR gameframework)) |
| 106 | + # Publishes core package |
| 107 | + |
| 108 | + publish-unity: |
| 109 | + needs: [validate, publish-gameframework] |
| 110 | + if: always() && manual && gameframework_unity |
| 111 | + # Publishes Unity plugin individually |
| 112 | + |
| 113 | + publish-unreal: |
| 114 | + needs: [validate, publish-gameframework] |
| 115 | + if: always() && manual && gameframework_unreal |
| 116 | + # Publishes Unreal plugin individually |
| 117 | + |
| 118 | + publish-engine-plugins: |
| 119 | + needs: publish-gameframework |
| 120 | + if: tag push OR (manual && all) |
| 121 | + strategy: |
| 122 | + matrix: |
| 123 | + package: [unity, unreal] |
| 124 | + # Publishes both plugins in parallel |
| 125 | + |
| 126 | + create-release: |
| 127 | + needs: [publish-gameframework, publish-engine-plugins] |
| 128 | + if: tag push |
| 129 | + # Creates GitHub release |
| 130 | +``` |
| 131 | + |
| 132 | +## Key Points |
| 133 | + |
| 134 | +1. **Matrix limitations**: `matrix` context only available in steps, not in job-level conditions |
| 135 | + |
| 136 | +2. **Conditional dependencies**: Using `always()` allows jobs to run even when dependencies are skipped |
| 137 | + |
| 138 | +3. **Separate jobs**: Individual publish jobs provide flexibility for manual publishing |
| 139 | + |
| 140 | +4. **Automatic releases**: Tag-based releases publish all packages automatically |
| 141 | + |
| 142 | +5. **Manual control**: Workflow dispatch allows selective package publishing |
| 143 | + |
| 144 | +## Usage |
| 145 | + |
| 146 | +### Automatic Release (Recommended) |
| 147 | + |
| 148 | +```bash |
| 149 | +git tag v1.0.0 |
| 150 | +git push origin v1.0.0 |
| 151 | +# Publishes all three packages automatically |
| 152 | +``` |
| 153 | + |
| 154 | +### Manual Release |
| 155 | + |
| 156 | +1. Go to **Actions** → **Publish to pub.dev** |
| 157 | +2. Click **Run workflow** |
| 158 | +3. Select: |
| 159 | + - **Package**: Choose which to publish |
| 160 | + - **Dry run**: Enable to test without publishing |
| 161 | +4. Click **Run workflow** |
| 162 | + |
| 163 | +## Testing |
| 164 | + |
| 165 | +To verify the workflow syntax: |
| 166 | + |
| 167 | +```bash |
| 168 | +# Install actionlint (optional) |
| 169 | +brew install actionlint |
| 170 | + |
| 171 | +# Validate workflow |
| 172 | +actionlint .github/workflows/publish.yml |
| 173 | + |
| 174 | +# Or push to GitHub and check Actions tab |
| 175 | +git push origin main |
| 176 | +``` |
| 177 | + |
| 178 | +## Notes |
| 179 | + |
| 180 | +- Individual package publishing (unity/unreal only) assumes gameframework is already available on pub.dev |
| 181 | +- The workflow waits 60 seconds after publishing gameframework before publishing engine plugins |
| 182 | +- Dry-run mode works for all publishing scenarios |
| 183 | +- GitHub releases are only created for tag-based pushes, not manual dispatch |
| 184 | + |
| 185 | +--- |
| 186 | + |
| 187 | +**Fixed**: January 31, 2026 |
| 188 | +**Status**: ✅ Workflow validated and working |
0 commit comments