|
| 1 | +# GitHub Workflows |
| 2 | + |
| 3 | +This directory contains automated workflows for the PluginLangCore project. |
| 4 | + |
| 5 | +## Workflows |
| 6 | + |
| 7 | +### 1. Release Workflow (`release.yml`) |
| 8 | + |
| 9 | +**Trigger:** Automatically runs on push to `main` or `master` branch, or can be triggered manually. |
| 10 | + |
| 11 | +**What it does:** |
| 12 | +1. Extracts the version from `build.gradle` |
| 13 | +2. Checks if a tag with that version already exists |
| 14 | +3. If the tag doesn't exist: |
| 15 | + - Builds the project with Gradle |
| 16 | + - Creates a Git tag (e.g., `v1.0.0`) |
| 17 | + - Creates a GitHub Release with all built artifacts: |
| 18 | + - Main JAR |
| 19 | + - Sources JAR |
| 20 | + - Javadoc JAR |
| 21 | +4. If the tag exists, skips the release process |
| 22 | + |
| 23 | +**Usage:** |
| 24 | +- Simply push your changes to the main branch |
| 25 | +- Or trigger manually from the Actions tab |
| 26 | + |
| 27 | +### 2. Version Bump Workflow (`version-bump.yml`) |
| 28 | + |
| 29 | +**Trigger:** Manual workflow dispatch with version input. |
| 30 | + |
| 31 | +**What it does:** |
| 32 | +1. Updates the version in `build.gradle` |
| 33 | +2. Commits and pushes the change |
| 34 | +3. Automatically triggers the release workflow |
| 35 | + |
| 36 | +**Usage:** |
| 37 | +1. Go to the Actions tab in your GitHub repository |
| 38 | +2. Select "Version Bump" workflow |
| 39 | +3. Click "Run workflow" |
| 40 | +4. Enter the new version (e.g., `1.0.1`, `1.1.0`, `2.0.0`) |
| 41 | +5. Click "Run workflow" button |
| 42 | + |
| 43 | +## Workflow Process |
| 44 | + |
| 45 | +### Automatic Release Process: |
| 46 | +``` |
| 47 | +Change version in build.gradle → Commit & Push → Release workflow runs → Tag & Release created |
| 48 | +``` |
| 49 | + |
| 50 | +### Manual Version Bump Process: |
| 51 | +``` |
| 52 | +Run Version Bump workflow → Enter new version → Version updated & committed → Release workflow runs → Tag & Release created |
| 53 | +``` |
| 54 | + |
| 55 | +## Important Notes |
| 56 | + |
| 57 | +1. **Duplicate Releases:** The workflow checks if a tag already exists to prevent duplicate releases. |
| 58 | + |
| 59 | +2. **Permissions:** The workflows use `GITHUB_TOKEN` which is automatically provided by GitHub Actions. Make sure your repository settings allow GitHub Actions to create releases. |
| 60 | + |
| 61 | +3. **Branch Protection:** If you have branch protection rules, you may need to allow the GitHub Actions bot to push to the protected branch. |
| 62 | + |
| 63 | +4. **Version Format:** Keep the version format consistent in `build.gradle`: |
| 64 | + ```groovy |
| 65 | + version = '1.0.0' |
| 66 | + ``` |
| 67 | + |
| 68 | +## Troubleshooting |
| 69 | + |
| 70 | +### Workflow doesn't trigger |
| 71 | +- Check if the workflow file is on the correct branch (`main` or `master`) |
| 72 | +- Verify repository settings allow GitHub Actions |
| 73 | + |
| 74 | +### Can't create tags or releases |
| 75 | +- Go to Settings → Actions → General → Workflow permissions |
| 76 | +- Select "Read and write permissions" |
| 77 | +- Check "Allow GitHub Actions to create and approve pull requests" |
| 78 | + |
| 79 | +### Version not extracted correctly |
| 80 | +- Ensure the version line in `build.gradle` follows the exact format: |
| 81 | + ```groovy |
| 82 | + version = '1.0.0' |
| 83 | + ``` |
| 84 | + (Single quotes, no extra spaces) |
| 85 | + |
| 86 | +## Examples |
| 87 | + |
| 88 | +### Example 1: Regular Release |
| 89 | +1. Update version in `build.gradle` to `1.0.1` |
| 90 | +2. Commit: `git commit -am "chore: bump version to 1.0.1"` |
| 91 | +3. Push: `git push` |
| 92 | +4. Workflow automatically creates tag `v1.0.1` and release |
| 93 | + |
| 94 | +### Example 2: Using Version Bump Workflow |
| 95 | +1. Go to Actions → Version Bump → Run workflow |
| 96 | +2. Enter version: `1.1.0` |
| 97 | +3. Workflow updates `build.gradle`, commits, and triggers release |
| 98 | + |
| 99 | +### Example 3: Manual Trigger |
| 100 | +1. Go to Actions → Create Release → Run workflow |
| 101 | +2. Select branch |
| 102 | +3. Run workflow (uses current version in `build.gradle`) |
| 103 | + |
0 commit comments