From a0d838052e4f594a52b20186bf1c4abe0668eb5a Mon Sep 17 00:00:00 2001 From: Fabian Steeg Date: Tue, 4 May 2021 16:42:25 +0200 Subject: [PATCH] Publish GitHub Packages by pushing to remote `publish` branch See https://github.com/metafacture/metafacture-core/issues/356 --- .github/workflows/publish.yml | 18 ++++++++++++++++++ build.gradle | 30 ++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..e856c585 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,18 @@ +name: Publish package to GitHub Packages +on: + push: + branches: + - 'publish' +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: Publish package + run: gradle publish + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + diff --git a/build.gradle b/build.gradle index f3ebaae3..4e59e7a2 100644 --- a/build.gradle +++ b/build.gradle @@ -43,6 +43,7 @@ subprojects { apply plugin: 'eclipse' apply plugin: 'java' apply plugin: 'org.xtext.builder' + apply plugin: 'maven-publish' apply from: "${rootDir}/gradle/source-layout.gradle" @@ -73,6 +74,35 @@ subprojects { options.compilerArgs << '-Werror' } + + publishing { + publications { + mavenArtifacts(MavenPublication) { + from components.java + afterEvaluate { + groupId = project.group + artifactId = project.name + } + } + } + repositories { + maven { + name = 'LocalEmbedded' + // run generated gradle task `./gradlew + // publishMavenArtifactsPublicationToLocalEmbeddedRepository` + // to publish all subprojects into the same local embedded repo: + url = "file://${rootDir}/build/repo" + } + maven { + name = "GitHubPackages" + url = "https://maven.pkg.github.com/metafacture/metafacture-fix" + credentials { + username = System.getenv("GITHUB_ACTOR") + password = System.getenv("GITHUB_TOKEN") + } + } + } + } } task installServer(type: Copy) {