Skip to content

Commit a56742e

Browse files
committed
Add automated GitHub release workflow
1 parent a599413 commit a56742e

File tree

3 files changed

+85
-2
lines changed

3 files changed

+85
-2
lines changed

.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+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
release:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v6
19+
20+
- name: Set up JDK 17
21+
uses: actions/setup-java@v5
22+
with:
23+
java-version: '17'
24+
distribution: 'temurin'
25+
cache: 'gradle'
26+
27+
- name: Grant execute permission for gradlew
28+
run: chmod +x gradlew
29+
30+
- name: Resolve release version
31+
shell: bash
32+
run: |
33+
set -euo pipefail
34+
VERSION="${GITHUB_REF_NAME#v}"
35+
echo "VERSION=${VERSION}" >> "$GITHUB_ENV"
36+
37+
- name: Build release artifacts
38+
run: ./gradlew clean :library:assembleRelease :library:publishReleasePublicationToMavenLocal -PLIBRARY_VERSION="$VERSION" -x test
39+
40+
- name: Collect release artifacts
41+
shell: bash
42+
run: |
43+
set -euo pipefail
44+
ARTIFACT_ID="counttimeprogressview"
45+
MAVEN_DIR="$HOME/.m2/repository/com/sfyc/ctpv/${ARTIFACT_ID}/${VERSION}"
46+
mkdir -p release-artifacts
47+
cp "library/build/outputs/aar/library-release.aar" "release-artifacts/${ARTIFACT_ID}-${VERSION}.aar"
48+
cp "${MAVEN_DIR}/${ARTIFACT_ID}-${VERSION}-sources.jar" "release-artifacts/"
49+
cp "${MAVEN_DIR}/${ARTIFACT_ID}-${VERSION}.pom" "release-artifacts/"
50+
cp "${MAVEN_DIR}/${ARTIFACT_ID}-${VERSION}.module" "release-artifacts/"
51+
(cd release-artifacts && zip "${ARTIFACT_ID}-${VERSION}.zip" *)
52+
53+
- name: Create or update GitHub Release
54+
env:
55+
GH_TOKEN: ${{ github.token }}
56+
shell: bash
57+
run: |
58+
set -euo pipefail
59+
if gh release view "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
60+
gh release upload "$GITHUB_REF_NAME" release-artifacts/* --repo "$GITHUB_REPOSITORY" --clobber
61+
else
62+
gh release create "$GITHUB_REF_NAME" release-artifacts/* \
63+
--repo "$GITHUB_REPOSITORY" \
64+
--title "CountTimeProgressView ${VERSION}" \
65+
--generate-notes
66+
fi

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,23 @@ countTimeProgressView.startCountTimeAnimation();
223223
- **Jetpack Compose adapter**: `CountTimeProgressViewCompose.create(context) { ... }` for use in `AndroidView`
224224
- **Zero library dependencies**: library module has no runtime dependency on AppCompat
225225

226+
## GitHub Release
227+
228+
GitHub Releases are generated automatically when a version tag is pushed.
229+
230+
```bash
231+
git tag v2.1.1
232+
git push origin v2.1.1
233+
```
234+
235+
The release workflow strips the optional `v` prefix and builds the library with that version. It uploads:
236+
237+
- `counttimeprogressview-<version>.aar`
238+
- `counttimeprogressview-<version>-sources.jar`
239+
- `counttimeprogressview-<version>.pom`
240+
- `counttimeprogressview-<version>.module`
241+
- `counttimeprogressview-<version>.zip`
242+
226243
## Customization
227244

228245
Please feel free to :)

library/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ if (project.hasProperty('signing.keyId')) {
88
apply plugin: 'signing'
99
}
1010

11-
version = '2.1.0'
11+
version = findProperty('LIBRARY_VERSION') ?: '2.1.0'
1212
group = 'com.sfyc.ctpv'
1313

1414
android {
@@ -19,7 +19,7 @@ android {
1919
minSdk rootProject.ext.min_sdk_version
2020
targetSdk rootProject.ext.target_sdk_version
2121
versionCode 5
22-
versionName '2.1.0'
22+
versionName project.version.toString()
2323

2424
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
2525
}

0 commit comments

Comments
 (0)