|
| 1 | +# Release Workflow |
| 2 | + |
| 3 | +A reusable GitHub Actions workflow for automating releases of Gradle-based projects with semantic |
| 4 | +versioning, Maven publishing, and branch management. |
| 5 | + |
| 6 | +## Overview |
| 7 | + |
| 8 | +The release workflow (`release.yml`) provides: |
| 9 | + |
| 10 | +- **Semantic versioning** - Automatic version bumping (major, minor, patch) |
| 11 | +- **Maven publishing** - Build and publish to Maven Central |
| 12 | +- **Branch management** - Automatic syncing of main, develop, and ci-release branches |
| 13 | +- **GitHub releases** - Automatic release creation with generated notes |
| 14 | +- **Snapshot support** - Optional snapshot releases without branch updates |
| 15 | +- **Signing** - Automatic artifact signing with GPG |
| 16 | + |
| 17 | +## Usage |
| 18 | + |
| 19 | +### In Your Project |
| 20 | + |
| 21 | +Create a workflow file (e.g., `.github/workflows/publish-new-version.yml`) in your project: |
| 22 | + |
| 23 | +```yaml |
| 24 | +name: Publish New Version |
| 25 | + |
| 26 | +on: |
| 27 | + workflow_dispatch: |
| 28 | + inputs: |
| 29 | + bump: |
| 30 | + description: 'Version bump type (major, minor, patch)' |
| 31 | + required: true |
| 32 | + type: choice |
| 33 | + options: |
| 34 | + - patch |
| 35 | + - minor |
| 36 | + - major |
| 37 | + snapshot: |
| 38 | + description: 'Snapshot release' |
| 39 | + required: false |
| 40 | + type: boolean |
| 41 | + default: false |
| 42 | + |
| 43 | +concurrency: |
| 44 | + group: release |
| 45 | + cancel-in-progress: false |
| 46 | + |
| 47 | +jobs: |
| 48 | + release: |
| 49 | + uses: GetStream/stream-build-conventions-android/.github/workflows/release.yml@develop |
| 50 | + with: |
| 51 | + bump: ${{ inputs.bump }} |
| 52 | + snapshot: ${{ inputs.snapshot }} |
| 53 | + secrets: |
| 54 | + github-token: ${{ secrets.STREAM_PUBLIC_BOT_TOKEN }} |
| 55 | + maven-central-username: ${{ secrets.MAVEN_USERNAME }} |
| 56 | + maven-central-password: ${{ secrets.MAVEN_PASSWORD }} |
| 57 | + signing-key: ${{ secrets.SIGNING_KEY }} |
| 58 | + signing-key-id: ${{ secrets.SIGNING_KEY_ID }} |
| 59 | + signing-key-password: ${{ secrets.SIGNING_PASSWORD }} |
| 60 | +``` |
| 61 | +
|
| 62 | +### Requirements |
| 63 | +
|
| 64 | +Your project must have: |
| 65 | +
|
| 66 | +1. **Branch structure**: |
| 67 | + - `develop` - Development branch (default branch to release from) |
| 68 | + - `main` - Production branch |
| 69 | + - `ci-release` - Created automatically during release |
| 70 | + |
| 71 | +2. **Version file**: A properties file with semantic version (defaults to `gradle.properties`, but |
| 72 | + can be customized via the `version-properties-file` input): |
| 73 | + ```properties |
| 74 | + version=1.2.3 |
| 75 | + ``` |
| 76 | + |
| 77 | +3. **Gradle project**: A Gradle project with a `publish` task configured |
| 78 | + |
| 79 | +## Inputs |
| 80 | + |
| 81 | +| Input | Required | Default | Description | |
| 82 | +|---------------------------|----------|---------------------|-------------------------------------------------| |
| 83 | +| `bump` | Yes | - | Version bump type: `major`, `minor`, or `patch` | |
| 84 | +| `snapshot` | No | `false` | Whether this is a snapshot release | |
| 85 | +| `version-properties-file` | No | `gradle.properties` | Path to file containing version | |
| 86 | + |
| 87 | +## Secrets |
| 88 | + |
| 89 | +| Secret | Required | Description | |
| 90 | +|--------------------------|----------|-------------------------------------------------------------------------------------| |
| 91 | +| `github-token` | Yes | GitHub token with repo with write permissions (i.e. able to push to main & develop) | |
| 92 | +| `maven-central-username` | Yes | Maven Central username for publishing | |
| 93 | +| `maven-central-password` | Yes | Maven Central password for publishing | |
| 94 | +| `signing-key` | Yes | GPG signing key for artifact signing | |
| 95 | +| `signing-key-id` | Yes | GPG signing key ID | |
| 96 | +| `signing-key-password` | Yes | GPG signing key password | |
| 97 | + |
| 98 | +## Snapshot vs Production Releases |
| 99 | + |
| 100 | +Both release types bump the version and run `./gradlew publish`. The key differences: |
| 101 | + |
| 102 | +| Feature | Production (`snapshot: false`) | Snapshot (`snapshot: true`) | |
| 103 | +|--------------------|--------------------------------|-----------------------------| |
| 104 | +| Version commit | Pushed to ci-release | Local only | |
| 105 | +| Branch updates | main and develop synced | No branches updated | |
| 106 | +| GitHub release | Created with tag | Not created | |
| 107 | +| `SNAPSHOT` env var | `"false"` | `"true"` | |
| 108 | + |
| 109 | +## Environment Variables |
| 110 | + |
| 111 | +The workflow sets these environment variables during the publish step: |
| 112 | + |
| 113 | +| Variable | Description | |
| 114 | +|-------------------------------------------------|----------------------------------------------------------------| |
| 115 | +| `SNAPSHOT` | `"true"` or `"false"` - Access via `System.getenv("SNAPSHOT")` | |
| 116 | +| `ORG_GRADLE_PROJECT_RELEASE_SIGNING_ENABLED` | Always `"true"` | |
| 117 | +| `ORG_GRADLE_PROJECT_mavenCentralUsername` | From secrets | |
| 118 | +| `ORG_GRADLE_PROJECT_mavenCentralPassword` | From secrets | |
| 119 | +| `ORG_GRADLE_PROJECT_signingInMemoryKey` | From secrets | |
| 120 | +| `ORG_GRADLE_PROJECT_signingInMemoryKeyId` | From secrets | |
| 121 | +| `ORG_GRADLE_PROJECT_signingInMemoryKeyPassword` | From secrets | |
0 commit comments