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
Changes from 2 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/${{github.repository}} -PpublishUsername=${{github.actor}} -PpublishPassword=${{secrets.GITHUB_TOKEN}} ${{env.GRADLE_OPTS}}