Skip to content

Commit

Permalink
ci(modules): build and publish modules separately (cryostatio#426)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores authored Jul 19, 2024
1 parent f6da0a3 commit 7439c76
Show file tree
Hide file tree
Showing 18 changed files with 1,363 additions and 4 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,26 @@ jobs:
key: ${{ runner.os }}-build-${{ hashFiles('**/pom.xml') }}
- run: mvn -B -U clean install


build-libcryostat:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
- uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
- run: cd libcryostat
- uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-build-${{ hashFiles('**/pom.xml') }}
- run: mvn -B -U clean install

build-cryostat:
needs: [build-core]
runs-on: ubuntu-latest
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/maven-central-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@ name: Publish a new Maven Central release
on:
workflow_call:
inputs:
jdk-version:
description: 'JDK version for build'
required: true
type: string
publish-cmd:
description: 'Command to perform publish'
required: true
type: string
publish-directory:
description: 'Directory to perform publish'
required: true
type: string

jobs:
build:
Expand All @@ -20,11 +28,11 @@ jobs:
- name: Java setup
uses: actions/setup-java@v3
with:
java-version: '17'
java-version: ${{ inputs.jdk-version }}
distribution: 'temurin'
cache: maven
- name: Run a build of the code base before release
run: ./mvnw --batch-mode --no-transfer-progress clean install
run: cd ${{ inputs.publish-directory }} && ./mvnw --batch-mode --no-transfer-progress clean install
# - name: Set release version
# run: ./mvnw --batch-mode --no-transfer-progress versions:set -DnewVersion=${{ github.event.inputs.version }}
- name: Release with JReleaser
Expand Down
19 changes: 18 additions & 1 deletion .github/workflows/push-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- run: mvn -B -U clean verify

get-version:
runs-on: ubuntu-latest
outputs:
Expand All @@ -28,10 +31,24 @@ jobs:
run: |
PROJECT_VERSION="$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)"
echo "project-version=${PROJECT_VERSION}" >> "${GITHUB_OUTPUT}"
publish-snapshot:
publish-core-snapshot:
needs: get-version
uses: ./.github/workflows/maven-central-publish.yml
secrets: inherit
with:
jdk-version: 17
publish-direectory: 'cryostat-core'
publish-cmd: './release-snapshot.sh'
if: ${{ github.repository_owner == 'cryostatio' && endsWith(needs.get-version.outputs.project-version, '-SNAPSHOT') }}


publish-libcryostat-snapshot:
needs: get-version
uses: ./.github/workflows/maven-central-publish.yml
secrets: inherit
with:
jdk-version: 11
publish-direectory: 'libcryostat'
publish-cmd: './release-snapshot.sh'
if: ${{ github.repository_owner == 'cryostatio' && endsWith(needs.get-version.outputs.project-version, '-SNAPSHOT') }}
14 changes: 13 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,21 @@ on:
# required: true

jobs:
publish-release:

publish-release-core:
uses: ./.github/workflows/maven-central-publish.yml
secrets: inherit
with:
jdk-version: 17
publish-directory: 'cryostat-core'
publish-cmd: './release.sh'
if: ${{ github.repository_owner == 'cryostatio' }}

publish-release-libcryostat:
uses: ./.github/workflows/maven-central-publish.yml
secrets: inherit
with:
jdk-version: 11
publish-directory: 'libcryostat'
publish-cmd: './release.sh'
if: ${{ github.repository_owner == 'cryostatio' }}
98 changes: 98 additions & 0 deletions cryostat-core/.mvn/wrapper/MavenWrapperDownloader.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/

import java.io.IOException;
import java.io.InputStream;
import java.net.Authenticator;
import java.net.PasswordAuthentication;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;

public final class MavenWrapperDownloader
{
private static final String WRAPPER_VERSION = "3.2.0";

private static final boolean VERBOSE = Boolean.parseBoolean( System.getenv( "MVNW_VERBOSE" ) );

public static void main( String[] args )
{
log( "Apache Maven Wrapper Downloader " + WRAPPER_VERSION );

if ( args.length != 2 )
{
System.err.println( " - ERROR wrapperUrl or wrapperJarPath parameter missing" );
System.exit( 1 );
}

try
{
log( " - Downloader started" );
final URL wrapperUrl = new URL( args[0] );
final String jarPath = args[1].replace( "..", "" ); // Sanitize path
final Path wrapperJarPath = Paths.get( jarPath ).toAbsolutePath().normalize();
downloadFileFromURL( wrapperUrl, wrapperJarPath );
log( "Done" );
}
catch ( IOException e )
{
System.err.println( "- Error downloading: " + e.getMessage() );
if ( VERBOSE )
{
e.printStackTrace();
}
System.exit( 1 );
}
}

private static void downloadFileFromURL( URL wrapperUrl, Path wrapperJarPath )
throws IOException
{
log( " - Downloading to: " + wrapperJarPath );
if ( System.getenv( "MVNW_USERNAME" ) != null && System.getenv( "MVNW_PASSWORD" ) != null )
{
final String username = System.getenv( "MVNW_USERNAME" );
final char[] password = System.getenv( "MVNW_PASSWORD" ).toCharArray();
Authenticator.setDefault( new Authenticator()
{
@Override
protected PasswordAuthentication getPasswordAuthentication()
{
return new PasswordAuthentication( username, password );
}
} );
}
try ( InputStream inStream = wrapperUrl.openStream() )
{
Files.copy( inStream, wrapperJarPath, StandardCopyOption.REPLACE_EXISTING );
}
log( " - Downloader complete" );
}

private static void log( String msg )
{
if ( VERBOSE )
{
System.out.println( msg );
}
}

}
Binary file added cryostat-core/.mvn/wrapper/maven-wrapper.jar
Binary file not shown.
18 changes: 18 additions & 0 deletions cryostat-core/.mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.1/apache-maven-3.9.1-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
Loading

0 comments on commit 7439c76

Please sign in to comment.