From 777d26986becdedb300fde9e812fb05fbd22f94f Mon Sep 17 00:00:00 2001 From: Tamara Cook <10754072+tamaracha@users.noreply.github.com> Date: Mon, 16 Sep 2024 21:08:14 +0200 Subject: [PATCH] Build: Configure CI workflow for publishing to GitHub Packages --- .editorconfig | 4 ++++ .github/workflows/publish.yml | 32 ++++++++++++++++++++++++++++++++ .github/workflows/validate.yml | 19 ++++++++++--------- plugin/build.gradle.kts | 15 +++++++++++++++ 4 files changed, 61 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/publish.yml diff --git a/.editorconfig b/.editorconfig index 7c6849e..3860999 100644 --- a/.editorconfig +++ b/.editorconfig @@ -6,3 +6,7 @@ indent_style = space indent_size = 4 tab_width = 4 max_line_length = 120 + +[*.yml] +indent_size = 2 +tab_width = 2 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..e8aef91 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,32 @@ +name: Publish package + +on: + release: + types: [created] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + publish-gh-packages: + name: Publish to GitHub Packages + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Setup Java + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: 22 + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 + - name: Publish Plugin + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ORG_GRADLE_PROJECT_signingKey: "${{ secrets.ORG_GRADLE_PROJECT_SIGNINGKEY }}" + ORG_GRADLE_PROJECT_signingPassword: "${{ secrets.ORG_GRADLE_PROJECT_SIGNINGPASSWORD }}" + run: ./gradlew publish diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 96aed15..348ad5d 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -3,13 +3,13 @@ name: Plugin Validation # Controls when the workflow will run on: # Triggers the workflow on push or pull request events but only for the "main" branch - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: + workflow_dispatch: # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: @@ -27,8 +27,9 @@ jobs: uses: gradle/actions/setup-gradle@v4 - name: Validate Plugin env: - GRADLE_PUBLISH_KEY: "${{ secrets.GRADLE_PUBLISH_KEY }}" - GRADLE_PUBLISH_SECRET: "${{ secrets.GRADLE_PUBLISH_SECRET }}" - ORG_GRADLE_PROJECT_signingKey: "${{ secrets.ORG_GRADLE_PROJECT_SIGNINGKEY }}" - ORG_GRADLE_PROJECT_signingPassword: "${{ secrets.ORG_GRADLE_PROJECT_SIGNINGPASSWORD }}" + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ORG_GRADLE_PROJECT_signingKey: "${{ secrets.ORG_GRADLE_PROJECT_SIGNINGKEY }}" + ORG_GRADLE_PROJECT_signingPassword: "${{ secrets.ORG_GRADLE_PROJECT_SIGNINGPASSWORD }}" + GRADLE_PUBLISH_KEY: "${{ secrets.GRADLE_PUBLISH_KEY }}" + GRADLE_PUBLISH_SECRET: "${{ secrets.GRADLE_PUBLISH_SECRET }}" run: ./gradlew publishPlugins --validate-only diff --git a/plugin/build.gradle.kts b/plugin/build.gradle.kts index b1cec22..3c3e90c 100644 --- a/plugin/build.gradle.kts +++ b/plugin/build.gradle.kts @@ -1,4 +1,5 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import java.net.URI plugins { kotlin("jvm") version "2.0.20" @@ -35,6 +36,20 @@ signing { val signingPassword: String? by project useInMemoryPgpKeys(signingKey, signingPassword) } + +publishing { + repositories { + maven { + name = "GitHubPackages" + url = URI.create("https://maven.pkg.github.com/infolektuell/gradle-jextract") + credentials { + username = providers.environmentVariable("GITHUB_ACTOR").get() + password = providers.environmentVariable("GITHUB_TOKEN").get() + } + } + } +} + java { toolchain.languageVersion = JavaLanguageVersion.of(22) targetCompatibility = JavaVersion.VERSION_21