Skip to content

Commit

Permalink
Merge pull request #2 from yumemi-inc/feature/publish_via_github_pack…
Browse files Browse the repository at this point in the history
…ages

GitHub Packages での公開設定
  • Loading branch information
warahiko authored Nov 28, 2023
2 parents b963cca + dddf7f8 commit e959289
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 42 deletions.
2 changes: 0 additions & 2 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
name-template: 'v$NEXT_PATCH_VERSION 🌈'
tag-template: 'v$NEXT_PATCH_VERSION'
template: |
## What’s Changed
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/publish-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Publish to GitHub Packages

on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+-alpha[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+-beta[0-9]+"

jobs:
build:
runs-on: ubuntu-22.04
permissions:
contents: write
packages: write
steps:
- name: Check out
uses: actions/checkout@v3
- name: Setup java
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
- name: Publish package
run: ./gradlew publishAllPublicationsToGithubPackagesRepository
env:
ORG_GRADLE_PROJECT_githubPackagesPassword: ${{ secrets.GITHUB_TOKEN }}
ORG_GRADLE_PROJECT_githubPackagesUsername: ${{ github.actor }}
20 changes: 18 additions & 2 deletions .github/workflows/update-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,29 @@ name: Update release

on:
push:
branches:
- main
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+-alpha[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+-beta[0-9]+"

jobs:
update_draft_release:
runs-on: ubuntu-latest
steps:
- name: Detect unstable release
id: detect_unstable_release
run: |
set -ev
stable_regex="^v[0-9]+\.[0-9]+\.[0-9]+$"
is_prerelease=$( if [[ ${{ github.ref_name }} =~ $stable_regex ]]; then echo "false"; else echo "true"; fi )
echo "IS_PRERELEASE=$is_prerelease" >> $GITHUB_OUTPUT
- uses: release-drafter/release-drafter@v5
with:
name: ${{ github.ref_name }} 🌈
tag: ${{ github.ref_name }}
version: ${{ github.ref_name }}
prerelease: ${{ steps.detect_unstable_release.outputs.IS_PRERELEASE }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ Make sure to read the [Contributing](CONTRIBUTING.md) page first though.

```
Copyright 2020 The Android Open Source Project
Copyright 2023 Yumemi, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
54 changes: 29 additions & 25 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright 2020 The Android Open Source Project
* Copyright 2023 Yumemi, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -37,6 +38,8 @@ buildscript {
plugins {
id "com.diffplug.spotless" version "6.5.2"
alias(libs.plugins.jetbrains.dokka)

alias(libs.plugins.gitVersion)
}

apply plugin: 'com.dropbox.affectedmoduledetector'
Expand Down Expand Up @@ -192,34 +195,35 @@ subprojects {
}

afterEvaluate {
def composeSnapshot = libs.versions.composesnapshot.get()
if (composeSnapshot.length() > 1) {
// We're depending on a Jetpack Compose snapshot, update the library version name
// to indicate it's from a Compose snapshot
def versionName = project.properties.get('VERSION_NAME')
if (versionName.contains("SNAPSHOT")) {
version = versionName.replace('-SNAPSHOT', ".compose-${composeSnapshot}-SNAPSHOT")
def hasMavenPublishPlugin = project.plugins.hasPlugin(libs.plugins.vanniktech.maven.publish.get().pluginId)
if (!hasMavenPublishPlugin) return

// https://vanniktech.github.io/gradle-maven-publish-plugin/other/#github-packages-example
publishing {
repositories {
maven {
name = "githubPackages"
url = "https://maven.pkg.github.com/yumemi-inc/accompanist"
// username and password (a personal Github access token) should be specified as
// `githubPackagesUsername` and `githubPackagesPassword` Gradle properties or alternatively
// as `ORG_GRADLE_PROJECT_githubPackagesUsername` and `ORG_GRADLE_PROJECT_githubPackagesPassword`
// environment variables
credentials(PasswordCredentials)
}
}
}

if (!version.endsWith('SNAPSHOT')) {
// If we're not a SNAPSHOT library version, we fail the build if we're relying on
// any snapshot dependencies
configurations.configureEach { configuration ->
configuration.dependencies.configureEach { dependency ->
if (dependency instanceof ProjectDependency) {
// We don't care about internal project dependencies
return
}

def depVersion = dependency.version
if (depVersion != null && depVersion.endsWith('SNAPSHOT')) {
throw new IllegalArgumentException(
"Using SNAPSHOT dependency with non-SNAPSHOT library version: $dependency"
)
}
}
mavenPublishing {
// https://github.com/palantir/gradle-git-version
def trimVersionPrefix = { String versionStr ->
versionStr.startsWith('v') ? versionStr - 'v' : versionStr
}
def versionName = (gitVersion >> trimVersionPrefix)()

coordinates(
project.properties.get('GROUP'),
project.properties.get('POM_ARTIFACT_ID'),
versionName,
)
}
}
}
23 changes: 10 additions & 13 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#
# Copyright 2020 The Android Open Source Project
# Copyright 2023 Yumemi, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -23,31 +24,27 @@ org.gradle.parallel=true
android.useAndroidX=true

# Increase memory
org.gradle.jvmargs=-Xmx4096m -XX:MaxMetaspaceSize=2048m -XX:+HeapDumpOnOutOfMemoryError
org.gradle.jvmargs=-Xmx4096m -XX:MaxMetaspaceSize=4096m -XX:+HeapDumpOnOutOfMemoryError

# Required to publish to Nexus (see https://github.com/gradle/gradle/issues/11308)
systemProp.org.gradle.internal.publish.checksums.insecure=true

# Increase timeout when pushing to Sonatype (otherwise we get timeouts)
systemProp.org.gradle.internal.http.socketTimeout=120000

GROUP=com.google.accompanist
# !! No longer need to update this manually when using a Compose SNAPSHOT
VERSION_NAME=0.33.3-SNAPSHOT
GROUP=jp.co.yumemi.compose.accompanist

POM_DESCRIPTION=Utilities for Jetpack Compose

POM_URL=https://github.com/google/accompanist/
POM_SCM_URL=https://github.com/google/accompanist/
POM_SCM_CONNECTION=scm:git:git://github.com/google/accompanist.git
POM_SCM_DEV_CONNECTION=scm:git:git://github.com/google/accompanist.git
POM_URL=https://github.com/yumemi-inc/accompanist
POM_SCM_URL=https://github.com/yumemi-inc/accompanist
POM_SCM_CONNECTION=scm:git:git://github.com/yumemi-inc/accompanist.git
POM_SCM_DEV_CONNECTION=scm:git:git://github.com/yumemi-inc/accompanist.git

POM_LICENCE_NAME=The Apache Software License, Version 2.0
POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
POM_LICENCE_DIST=repo

POM_DEVELOPER_ID=google
POM_DEVELOPER_NAME=Google

SONATYPE_HOST=DEFAULT
RELEASE_SIGNING_ENABLED=true
POM_DEVELOPER_ID=yumemi-inc
POM_DEVELOPER_NAME=YUMEMI Inc.
POM_DEVELOPER_URL=https://github.com/yumemi-inc/
6 changes: 6 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ androidxWindow = "1.0.0"
metalava = "0.3.2"
vanniktechPublish = "0.25.2"

# plugin
# https://github.com/palantir/gradle-git-version
gitVersion = "3.0.0"

[libraries]
compose-ui-ui = { module = "androidx.compose.ui:ui", version.ref = "compose" }
compose-ui-util = { module = "androidx.compose.ui:ui-util", version.ref = "compose" }
Expand Down Expand Up @@ -112,3 +116,5 @@ android-lint = { id = "com.android.lint", version.ref = "androidlint"}
jetbrains-dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
gradle-metalava = { id = "me.tylerbwong.gradle.metalava", version.ref = "metalava" }
vanniktech-maven-publish = { id = "com.vanniktech.maven.publish", version.ref = "vanniktechPublish" }

gitVersion = { id = "com.palantir.git-version", version.ref = "gitVersion" }

0 comments on commit e959289

Please sign in to comment.