Skip to content

Commit

Permalink
Publishing staging version with io.github.gradle-nexus.publish-plugin…
Browse files Browse the repository at this point in the history
… (WIP)
  • Loading branch information
vsuharnikov committed Oct 12, 2023
1 parent dfea3df commit 2983802
Show file tree
Hide file tree
Showing 2 changed files with 149 additions and 137 deletions.
268 changes: 136 additions & 132 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,120 +15,122 @@ env:
# GITHUB_CONTEXT: ${{ toJson(github) }} # For debugging purposes

jobs:
build-native:
name: ${{ matrix.platform }}/${{ matrix.arch }} library
runs-on: ${{ matrix.os }}
env:
# Where a library should be
target-path: ${{ matrix.jni-platform }}/${{ matrix.arch }}

# Rust build target
build-target: ${{ matrix.build-arch }}-${{ matrix.build-platform }}

# Rust target directory
TARGET_DIR: ./target

# Emit backtraces on panics.
RUST_BACKTRACE: 1
strategy:
matrix:
platform: [ linux, osx, windows ]
arch: [ aarch64, amd64, x86 ]
exclude:
- platform: osx
arch: x86
- platform: windows
arch: aarch64

include:
- platform: linux
os: ubuntu-20.04
build-platform: unknown-linux-gnu
artifact: libzwaves_jni.so
jni-platform: linux64

- platform: linux
arch: aarch64
extra-packages: gcc-aarch64-linux-gnu

- platform: linux
arch: x86
extra-packages: gcc-multilib
jni-platform: linux32

- platform: osx
os: macos-latest
build-platform: apple-darwin
artifact: libzwaves_jni.dylib
jni-platform: osx64

- platform: windows
os: windows-2019
build-platform: pc-windows-msvc # x86 and gcc lead to "undefined reference to _Unwind_Resume"
artifact: zwaves_jni.dll
jni-platform: windows64

- platform: windows
arch: x86
jni-platform: windows32

- arch: aarch64
build-arch: aarch64

- arch: amd64
build-arch: x86_64

- arch: x86
build-arch: i686
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Print debug information
run: |
echo "Build target: ${{ env.build-target }}"
echo "Target path: ${{ env.target-path }}"
- name: Install build tools
if: ${{ matrix.extra-packages }}
run: |
sudo apt-get update
sudo apt-get install -y ${{ matrix.extra-packages }}
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
target: ${{ env.build-target }}

- name: Enable Rust dependencies caching
uses: Swatinem/rust-cache@v2

- name: Run Rust tests
# Architecture is always x86-64: https://stackoverflow.com/a/71220337
if: matrix.arch == 'amd64'
run: |
cd zwaves_jni
cargo test --lib --target ${{ env.build-target }}
- name: Build native libraries
run: |
cd zwaves_jni
cargo build --release --target ${{ env.build-target }}
cd ..
cp target/${{ env.build-target }}/release/${{ matrix.artifact }} ${{ env.NATIVE_DIR }}/${{ env.target-path }}
- name: Upload result
uses: actions/upload-artifact@v3
with:
name: native-libraries
path: ${{ env.NATIVE_DIR }}/**/*

# build-native:
# name: ${{ matrix.platform }}/${{ matrix.arch }} library
# runs-on: ${{ matrix.os }}
# env:
# # Where a library should be
# target-path: ${{ matrix.jni-platform }}/${{ matrix.arch }}
#
# # Rust build target
# build-target: ${{ matrix.build-arch }}-${{ matrix.build-platform }}
#
# # Rust target directory
# TARGET_DIR: ./target
#
# # Emit backtraces on panics.
# RUST_BACKTRACE: 1
# strategy:
# matrix:
## platform: [ linux, osx, windows ]
## arch: [ aarch64, amd64, x86 ]
# platform: [ linux ]
# arch: [ amd64 ]
# exclude:
# - platform: osx
# arch: x86
# - platform: windows
# arch: aarch64
#
# include:
# - platform: linux
# os: ubuntu-20.04
# build-platform: unknown-linux-gnu
# artifact: libzwaves_jni.so
# jni-platform: linux64
#
## - platform: linux
## arch: aarch64
## extra-packages: gcc-aarch64-linux-gnu
##
## - platform: linux
## arch: x86
## extra-packages: gcc-multilib
## jni-platform: linux32
##
## - platform: osx
## os: macos-latest
## build-platform: apple-darwin
## artifact: libzwaves_jni.dylib
## jni-platform: osx64
##
## - platform: windows
## os: windows-2019
## build-platform: pc-windows-msvc # x86 and gcc lead to "undefined reference to _Unwind_Resume"
## artifact: zwaves_jni.dll
## jni-platform: windows64
##
## - platform: windows
## arch: x86
## jni-platform: windows32
##
## - arch: aarch64
## build-arch: aarch64
#
# - arch: amd64
# build-arch: x86_64
#
## - arch: x86
## build-arch: i686
# steps:
# - name: Checkout sources
# uses: actions/checkout@v4
#
# - name: Print debug information
# run: |
# echo "Build target: ${{ env.build-target }}"
# echo "Target path: ${{ env.target-path }}"
#
# - name: Install build tools
# if: ${{ matrix.extra-packages }}
# run: |
# sudo apt-get update
# sudo apt-get install -y ${{ matrix.extra-packages }}
#
# - name: Install stable toolchain
# uses: dtolnay/rust-toolchain@stable
# with:
# toolchain: stable
# target: ${{ env.build-target }}
#
# - name: Enable Rust dependencies caching
# uses: Swatinem/rust-cache@v2
#
# - name: Run Rust tests
# # Architecture is always x86-64: https://stackoverflow.com/a/71220337
# if: matrix.arch == 'amd64'
# run: |
# cd zwaves_jni
# cargo test --lib --target ${{ env.build-target }}
#
# - name: Build native libraries
# run: |
# cd zwaves_jni
# cargo build --release --target ${{ env.build-target }}
# cd ..
#
# cp target/${{ env.build-target }}/release/${{ matrix.artifact }} ${{ env.NATIVE_DIR }}/${{ env.target-path }}
#
# - name: Upload result
# uses: actions/upload-artifact@v3
# with:
# name: native-libraries
# path: ${{ env.NATIVE_DIR }}/**/*
#
build-jni:
name: Build JNI library
runs-on: ubuntu-20.04
needs: build-native
# needs: build-native
steps:
- uses: actions/checkout@v3

Expand All @@ -138,18 +140,19 @@ jobs:
distribution: temurin
cache: gradle

- uses: actions/download-artifact@v3
with:
name: native-libraries
path: ${{ env.NATIVE_DIR }}
# - uses: actions/download-artifact@v3
# with:
# name: native-libraries
# path: ${{ env.NATIVE_DIR }}

- name: Print debug information
run: |
cd ./zwaves_jni/javalib
# About -q: https://github.com/gradle/gradle/issues/5098#issuecomment-1084652709
VERSION=$(./gradlew -q printVersion $GRADLE_EXTRA_ARGS)
PUBLISHING_TYPE=$(./gradlew -q publishingType $GRADLE_EXTRA_ARGS)
VERSION=$(./gradlew -q $GRADLE_EXTRA_ARGS printVersion)
# PUBLISHING_TYPE=$(./gradlew -q $GRADLE_EXTRA_ARGS publishingType)
PUBLISHING_TYPE=staging
# echo "$GITHUB_CONTEXT" # For debugging purposes
Expand All @@ -159,26 +162,27 @@ jobs:
# Make environment variables available in the next step
echo "PUBLISHING_TYPE=${PUBLISHING_TYPE}" >> $GITHUB_ENV
- name: Run tests
run: |
cd zwaves_jni/javalib
./gradlew ${GRADLE_EXTRA_ARGS} test
- name: Publish snapshot version
if: ${{ env.PUBLISHING_TYPE == 'snapshot' }}
run: |
cd zwaves_jni/javalib
./gradlew publishToSonatype ${GRADLE_EXTRA_ARGS} \
-PsonatypeUsername='${{ secrets.OSSRH_USERNAME }}' \
-PsonatypePassword='${{ secrets.OSSRH_PASSWORD }}' \
-PgpgKey='${{ secrets.OSSRH_GPG_KEY_ASCII }}' \
-PgpgPassphrase='${{ secrets.OSSRH_GPG_PASSPHRASE }}'
# - name: Run tests
# run: |
# cd zwaves_jni/javalib
# ./gradlew ${GRADLE_EXTRA_ARGS} test

# - name: Publish snapshot version
# if: ${{ env.PUBLISHING_TYPE == 'snapshot' }}
# run: |
# cd zwaves_jni/javalib
# ./gradlew ${GRADLE_EXTRA_ARGS} publishToSonatype \
# -PsonatypeUsername='${{ secrets.OSSRH_USERNAME }}' \
# -PsonatypePassword='${{ secrets.OSSRH_PASSWORD }}' \
# -PgpgKey='${{ secrets.OSSRH_GPG_KEY_ASCII }}' \
# -PgpgPassphrase='${{ secrets.OSSRH_GPG_PASSPHRASE }}'

- name: Publish staging version
if: ${{ env.PUBLISHING_TYPE == 'staging' }}
run: |
cd zwaves_jni/javalib
./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository ${GRADLE_EXTRA_ARGS} \
# publishToSonatype closeAndReleaseSonatypeStagingRepository \
./gradlew -PrefName=v0.1.7 retrieveSonatypeStagingProfile \
-PsonatypeUsername='${{ secrets.OSSRH_USERNAME }}' \
-PsonatypePassword='${{ secrets.OSSRH_PASSWORD }}' \
-PgpgKey='${{ secrets.OSSRH_GPG_KEY_ASCII }}' \
Expand Down
18 changes: 13 additions & 5 deletions zwaves_jni/javalib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def pr() { project.findProperty('pr').toString() ?: "" }
def refName() { project.findProperty('refName').toString() ?: "" }

ext {
baseVersion = "0.2.0"
baseVersion = "0.1.7"

publishingType = {
if (pr()?.isNumber()) "snapshot" else if (refName() == "v${baseVersion}") "staging" else "prohibited"
Expand Down Expand Up @@ -57,7 +57,9 @@ publishing {
from components.java

pom {
name.set("zwaves")
packaging = 'jar'
url = 'https://github.com/wavesplatform/zwaves'

licenses {
license {
name.set("MIT License")
Expand All @@ -76,16 +78,22 @@ publishing {

signing {
useInMemoryPgpKeys(project.findProperty('gpgKey') as String, project.findProperty('gpgPassphrase') as String)
sign(publishing.publications.mavenJava)
sign configurations.archives
}

nexusPublishing {
repositories {
sonatype {
snapshotRepositoryUrl.set(uri("https://oss.sonatype.org/content/repositories/snapshots"))
nexusUrl.set(uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/"))
username = project.findProperty('sonatypeUsername')
password = project.findProperty('sonatypePassword')
// username = project.findProperty('sonatypeUsername')
// password = project.findProperty('sonatypePassword')
}
}
}

//nexusPublishing {
// repositories {
// sonatype()
// }
//}

0 comments on commit 2983802

Please sign in to comment.