diff --git a/.github/workflows/main-pipeline.yml b/.github/workflows/main-pipeline.yml new file mode 100644 index 0000000..8bd552e --- /dev/null +++ b/.github/workflows/main-pipeline.yml @@ -0,0 +1,16 @@ +name: main pipeline + +on: + push: + branches: + - 'master' +jobs: + test_libraries: + uses: blockchain/devx-workflows/.github/workflows/library-pipeline.yml@0.0.35 + with: + version_script: scripts/version.sh + library_script: scripts/publish_lib.sh + build_docker_image: eu.gcr.io/blockchain-internal/build_common_jvm8-v2 + secrets: + nexus_password: ${{ secrets.NEXUS_PASSWORD }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/pr-pipeline.yml b/.github/workflows/pr-pipeline.yml new file mode 100644 index 0000000..0d1e16c --- /dev/null +++ b/.github/workflows/pr-pipeline.yml @@ -0,0 +1,16 @@ +name: pr pipeline + +on: + pull_request: + types: [ opened, synchronize, reopened ] + +jobs: + test_libraries: + uses: blockchain/devx-workflows/.github/workflows/library-pipeline.yml@0.0.35 + with: + version_script: scripts/version.sh + library_script: scripts/publish_lib.sh + build_docker_image: eu.gcr.io/blockchain-internal/build_common_jvm8-v2 + secrets: + nexus_password: ${{ secrets.NEXUS_PASSWORD }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/build.gradle b/build.gradle index f817b00..aba8875 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,5 @@ allprojects { group = 'com.blockchain.btcd-cli4j' - version = '0.5.8.16' } subprojects { diff --git a/scripts/publish_lib.sh b/scripts/publish_lib.sh new file mode 100644 index 0000000..26aa565 --- /dev/null +++ b/scripts/publish_lib.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +echo "nexusUrl=https://nexus.internal.blockchain.info" >> gradle.properties +echo "nexusUsername=github-actions" >> gradle.properties +echo "nexusPassword=$NEXUS_PASSWORD" >> gradle.properties +echo "gradleCachePassword=" >> gradle.properties + +chown -R blockchain:blockchain $PWD +su blockchain -c "./gradlew publish --no-daemon -Pversion=$VERSION" || true \ No newline at end of file diff --git a/scripts/version.sh b/scripts/version.sh new file mode 100755 index 0000000..09b46d4 --- /dev/null +++ b/scripts/version.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +BUILD_VERSION=0.5.8 +if [ "$GITHUB_REF" = "refs/heads/master" ] + then + LAST_VERSION=$(git tag --sort=-v:refname --merged | grep -E '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | head -n1) + echo "$LAST_VERSION" | grep -Ev '^$' > /dev/null || exit 1 + if [[ "$LAST_VERSION" == ${BUILD_VERSION}.* ]] + then BUILD_NUM=$(( 1 + $( cut -d. -f4 <<< "${LAST_VERSION}") )) + else BUILD_NUM=0 + fi + echo "${BUILD_VERSION}.${BUILD_NUM}" + else + GIT_COMMIT=$( git rev-parse --short HEAD ) + echo "$GITHUB_HEAD_REF"-"$GIT_COMMIT" +fi \ No newline at end of file