Skip to content

Commit 40180ad

Browse files
authored
Add GitHub action to publish package (#49)
* Add release drafter * Add GitHub Action for publishing package * Fix build * Bump version * Clean up * ci: trigger pipeline * Add env variables to ci build
1 parent 09a21b4 commit 40180ad

File tree

9 files changed

+204
-18
lines changed

9 files changed

+204
-18
lines changed

.github/pull_request_template.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
### Breaking Changes
2+
<!-- Optional - List any backward incompatible changes -->
3+
4+
### New Features
5+
<!-- Optional - List new functionality added -->
6+
7+
### Bug Fixes
8+
<!-- Optional - List bugs fixed in this release -->
9+
10+
### Checklist
11+
- [ ] Version bumped
12+
- [ ] Documentation updated

.github/release-drafter-config.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name-template: "v$RESOLVED_VERSION 🚀"
2+
tag-template: "v$RESOLVED_VERSION"
3+
categories:
4+
- title: "⚠️ Breaking Changes"
5+
labels:
6+
- "breaking"
7+
- "major"
8+
- title: "🚀 Features"
9+
labels:
10+
- "feature"
11+
- "enhancement"
12+
- title: "🐛 Bug Fixes"
13+
labels:
14+
- "fix"
15+
- "bugfix"
16+
- "bug"
17+
- title: "🧰 Maintenance"
18+
labels:
19+
- "chore"
20+
- "maintenance"
21+
- title: "📚 Documentation"
22+
labels:
23+
- "documentation"
24+
- title: "⬆️ Dependencies"
25+
collapse-after: 5
26+
labels:
27+
- "dependencies"
28+
29+
change-template: "- $TITLE @$AUTHOR (#$NUMBER)"
30+
change-title-escapes: '\<*_&'
31+
version-resolver:
32+
major:
33+
labels:
34+
- "major"
35+
- "breaking"
36+
minor:
37+
labels:
38+
- "minor"
39+
- "feature"
40+
patch:
41+
labels:
42+
- "patch"
43+
- "fix"
44+
- "bugfix"
45+
- "bug"
46+
default: patch
47+
48+
sort-by: "merged_at"
49+
sort-direction: "descending"
50+
51+
exclude-labels:
52+
- "skip-changelog"
53+
54+
autolabeler:
55+
- label: "documentation"
56+
files:
57+
- "*.md"
58+
- label: "bug"
59+
branch:
60+
- '/fix\/.+/'
61+
title:
62+
- "/fix/i"
63+
- label: "feature"
64+
branch:
65+
- '/feature\/.+/'
66+
- label: "dependencies"
67+
files:
68+
- "yarn.lock"
69+
70+
template: |
71+
## Changes in Release v$RESOLVED_VERSION
72+
73+
$CHANGES
74+
75+
**Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION

.github/workflows/ci.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v3
15+
16+
- name: Set up JDK 17
17+
uses: actions/setup-java@v3
18+
with:
19+
java-version: '17'
20+
distribution: 'temurin'
21+
cache: gradle
22+
23+
- name: Grant execute permission for gradlew
24+
run: chmod +x gradlew
25+
26+
- name: Build with Gradle
27+
env:
28+
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
29+
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
30+
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
31+
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
32+
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
33+
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
34+
run: ./gradlew build

.github/workflows/publish.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Publish Authsignal Android Package
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
publish:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v3
13+
14+
- name: Set up JDK 17
15+
uses: actions/setup-java@v3
16+
with:
17+
java-version: '17'
18+
distribution: 'temurin'
19+
cache: gradle
20+
21+
- name: Grant execute permission for gradlew
22+
run: chmod +x gradlew
23+
24+
- name: Build and Publish
25+
env:
26+
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
27+
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
28+
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
29+
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
30+
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
31+
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
32+
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository

.github/workflows/release-drafter.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Release Drafter
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
types: [opened, reopened, synchronize]
9+
workflow_dispatch:
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
update_release_draft:
16+
permissions:
17+
contents: write
18+
pull-requests: write
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: release-drafter/release-drafter@v6
22+
with:
23+
config-name: release-drafter-config.yml
24+
env:
25+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2023 Authsignal
3+
Copyright (c) 2025 Authsignal
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

build.gradle.kts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,18 @@ allprojects {
2424
}
2525
}
2626

27+
fun getProperty(propertyName: String, gradleLocalPropertyName: String = propertyName): String {
28+
return System.getenv(propertyName) ?: gradleLocalProperties(rootDir).getProperty(gradleLocalPropertyName) ?: ""
29+
}
30+
2731
nexusPublishing {
2832
repositories {
2933
sonatype {
30-
val properties = gradleLocalProperties(rootDir)
31-
32-
username.set(properties.getProperty("ossrhUsername"))
33-
password.set(properties.getProperty("ossrhPassword"))
34-
stagingProfileId.set(properties.getProperty("sonatypeStagingProfileId"))
35-
nexusUrl.set(uri(properties.getProperty("nexusUrl")))
36-
snapshotRepositoryUrl.set(uri(properties.getProperty("snapshotRepositoryUrl")))
34+
username.set(getProperty("OSSRH_USERNAME", "ossrhUsername"))
35+
password.set(getProperty("OSSRH_PASSWORD", "ossrhPassword"))
36+
stagingProfileId.set(getProperty("SONATYPE_STAGING_PROFILE_ID", "sonatypeStagingProfileId"))
37+
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
38+
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
3739
}
3840
}
3941
}

module/build.gradle.kts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties
2+
import org.gradle.api.GradleException
23

34
plugins {
45
id("com.android.library")
@@ -39,6 +40,10 @@ android {
3940
}
4041
}
4142

43+
fun getProperty(propertyName: String, gradleLocalPropertyName: String = propertyName): String {
44+
return System.getenv(propertyName) ?: gradleLocalProperties(rootDir).getProperty(gradleLocalPropertyName) ?: ""
45+
}
46+
4247
val sourcesJar by tasks.creating(Jar::class) {
4348
archiveClassifier.set("sources")
4449
from(android.sourceSets.getByName("main").java.srcDirs)
@@ -97,15 +102,16 @@ publishing {
97102
}
98103

99104
signing {
100-
val properties = gradleLocalProperties(rootDir)
101-
102-
useInMemoryPgpKeys(
103-
properties.getProperty("signing.keyId"),
104-
properties.getProperty("signing.key"),
105-
properties.getProperty("signing.password"),
106-
)
107-
108-
sign(publishing.publications)
105+
val signingKeyId = getProperty("SIGNING_KEY_ID", "signing.keyId")
106+
val signingKey = getProperty("SIGNING_KEY", "signing.key")
107+
val signingPassword = getProperty("SIGNING_PASSWORD", "signing.password")
108+
109+
if (signingKeyId.isNotEmpty() && signingKey.isNotEmpty() && signingPassword.isNotEmpty()) {
110+
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
111+
sign(publishing.publications)
112+
} else {
113+
throw GradleException("Signing information incomplete. Publishing requires valid signing configuration.")
114+
}
109115
}
110116

111117
val ktorVersion: String by project

module/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
pomName=Authsignal SDK for Android
22
pomArtifactId=authsignal-android
3-
versionName=2.2.6
3+
versionName=2.2.7
44
versionCode=2025
55

0 commit comments

Comments
 (0)