Skip to content

Commit 026d4f1

Browse files
committed
ci: add GitHub Packages publishing and fix release permissions
- Add contents: write permission to github-release job - Add publish-github-packages job using GITHUB_TOKEN (no extra secrets needed) - Register GitHubPackages Maven repository for all publishable submodules
1 parent a56fea5 commit 026d4f1

2 files changed

Lines changed: 56 additions & 3 deletions

File tree

.github/workflows/release.yml

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ jobs:
99
github-release:
1010
name: Create GitHub Release
1111
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
1214

1315
steps:
1416
- name: Checkout
@@ -41,8 +43,41 @@ jobs:
4143
See [CHANGELOG.md](CHANGELOG.md) for what's changed in this release.
4244
generate_release_notes: true
4345

46+
publish-github-packages:
47+
name: Publish to GitHub Packages
48+
runs-on: ubuntu-latest
49+
needs: github-release
50+
permissions:
51+
contents: read
52+
packages: write
53+
54+
steps:
55+
- name: Checkout
56+
uses: actions/checkout@v4
57+
58+
- name: Set up JDK 17
59+
uses: actions/setup-java@v4
60+
with:
61+
java-version: '17'
62+
distribution: 'temurin'
63+
64+
- name: Set up Gradle
65+
uses: gradle/actions/setup-gradle@v4
66+
67+
- name: Run tests
68+
run: ./gradlew test --stacktrace
69+
70+
- name: Check public API compatibility
71+
run: ./gradlew apiCheck
72+
73+
- name: Publish to GitHub Packages
74+
run: ./gradlew publishAllPublicationsToGitHubPackagesRepository --no-configuration-cache
75+
env:
76+
ORG_GRADLE_PROJECT_githubPackagesUsername: ${{ github.actor }}
77+
ORG_GRADLE_PROJECT_githubPackagesPassword: ${{ secrets.GITHUB_TOKEN }}
78+
4479
# Uncomment and configure when Maven Central secrets are set up:
45-
# publish:
80+
# publish-maven-central:
4681
# name: Publish to Maven Central
4782
# runs-on: ubuntu-latest
4883
# needs: github-release
@@ -53,8 +88,6 @@ jobs:
5388
# java-version: '17'
5489
# distribution: 'temurin'
5590
# - uses: gradle/actions/setup-gradle@v4
56-
# with:
57-
# cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
5891
# - run: ./gradlew test --stacktrace
5992
# - run: ./gradlew apiCheck
6093
# - run: ./gradlew publishAllPublicationsToMavenCentralRepository --no-configuration-cache

build.gradle.kts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,23 @@ apiValidation {
1313
ignoredProjects += setOf("sample-app")
1414
nonPublicMarkers += setOf("io.squarescreen.core.ExperimentalSquareScreenApi")
1515
}
16+
17+
// Register GitHub Packages as a publish target for all submodules that apply the
18+
// maven-publish plugin. The task `publishAllPublicationsToGitHubPackagesRepository`
19+
// is automatically generated by Gradle for a repository named "GitHubPackages".
20+
subprojects {
21+
afterEvaluate {
22+
extensions.findByType(org.gradle.api.publish.PublishingExtension::class.java)?.apply {
23+
repositories {
24+
maven {
25+
name = "GitHubPackages"
26+
url = uri("https://maven.pkg.github.com/Perpectiv-Global/square-screen-android-sdk")
27+
credentials {
28+
username = project.findProperty("githubPackagesUsername") as String? ?: ""
29+
password = project.findProperty("githubPackagesPassword") as String? ?: ""
30+
}
31+
}
32+
}
33+
}
34+
}
35+
}

0 commit comments

Comments
 (0)