Skip to content

Commit 9fb1876

Browse files
committed
Extract generic release workflow
1 parent 348636b commit 9fb1876

File tree

3 files changed

+212
-26
lines changed

3 files changed

+212
-26
lines changed

.github/workflows/README.md

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
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: ${{ github.event.inputs.bump }}
52+
snapshot: ${{ github.event.inputs.snapshot == 'true' }}
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 |
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
bump:
7+
description: 'Version bump type'
8+
required: true
9+
type: choice
10+
options:
11+
- patch
12+
- minor
13+
- major
14+
default: minor
15+
version-properties-file:
16+
description: 'Path to properties file containing version'
17+
required: false
18+
type: string
19+
default: 'gradle.properties'
20+
snapshot:
21+
description: 'Snapshot release'
22+
required: false
23+
type: boolean
24+
default: false
25+
26+
concurrency:
27+
group: release
28+
cancel-in-progress: false
29+
30+
jobs:
31+
release:
32+
permissions:
33+
contents: write
34+
uses: ./.github/workflows/release.yml
35+
with:
36+
bump: ${{ inputs.bump }}
37+
version-properties-file: ${{ inputs.version-properties-file }}
38+
snapshot: ${{ inputs.snapshot }}
39+
secrets:
40+
github-token: ${{ secrets.STREAM_PUBLIC_BOT_TOKEN }}
41+
maven-central-username: ${{ secrets.OSSRH_USERNAME }}
42+
maven-central-password: ${{ secrets.OSSRH_PASSWORD }}
43+
signing-key: ${{ secrets.SIGNING_KEY }}
44+
signing-key-id: ${{ secrets.SIGNING_KEY_ID }}
45+
signing-key-password: ${{ secrets.SIGNING_PASSWORD }}

.github/workflows/release.yml

Lines changed: 46 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,41 @@
1-
name: Release
1+
name: Release Workflow
22

33
on:
4-
workflow_dispatch:
4+
workflow_call:
55
inputs:
66
bump:
7-
description: 'Version bump type'
7+
description: 'Version bump type (major, minor, patch)'
88
required: true
9-
type: choice
10-
options:
11-
- patch
12-
- minor
13-
- major
9+
type: string
1410
version-properties-file:
1511
description: 'Path to properties file containing version'
1612
required: false
1713
type: string
1814
default: 'gradle.properties'
19-
20-
concurrency:
21-
group: release
22-
cancel-in-progress: false
15+
snapshot:
16+
description: 'Whether this is a snapshot release'
17+
required: false
18+
type: boolean
19+
default: false
20+
secrets:
21+
github-token:
22+
description: 'GitHub token with repo write permissions'
23+
required: true
24+
maven-central-username:
25+
description: 'Maven Central username'
26+
required: true
27+
maven-central-password:
28+
description: 'Maven Central password'
29+
required: true
30+
signing-key:
31+
description: 'GPG signing key'
32+
required: true
33+
signing-key-id:
34+
description: 'GPG signing key ID'
35+
required: true
36+
signing-key-password:
37+
description: 'GPG signing key password'
38+
required: true
2339

2440
jobs:
2541
publish:
@@ -29,7 +45,7 @@ jobs:
2945
- name: Checkout
3046
uses: actions/checkout@v4
3147
with:
32-
token: ${{ secrets.STREAM_PUBLIC_BOT_TOKEN }}
48+
token: ${{ secrets.github-token }}
3349
ref: develop
3450
fetch-depth: 0
3551

@@ -55,47 +71,51 @@ jobs:
5571
5672
- name: Bump version
5773
id: bump
58-
uses: ./.github/actions/bump-version
74+
uses: GetStream/stream-build-conventions-android/.github/actions/bump-version@${{ github.action_ref }}
5975
with:
60-
bump: ${{ github.event.inputs.bump }}
61-
file: ${{ github.event.inputs.version-properties-file }}
76+
bump: ${{ inputs.bump }}
77+
file: ${{ inputs.version-properties-file }}
6278

6379
- name: Commit version file
6480
uses: EndBug/[email protected]
6581
with:
66-
add: ${{ github.event.inputs.version-properties-file }}
82+
add: ${{ inputs.version-properties-file }}
6783
message: "AUTOMATION: Version Bump"
6884
default_author: github_actions
6985
push: false
7086

7187
- name: Push changes to ci-release branch
88+
if: ${{ !inputs.snapshot }}
7289
run: git push origin HEAD:ci-release --force-with-lease
7390

7491
- name: Setup Gradle
75-
uses: ./.github/actions/setup-gradle
92+
uses: GetStream/stream-build-conventions-android/.github/actions/setup-gradle@${{ github.action_ref }}
7693
with:
7794
cache-read-only: false
7895

7996
- name: Build and publish
80-
run: ./gradlew build publish --no-configuration-cache
97+
run: ./gradlew publish --no-configuration-cache
8198
env:
82-
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }}
83-
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }}
84-
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }}
85-
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }}
86-
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
99+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.maven-central-username }}
100+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.maven-central-password }}
101+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.signing-key }}
102+
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.signing-key-id }}
103+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.signing-key-password }}
87104
ORG_GRADLE_PROJECT_RELEASE_SIGNING_ENABLED: true
105+
SNAPSHOT: ${{ inputs.snapshot }}
88106

89107
- name: Create Github Release
108+
if: ${{ !inputs.snapshot }}
90109
uses: ncipollo/[email protected]
91110
with:
92111
generateReleaseNotes: true
93-
token: ${{ secrets.STREAM_PUBLIC_BOT_TOKEN }}
112+
token: ${{ secrets.github-token }}
94113
tag: v${{ steps.bump.outputs.new-version }}
95114
commit: ci-release
96115
makeLatest: true
97116

98117
sync_branches:
118+
if: ${{ !inputs.snapshot }}
99119
needs: publish
100120
name: Sync main and develop with release
101121
runs-on: ubuntu-latest
@@ -105,7 +125,7 @@ jobs:
105125
with:
106126
ref: main
107127
fetch-depth: 0
108-
token: ${{ secrets.STREAM_PUBLIC_BOT_TOKEN }}
128+
token: ${{ secrets.github-token }}
109129

110130
- name: Configure git
111131
run: |

0 commit comments

Comments
 (0)