From 0e0d0158ae9ed9edfc2ae1f98b5e08e90ae1fdbb Mon Sep 17 00:00:00 2001 From: a dinosaur Date: Mon, 3 Jul 2023 16:04:22 +1000 Subject: [PATCH] maven publishing workflow --- .github/workflows/plugin.yml | 17 +++++++++++++++ .github/workflows/publish.yml | 23 +++++++++++++++++++++ build.gradle.kts | 39 +++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 .github/workflows/plugin.yml create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/plugin.yml b/.github/workflows/plugin.yml new file mode 100644 index 0000000..319666a --- /dev/null +++ b/.github/workflows/plugin.yml @@ -0,0 +1,17 @@ +name: Plugin +on: [push] +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + - name: Build with Gradle + uses: gradle/gradle-build-action@v2 + with: + arguments: build diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..df88231 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,23 @@ +name: Publish +on: + push: + branches: + - master +jobs: + publish: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + - name: Publish with Gradle + uses: gradle/gradle-build-action@v2 + with: + arguments: publishAllPublicationsToGitHubPackagesRepository publishAllPublicationsToGitLabRepository + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + GITLAB_TOKEN: "${{ secrets.GITLAB_TOKEN }}" diff --git a/build.gradle.kts b/build.gradle.kts index f47af0c..cfc5190 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,7 @@ plugins { `kotlin-dsl` kotlin("plugin.serialization") version "1.5.31" + `maven-publish` } group = "gay.pizza.foundation" @@ -37,3 +38,41 @@ gradlePlugin { } } } + +publishing { + repositories { + mavenLocal() + + var githubPackagesToken = System.getenv("GITHUB_TOKEN") + if (githubPackagesToken == null) { + githubPackagesToken = project.findProperty("github.token") as String? + } + + var gitlabPackagesToken = System.getenv("GITLAB_TOKEN") + if (gitlabPackagesToken == null) { + gitlabPackagesToken = project.findProperty("gitlab.com.accessToken") as String? + } + + maven { + name = "GitHubPackages" + url = uri("https://maven.pkg.github.com/gaypizzaspecifications/drywall") + credentials { + username = project.findProperty("github.username") as String? ?: "gaypizzaspecifications" + password = githubPackagesToken + } + } + + maven { + name = "GitLab" + url = uri("https://gitlab.com/api/v4/projects/47347654/packages/maven") + credentials(HttpHeaderCredentials::class.java) { + name = "Private-Token" + value = gitlabPackagesToken + } + + authentication { + create("header") + } + } + } +}