Skip to content

Commit 538a554

Browse files
authored
Merge pull request #132 from androidbroadcast/feature/release-workflow
Add tag-triggered release workflow
2 parents 6c64a93 + b3b9f6a commit 538a554

5 files changed

Lines changed: 143 additions & 10 deletions

File tree

.github/workflows/release.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Set up JDK 21
20+
uses: actions/setup-java@v4
21+
with:
22+
java-version: '21'
23+
distribution: 'temurin'
24+
cache: gradle
25+
26+
- name: Extract version from tag
27+
id: version
28+
run: echo "TAG_VERSION=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
29+
30+
- name: Validate version matches libs.versions.toml
31+
run: |
32+
TOML_VERSION=$(grep '^vbpd = ' gradle/libs.versions.toml | sed 's/vbpd = "\(.*\)"/\1/')
33+
if [ "${{ steps.version.outputs.TAG_VERSION }}" != "$TOML_VERSION" ]; then
34+
echo "::error::Tag version (${{ steps.version.outputs.TAG_VERSION }}) does not match libs.versions.toml ($TOML_VERSION)"
35+
exit 1
36+
fi
37+
echo "Version validated: $TOML_VERSION"
38+
39+
- name: Grant execute permission for gradlew
40+
run: chmod +x gradlew
41+
42+
- name: Run checks
43+
run: ./gradlew check --no-configuration-cache
44+
45+
- name: Publish to Maven Central
46+
run: ./gradlew publishAllPublicationsToMavenCentralRepository --no-configuration-cache
47+
env:
48+
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }}
49+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }}
50+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
51+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
52+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
53+
54+
- name: Build release AARs
55+
run: ./gradlew :vbpd-core:assembleRelease :vbpd:assembleRelease :vbpd-reflection:assembleRelease --no-configuration-cache
56+
57+
- name: Create GitHub Release
58+
uses: softprops/action-gh-release@v2
59+
with:
60+
tag_name: ${{ github.ref_name }}
61+
name: ${{ github.ref_name }}
62+
generate_release_notes: true
63+
files: |
64+
vbpd-core/build/outputs/aar/vbpd-core-release.aar
65+
vbpd/build/outputs/aar/vbpd-release.aar
66+
vbpd-reflection/build/outputs/aar/vbpd-reflection-release.aar

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# ViewBindingPropertyDelegate
22

3+
[![Maven Central](https://img.shields.io/maven-central/v/dev.androidbroadcast.vbpd/vbpd)](https://central.sonatype.com/namespace/dev.androidbroadcast.vbpd)
4+
[![Build](https://github.com/androidbroadcast/ViewBindingPropertyDelegate/actions/workflows/build.yml/badge.svg)](https://github.com/androidbroadcast/ViewBindingPropertyDelegate/actions/workflows/build.yml)
5+
[![License](https://img.shields.io/github/license/androidbroadcast/ViewBindingPropertyDelegate)](LICENSE.md)
6+
37
Make work with [Android View Binding](https://d.android.com/topic/libraries/view-binding) simpler. The library:
48
- manages ViewBinding lifecycle and clears the reference to it to prevent memory leaks
59
- eliminates the need to keep nullable references to Views or ViewBindings
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Release Workflow Design
2+
3+
**Goal:** Automate the full release process — from git tag to Maven Central publication and GitHub Release creation.
4+
5+
**Current state:** Publishing is done manually from a local machine via `./gradlew publish` with credentials in `local.properties`. No automated release workflow exists.
6+
7+
---
8+
9+
## Trigger
10+
11+
Push a git tag matching `v*` (e.g., `v2.0.5`):
12+
13+
```bash
14+
git tag v2.0.5
15+
git push origin v2.0.5
16+
```
17+
18+
## Pipeline
19+
20+
```
21+
git push tag v2.0.5
22+
23+
GitHub Actions (release.yml):
24+
1. Checkout + Setup JDK 21
25+
2. Validate: tag version == libs.versions.toml vbpd version
26+
3. ./gradlew check (build + tests + detekt + ktlint)
27+
4. ./gradlew publishAllPublicationsToMavenCentralRepository
28+
5. Create GitHub Release (tag message as changelog)
29+
6. Upload AAR artifacts to GitHub Release
30+
```
31+
32+
## Versioning
33+
34+
Tag must match the version in `gradle/libs.versions.toml` (`vbpd = "2.0.5"`). CI validates this at step 2 — fails fast if mismatch. This prevents accidental releases with wrong versions.
35+
36+
## Credentials
37+
38+
Stored as GitHub Secrets:
39+
40+
| Secret | Purpose |
41+
|--------|---------|
42+
| `SIGNING_KEY_ID` | GPG key ID for signing |
43+
| `SIGNING_KEY` | Base64-encoded GPG private key |
44+
| `SIGNING_PASSWORD` | GPG key passphrase |
45+
| `MAVEN_CENTRAL_USERNAME` | Sonatype Central Portal username |
46+
| `MAVEN_CENTRAL_PASSWORD` | Sonatype Central Portal token |
47+
48+
## Changes Required
49+
50+
### New files
51+
- `.github/workflows/release.yml` — tag-triggered release workflow
52+
53+
### Modified files
54+
- `gradle/convetions-plugins/vbpd-library-base/src/main/kotlin/vbpdpublish.gradle.kts` — read credentials from environment variables (fallback to local.properties for local dev)
55+
- `README.md` — add CI status and Maven Central version badges
56+
57+
### Deleted files
58+
- `jitpack.yml` — JitPack is not used, config is outdated (JDK 11)
59+
60+
## Design Decisions
61+
62+
- **Tag-triggered** over workflow_dispatch: prevents accidental releases, ties version to git history
63+
- **Version validation** over auto-extraction: explicit control, no build script magic
64+
- **Environment variables** over secrets file: standard CI pattern, Vanniktech plugin supports it natively
65+
- **Keep local.properties fallback**: developers can still publish locally if needed

gradle/conventions-plugins/vbpd-library-base/src/main/kotlin/vbpdpublish.gradle.kts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import dev.androidbroadcast.vbpd.gradle.mavenPublishingConfig
44
import dev.androidbroadcast.vbpd.gradle.vanniktechMavenPublishingConfig
55
import java.util.Properties
66

7-
// generate Kotlin function read from local.properties
8-
private fun readProperties(): Properties {
9-
val localProperties = Properties()
10-
project.rootProject.file("local.properties").inputStream().use(localProperties::load)
11-
return localProperties
12-
}
7+
// CI: credentials come from environment variables (ORG_GRADLE_PROJECT_* prefix)
8+
// Local: credentials come from local.properties
9+
private val localPropertiesFile = project.rootProject.file("local.properties")
1310

14-
if (project.rootProject.file("local.properties").exists()) {
15-
val properties = readProperties()
11+
if (localPropertiesFile.exists()) {
12+
val properties = Properties().apply {
13+
localPropertiesFile.inputStream().use(::load)
14+
}
15+
// File-based signing for local development
1616
project.extra["signing.keyId"] = properties.getProperty("signing.keyId")
1717
project.extra["signing.secretKeyRingFile"] = properties.getProperty("signing.secretKeyRingFile")
1818
project.extra["signing.password"] = properties.getProperty("signing.password")

jitpack.yml

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)