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

Continuous integration and Sonatype publishing #3

Merged
merged 5 commits into from
Jul 13, 2023
Merged
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
142 changes: 142 additions & 0 deletions .github/workflows/build-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
# This workflow builds the API and releases it to Maven-Sonatype-Central repository

name: Build and deploy jSnapLoader

# Runs this workflow [on-release] only
on:
# Triggers the workflow on push or pull request events but only for the "master" branch
release:
types: [published]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

jobs:
compile-assemble:
# runner images with architectures (variants)
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ 'ubuntu-latest' ]
name: Compile java and assemble jar

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout Job
uses: actions/checkout@v3

- name: Setup Temurin-OpenJDK-19
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '19'

- name: Compiling java
run: ./gradlew --console="verbose" -Pversion=${GITHUB_REF_NAME} :snaploader:build

- name: Archive build
uses: actions/upload-artifact@v3
with:
name: snaploader-build
path: snaploader/build/libs

deploy:
environment:
name: maven-central
url: https://repo.maven.apache.org/maven2/io/github/software-hardware-codesign/
runs-on: ${{ matrix.os }}
needs: [compile-assemble]
strategy:
matrix:
os: [ 'ubuntu-latest' ]
name: Deploying to Maven-Central repository

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout Job
uses: actions/checkout@v3

- name: Setup Temurin-OpenJDK-19
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '19'

- name: Setup maven-3.9
run: |
# remove shipped maven-3.8 that causes the plexus plugin incompatibility behavior
sudo apt remove maven
# installs maven-3.9 with the fixed plugins patch
chmod +rwx ./helper-scripts/project-impl/publishing/install-maven-latest.sh
./helper-scripts/project-impl/publishing/install-maven-latest.sh

- name: Use Predefined PGP Keybox
run: gpg --import ./helper-scripts/project-impl/publishing/avrsandbox.pub

- name: Import secret-key
run: gpg --allow-secret-key-import --import --batch --yes --passphrase="avrsandbox" ./helper-scripts/project-impl/publishing/secret-key

- name: Import owner-trust
run: gpg --import-ownertrust ./helper-scripts/project-impl/publishing/owner-trust.txt

- name: Send public key 'avrsandbox'
# sends the public key to a maven compatible host
run: gpg --keyserver keyserver.ubuntu.com --send-keys 85A57D4975B6EE2B6D0EA46903DE10B9F12F0B20

- name: Generate sources jar
run: ./gradlew -Pversion=$GITHUB_REF_NAME :snaploader:generateSourcesJar

- name: Generate javadoc jar
run: ./gradlew -Pversion=$GITHUB_REF_NAME :snaploader:generateJavadocJar

- name: Download build
uses: actions/download-artifact@v3
with:
name: snaploader-build
path: snaploader/build/libs/

- name: Deploying snaploader binaries
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}
run: |
chmod +rwx ./helper-scripts/project-impl/publishing/sonatype-publish-artifacts.sh
# publish artifacts using the tag version
./helper-scripts/project-impl/publishing/sonatype-publish-artifacts.sh $GITHUB_REF_NAME

# deploy-doc:
# environment:
# name: release-documentation
# url: ${{ steps.deployment.outputs.page_url }}
# runs-on: ubuntu-latest

# steps:
# - name: Checkout
# uses: actions/checkout@v3

# - name: Generate javadoc
# run: chmod +rwx ./gradlew && ./gradlew :jme3-alloc:generateJavadocJar

# - name: Move javadocs to the deployment folder 'website'
# run: ./gradlew -Pversion=${GITHUB_REF_NAME} :jme3-alloc:manipulateJavadocForWebsite

# - name: Setup Pages
# uses: actions/configure-pages@v3

# - name: Build with Jekyll
# uses: actions/jekyll-build-pages@v1
# with:
# source: ./website
# destination: ./_site

# - name: Upload artifact
# uses: actions/upload-pages-artifact@v1

# - name: Deploy to GitHub Pages
# id: deployment
# uses: actions/deploy-pages@v1
103 changes: 103 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# This is a basic workflow to help you get started with Actions

name: Build and Test jSnapLoader

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "master" branch
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
compile-java:
# runner images with architectures (variants)
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ 'ubuntu-latest' ]
name: Compile java

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout Job
uses: actions/checkout@v3

- name: Setup Temurin-JDK-19
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '19'

- name: Compiling java
run: ./gradlew --console="verbose" :snaploader:build

- name: Archive build
uses: actions/upload-artifact@v3
with:
name: snaploader-snapshot
path: snaploader/build/libs/

test-doc-generation:
# a linux runner image with the ndk installed and llvm ready to compile android native binaries
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ 'ubuntu-latest' ]
name: Generating documentation

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout Job
uses: actions/checkout@v3

- name: Setup Oracle-JDK-19
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '19'

- name: Generate javadoc
run: chmod +rwx ./gradlew && ./gradlew :snaploader:generateJavadocJar

test:
# runner images with architectures (variants)
runs-on: ${{ matrix.os }}
needs: assemble-desktop
strategy:
matrix:
os: [ 'ubuntu-latest', 'macos-latest', 'windows-latest' ]
name: Testing jme3-alloc on ${{ matrix.os }} for x86-64

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout Job
uses: actions/checkout@v3

- name: Setup Temurin-JDK-19
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '19'

- name: Download snaploader.jar library
uses: actions/download-artifact@v3
with:
name: snaploader-snapshot
path: snaploader/build/libs/

- name: Run com.avrsandbox.snaploader.examples.TestBasicFeatures
run: ./gradlew :snaploader-examples:TestBasicFeatures :snaploader-examples:run

- name: Run com.avrsandbox.snaploader.examples.TestMultipleLoads
run: ./gradlew :snaploader-examples:TestMultipleLoads :snaploader-examples:run

- name: Run com.avrsandbox.snaploader.examples.TestZipExtractor
run: ./gradlew :snaploader-examples:TestZipExtractor :snaploader-examples:run

- name: List extracted files
run: ls ./snaploader-examples/build/libs/
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ build
bin

.vscode

apache-maven-3.9.3

apache-maven-3.9.3-bin.tar.gz
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version=SNAPSHOT
19 changes: 19 additions & 0 deletions helper-scripts/abstract/abstract-checksum-generator.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

function getMd5Checksum() {
local input=$1
local output=$2

md5sum "$input" > "$output"

return $?
}

function getSha1Checksum() {
local input=$1
local output=$2

sha1sum "$input" > "$output"

return $?
}
10 changes: 10 additions & 0 deletions helper-scripts/abstract/abstract-move-files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

function move() {
local src=$1
local dest=$2

mv -uv $src $dest

return $?
}
62 changes: 62 additions & 0 deletions helper-scripts/abstract/abstract-sonatype-publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash

function generateGenericPom() {
local groupId=$1
local artifactId=$2
local version=$3
local output=$4

config="<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd\"> \
<modelVersion>4.0.0</modelVersion> \
<groupId>${groupId}</groupId> \
<artifactId>${artifactId}</artifactId> \
<version>${version}</version> \
<name>jSnapLoader API</name> \
<packaging>jar</packaging> \
<description>A high-performance cross-platform dynamic library loader API for JVM Applications with file locator and file extractor interfaces.</description> \
<url>https://github.com/Software-Hardware-Codesign/jSnapLoader</url> \
<licenses> \
<license> \
<name>The AvrSandbox Project, jSnapLoader BSD-3 Clause License</name> \
<url>https://github.com/Software-Hardware-Codesign/jSnapLoader/blob/master/LICENSE</url> \
</license> \
</licenses> \
<developers> \
<developer> \
<name>Pavly Gerges aka. pavl_g</name> \
<email>pepogerges33@gmail.com</email> \
<organization>AvrSandbox Project</organization> \
<organizationUrl>https://github.com/Software-Hardware-Codesign</organizationUrl> \
</developer> \
</developers> \
<scm> \
<connection>scm:git://github.com/Software-Hardware-Codesign/jSnapLoader.git</connection> \
<developerConnection>scm:git:ssh://github.com/Software-Hardware-Codesign/jSnapLoader.git</developerConnection> \
<url>https://github.com/Software-Hardware-Codesign/jSnapLoader/tree/master</url> \
</scm> \
</project> \
"
echo $config > ${output}
}

function publishBuild() {
local artifactId=$1
local artifact=$2
local version=$3
local javadoc_jar=$4
local sources_jar=$5
local pomFile=$6

${maven_bin} gpg:sign-and-deploy-file -s ${settings} -Durl=${sonatype_url} \
-DartifactId=${artifactId} \
-DrepositoryId=${repository} \
-Dversion=${version} \
-DpomFile=${pomFile} \
-Dgpg.passphrase=${passphrase} \
-Dfile=${artifact} \
-Djavadoc=${javadoc_jar} \
-Dsources=${sources_jar}


return $?
}
Binary file not shown.
16 changes: 16 additions & 0 deletions helper-scripts/project-impl/publishing/install-maven-latest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

source "./helper-scripts/project-impl/variables.sh"

function downloadMavenLatest() {
wget "https://dlcdn.apache.org/maven/maven-3/${maven_version}/binaries/apache-maven-${maven_version}-bin.tar.gz"
return $?
}

function extractMavenLatest() {
tar xzvf "./apache-maven-${maven_version}-bin.tar.gz"
return $?
}

downloadMavenLatest
extractMavenLatest
12 changes: 12 additions & 0 deletions helper-scripts/project-impl/publishing/maven-settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>ossrh</id>
<username>${env.OSSRH_USERNAME}</username>
<password>${env.OSSRH_TOKEN}</password>
</server>
</servers>
</settings>
3 changes: 3 additions & 0 deletions helper-scripts/project-impl/publishing/owner-trust.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# List of assigned trustvalues, created Thu 13 Jul 2023 12:01:36 AM EAT
# (Use "gpg --import-ownertrust" to restore them)
85A57D4975B6EE2B6D0EA46903DE10B9F12F0B20:6:
Binary file added helper-scripts/project-impl/publishing/secret-key
Binary file not shown.
Loading
Loading