Skip to content

Commit

Permalink
Merge pull request #2 from futuredapp/feature/publishing
Browse files Browse the repository at this point in the history
Publish to Gradle Plugin Portal
  • Loading branch information
matejsemancik authored Nov 17, 2023
2 parents 0515f77 + 0195db5 commit 32d2780
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 13 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/gradle-wrapper-validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Validate Gradle Wrapper
on:
push:
branches:
- main
pull_request:
branches:
- '*'

jobs:
validation:
name: Validation
runs-on: ubuntu-latest
steps:
- name: Checkout latest code
uses: actions/checkout@v4
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
21 changes: 21 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Publish Plugin to Gradle Plugin Portal

on:
push:
tags:
- '*'

jobs:
gradle:
runs-on: ubuntu-latest
env:
GRADLE_PUBLISH_KEY: ${{ secrets.GRADLE_PUBLISH_KEY }}
GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_PUBLISH_SECRET }}
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Publish on Plugin Portal
run: ./gradlew :plugin:setupPublishSecrets :plugin:publishPlugins
if: success()
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Then add the plugin to your module-level `build.gradle` or `build.gradle.kts` fi

```kotlin
plugins {
id("app.futured.sheethappens") version "$latestVersion"
id("app.futured.sheethappens") version "0.5.6"
}
```

Expand Down Expand Up @@ -121,11 +121,24 @@ play around.
Also, [here](https://docs.google.com/spreadsheets/d/1q5WMvNFEJQts4lWkSTHN5je_BG3Wq6iRZPseN-ZHrNM/edit?usp=sharing) you
can take a look at sample Google Spreadsheet.

## Contributors

Current maintainer and main contributor is [@matejsemancik](https://github.com/matejsemancik).

For release process, see [RELEASE.md](RELEASE.md)

## Licence

This project is available under MIT license. See [LICENSE file](LICENSE) for more information.

## Credits

This Gradle plugin was inspired by
Ackee's [Spreadsheet Localizer INTELLIJ IDEA plugin](https://github.com/AckeeCZ/Spreadsheet-Localizer-Plugin) & it is
fully compatible with their Google Sheet formatting.

This plugin improves on this concept by giving you more configuration options and ability to run it from command line or
CI environment as Gradle task.
This Gradle plugin improves on this concept by giving you more configuration options and ability to run it from command
line or CI environment as Gradle task.

Various bits and pieces of inspiration were taken from https://github.com/cortinico/kotlin-gradle-plugin-template
and https://github.com/iurysza/module-graph
17 changes: 17 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## Release process

This document describes release process of this plugin into `Gradle Plugin Portal` repository.
There is only one type of publication -- release. Snapshots
are [not supported](https://plugins.gradle.org/docs/publish-plugin) by Gradle Plugin Portal.

### Release

New release is published automatically when a new tag is created which should be done by creating a new release within
GitHub UI.

#### Before release

1. Update the plugin `VERSION` property in [gradle.properties](gradle.properties) file.
2. Update the plugin version in [README](README.md) file.

CI run specification: [.github/workflows/publish.yml](.github/workflows/publish.yml)
13 changes: 13 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
kotlin.code.style=official

# region Publishing

ID=app.futured.sheethappens
VERSION=0.5.6
GROUP=app.futured.sheethappens
DISPLAY_NAME=Sheet Happens
DESCRIPTION=Gradle plugin for generating Android / KMP string translations from Google Spreadsheets
WEBSITE=https://github.com/futuredapp/sheet-happens
VCS_URL=https://github.com/futuredapp/sheet-happens
IMPLEMENTATION_CLASS=app.futured.sheethappens.plugin.SheetHappensPlugin

# endregion
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
kotlin = "1.9.20"
publish = "1.2.1"
kotlinx-serialization = "1.6.1"
sheetHappens = "0.5.5"
sheetHappens = "0.5.6"

[libraries]
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization" }
Expand Down
33 changes: 24 additions & 9 deletions plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@ plugins {
alias(libs.plugins.gradle.pluginPublish)
}

group = "app.futured.sheethappens"
version = "0.5.5"
group = property("GROUP").toString()

gradlePlugin {
website = "https://github.com/futuredapp/sheet-happens"
vcsUrl = "https://github.com/futuredapp/sheet-happens"
website = property("WEBSITE").toString()
vcsUrl = property("VCS_URL").toString()

plugins {
create("sheetHappensPlugin") {
id = "app.futured.sheethappens"
displayName = "Sheet Happens"
description = "Gradle plugin for generating Android / KMP string translations from Google Spreadsheets"
implementationClass = "app.futured.sheethappens.plugin.SheetHappensPlugin"
create(property("ID").toString()) {
id = property("ID").toString()
displayName = property("DISPLAY_NAME").toString()
description = property("DESCRIPTION").toString()
tags = listOf("plugin", "gradle", "localization", "translation", "android", "kmp")
implementationClass = property("IMPLEMENTATION_CLASS").toString()
version = property("VERSION").toString()
}
}
}
Expand All @@ -29,4 +30,18 @@ dependencies {

tasks.test {
useJUnitPlatform()
}

tasks.create("setupPublishSecrets") {
doLast {
val key = System.getenv("GRADLE_PUBLISH_KEY")
val secret = System.getenv("GRADLE_PUBLISH_SECRET")

if (key == null || secret == null) {
throw GradleException("gradlePublishKey and/or gradlePublishSecret are not defined environment variables")
}

System.setProperty("gradle.publish.key", key)
System.setProperty("gradle.publish.secret", secret)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ abstract class LocalizationUpdateTask : DefaultTask() {
abstract val splitResources: Property<Boolean>

init {
description = "Reads Google Sheet and generates XML string resources"
group = "localization"
}

Expand Down

0 comments on commit 32d2780

Please sign in to comment.