Skip to content

Commit

Permalink
Build: Configure CI workflow for publishing to GitHub Packages
Browse files Browse the repository at this point in the history
  • Loading branch information
tamaracha committed Sep 16, 2024
1 parent 5d3ccec commit 777d269
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 9 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ indent_style = space
indent_size = 4
tab_width = 4
max_line_length = 120

[*.yml]
indent_size = 2
tab_width = 2
32 changes: 32 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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
19 changes: 10 additions & 9 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
15 changes: 15 additions & 0 deletions plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import java.net.URI

plugins {
kotlin("jvm") version "2.0.20"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 777d269

Please sign in to comment.