Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Publish Android package

on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: Maven version to publish (for example 0.1.0-alpha.1)
required: true
type: string

permissions:
contents: read
packages: write

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '21'
- uses: gradle/actions/setup-gradle@v4
with:
gradle-version: 8.14.3
- name: Test and publish GitHub Package
run: >-
gradle
:amll:testDebugUnitTest
:amll:assembleRelease
:amll:publishReleasePublicationToGitHubPackagesRepository
env:
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AMLL_VERSION: ${{ github.event_name == 'release' && github.event.release.tag_name || inputs.version }}
26 changes: 25 additions & 1 deletion amll/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,38 @@ dependencies {
testImplementation("junit:junit:4.13.2")
}

val publicationVersion =
providers.environmentVariable("AMLL_VERSION")
.orElse(providers.gradleProperty("amllVersion"))
.orElse("0.1.0-SNAPSHOT")
.map { it.removePrefix("v") }

val githubActor = providers.environmentVariable("GITHUB_ACTOR")
val githubToken = providers.environmentVariable("GITHUB_TOKEN")

afterEvaluate {
publishing {
publications {
create<MavenPublication>("release") {
from(components["release"])
groupId = "dev.yaqmc"
artifactId = "amll-android"
version = "0.1.0-SNAPSHOT"
version = publicationVersion.get()
}
}

// Keep ordinary local/PR builds credential-free. GitHub Packages is only registered when
// both credentials are present, which GitHub Actions supplies in the publish workflow.
if (githubActor.isPresent && githubToken.isPresent) {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/YAQMC/amll-android")
credentials {
username = githubActor.get()
password = githubToken.get()
}
}
}
}
}
Expand Down
Loading