Skip to content

show dist

show dist #21

name: Build and push to MavenCentral
on:
push:
branches:
- publish_play
# tags:
# - 0.*
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- name: Echo multiline env
run: |
echo "$XXX" > /tmp/a
ls -l /tmp
cat /tmp/a
env:
XXX: ${{ vars.TEST_MULTILINE }}
- name: List env
run: env | sort
env:
XXX: ${{ vars.TEST_MULTILINE }}
- name: Define BUILD_LABEL
env:
INPUT: ${{ github.head_ref || github.ref_name }}
run: |
echo "BUILD_LABEL=${INPUT//\//_}" >> $GITHUB_ENV
# - name: Echo env
# run: env | sort
- uses: actions/checkout@v4
- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@699bb18358f12c5b78b37bb0111d3a0e2276e0e2
# 2.1.1
- name: Set build version
# Cannot use ${BUILD_LABEL} with gradle-build-action, so stuff version
# into gradle.properties
run: sed -i 's/^version.*/version = '${BUILD_LABEL}'/;' ./gradle.properties
- name: Build release
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5
# v3.1.0
with:
# Only write to the cache for builds on the 'main' branch (default - but here for documentation)
cache-read-only: ${{ github.ref != 'refs/heads/main' }}
# arguments: javadoc publish -s
arguments: publish -s
- name: show dist
run: |
realpath build/dist
tree build/dist
# Crude upload inspired by https://mccue.dev/pages/6-1-22-upload-to-maven-central
# Avoids sharing credentials with all Gradle plugins/potential annotation processors
- name: Upload and Release Bundle
uses: jskov/action-nexus-publish@sign_and_pack
with:
signing_key: ${{ vars.TEST_SIGNING_KEY }}
signing_key_secret: ${{ vars.TEST_SIGNING_KEY_SECRET }}
search_directory: build/dist
# env:
# USERNAME: ${{ secrets.OSSRH_USERNAME }}
# PASSWORD: ${{ secrets.OSSRH_TOKEN }}
# run: |
# curl --request GET --url https://s01.oss.sonatype.org/service/local/authentication/login \
# --cookie-jar cookies.txt --user "${USERNAME}:${PASSWORD}"
# repoMetadataId=$(curl --request POST --url https://s01.oss.sonatype.org/service/local/staging/bundle_upload \
# --cookie cookies.txt --header 'Content-Type: multipart/form-data' \
# --form file=@/tmp/bundle-metadata.jar | jq -r ".repositoryUris[0]" | sed 's/.*\///')
# repoPluginId=$(curl --request POST --url https://s01.oss.sonatype.org/service/local/staging/bundle_upload \
# --cookie cookies.txt --header 'Content-Type: multipart/form-data' \
# --form file=@/tmp/bundle-plugin.jar | jq -r ".repositoryUris[0]" | sed 's/.*\///')
# echo "Wait for repos '$repoMetadataId', and '$repoPluginId' to settle.."
# # should probe for state change:
# # curl -v -H 'Accept: application/json' /tmp/cookies.txt https://s01.oss.sonatype.org/service/local/staging/repository/dkmada-1104
# # Look for type:closed
# sleep 150
# echo "Publish NOT completed! Test repo!"
# # release - unless tag starts with 0.0.
# echo $BUILD_LABEL | grep -q -v -e "^0[.]0[.]" \
# && curl --request POST \
# --url https://s01.oss.sonatype.org/service/local/staging/bulk/promote \
# --cookie cookies.txt \
# --header 'Content-Type: application/json' \
# --data "{ 'data': { 'autoDropAfterRelease': true, 'description': '', 'stagedRepositoryIds': ['$repoMetadataId', '$repoPluginId'] } }" \
# && echo "Publish completed" \
# || echo "Publish skipped / failed"
# rm -f cookies.txt