Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add workflow action to publish artifacts #54

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 83 additions & 1 deletion .github/workflows/pravega-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,48 @@ on:
- main # On every push to the main branch.
pull_request: # On every pull request, regardless of source/target branch.

# Define a few constants that are shared across all the jobs (copied from Pravega workload)
env:
BUILD_CACHE_PATH: ./*
GLOBAL_CACHE_PATH: |
~/.gradle
~/.m2
GLOBAL_CACHE_KEY: gradle-m2-java-11
GLOBAL_CACHE_RESTORE_KEYS: |
gradle-m2-java-
gradle-m2
# We cache the class files, resources and build output. This is generated on the build job and reused in dependent jobs.
# If there are subsequent builds this includes test execution.
BUILD_CACHE_PATH: |
.gradle
./bin
**/bin
**/build

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Build Information
run: echo Building a '${{ github.event_name }}' for target '${{ github.ref }}'.
- name: Checkout
uses: actions/checkout@v2
- name: Gradle & Maven Cache
uses: actions/[email protected]
with:
path: ${{env.GLOBAL_CACHE_PATH}}
key: ${{env.GLOBAL_CACHE_KEY}}
restore-keys: ${{env.GLOBAL_CACHE_RESTORE_KEYS}}
- name: Build Output Cache
uses: actions/[email protected]
with:
path: ${{env.BUILD_CACHE_PATH}}
key: ${{github.ref}}-${{github.run_id}}-${{github.job}}
restore-keys: |
${{github.ref}}
- name: Clean
if: ${{ startsWith(github.ref, 'refs/heads/') }}
run: ./gradlew clean ${{env.GRADLE_OPTS}}
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
Expand All @@ -47,6 +81,22 @@ jobs:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Gradle & Maven Cache
uses: actions/[email protected]
with:
path: ${{env.GLOBAL_CACHE_PATH}}
key: ${{env.GLOBAL_CACHE_KEY}}
restore-keys: ${{env.GLOBAL_CACHE_RESTORE_KEYS}}
- name: Build Output Cache
uses: actions/[email protected]
with:
path: ${{env.BUILD_CACHE_PATH}}
key: ${{github.ref}}-${{github.run_id}}-${{github.job}}
restore-keys: |
${{github.ref}}-${{github.run_id}}
${{github.ref}}
- name: Build Output Cache
uses: actions/[email protected]
with:
Expand All @@ -62,3 +112,35 @@ jobs:
steps:
- name: Check Build Status
run: echo build, unit and integration tests successful.

snapshot:
name: Publish snapshot packages
needs: [build_and_test_complete]
# Only run this on PUSH (no pull requests) and only on the main branch and (future) release branches.
# if: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/r0.') || startsWith(github.ref, 'refs/heads/r1.')) }}
# Temp comment out above 'if' statement so we can publish the artifacts and verify it works on the 'push' to the forked branch
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Gradle & Maven Cache
uses: actions/[email protected]
with:
path: ${{env.GLOBAL_CACHE_PATH}}
key: ${{env.GLOBAL_CACHE_KEY}}
restore-keys: ${{env.GLOBAL_CACHE_RESTORE_KEYS}}
- name: Build Output Cache
uses: actions/[email protected]
with:
path: ${{env.BUILD_CACHE_PATH}}
key: ${{github.ref}}-${{github.run_id}}-${{github.job}}
restore-keys: |
${{github.ref}}-${{github.run_id}}
${{github.ref}}
- name: Assemble
run: ./gradlew assemble --parallel ${{env.GRADLE_OPTS}}
- name: Publish to GitHub Packages
run: ./gradlew publish -PpublishUrl=https://maven.pkg.github.com/pravega/presto-connector -PpublishUsername=${{github.actor}} -PpublishPassword=${{secrets.GITHUB_TOKEN}} ${{env.GRADLE_OPTS}}

85 changes: 85 additions & 0 deletions gradle/maven.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/**
* Copyright Pravega Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
plugins.withId('maven') {
uploadArchives {
repositories {
mavenDeployer {
// Only configure publishing if a URL was provided
if (project.hasProperty("publishUrl")) {
if (publishUrl == "mavenCentral") {
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: publishUsername, password: publishPassword)
}
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: publishUsername, password: publishPassword)
}
} else {
repository(url: publishUrl) {
// Only configure credentials if they are provided (allows publishing to the filesystem)
if (project.hasProperty("publishUsername") && project.hasProperty("publishPassword")) {
authentication(userName: publishUsername, password: publishPassword)
}
}
}
}

/* pom.artifactId = "presto-connector" + project.path.replace(':', '-') */
pom.artifactId = "pravega-trino-connector"
pom.project {
name "Pravega Presto Connector"
url "https://pravega.io"
description "Streaming Storage Platform"
scm {
url 'https://github.com/pravega/pravega/tree/master'
connection 'scm:git:git://github.com/pravega/presto-connector.git'
developerConnection 'scm:git:https://github.com/pravega/presto-connector.git'
}
licenses {
license {
name 'The Apache License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id 'chipmaurer'
name 'Chip Maurer'
}
}
}

// Sign the POM when the signing plugin is present
plugins.withId('signing') {
if (project.hasProperty('doSigning')) {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
}
}
}
}
}

install {
repositories {
mavenInstaller {
/* pom.artifactId = "presto-connector" + project.path.replace(':', '-') */
pom.artifactId = "pravega-trino-connector"
}
}
}

task publish(dependsOn:'uploadArchives') {
}
}
8 changes: 3 additions & 5 deletions prestodb/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,18 @@ plugins {
}

apply from: "$rootDir/gradle/checkstyle.gradle"
apply from: "$rootDir/gradle/maven.gradle"

repositories {
mavenLocal()

maven {
url = uri('https://oss.jfrog.org/jfrog-dependencies')
url = uri('https://repo.maven.apache.org/maven2')
}

maven {
url = uri('https://jitpack.io')
}

maven {
url = uri('https://repo.maven.apache.org/maven2')
}
}

dependencies {
Expand Down Expand Up @@ -104,6 +101,7 @@ distributions {
contents {
distributionBaseName = 'pravega-presto-connector'
from jar
from(project.configurations.runtime)
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions trino/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ plugins {
id 'maven'
}
apply from: "$rootDir/gradle/checkstyle.gradle"
apply from: "$rootDir/gradle/maven.gradle"

repositories {
mavenLocal()
Expand Down Expand Up @@ -111,6 +112,7 @@ distributions {
contents {
distributionBaseName = 'pravega-trino-connector'
from jar
from(project.configurations.runtime)
}
}
}
Expand Down