[pull] master from wavesplatform:master #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish packages to OSSRH | |
on: | |
push: | |
branches: | |
- master | |
- version-[0-9].[0-9]+.x | |
tags: | |
- v[0-9].[0-9]+.[0-9]+ | |
pull_request: | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-java@v1 | |
with: | |
java-version: 1.8 | |
- uses: actions/cache@v2 | |
with: | |
key: ${{ hashFiles('pom.xml') }} | |
path: ~/.m2/repository | |
- name: Prepare version | |
id: maven-version | |
run: | | |
mvn_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) | |
git_ref=${GITHUB_REF##*/} | |
pr_number=${{ github.event.number }} | |
if [[ $git_ref =~ v[0-9]+\.[0-9]+\.[0-9]+$ ]] ; then | |
if [[ v$mvn_version != $git_ref ]] ; then | |
echo Maven version $mvn_version does not match tag $git_ref | |
exit 1 | |
fi | |
elif [[ $pr_number != "" && $mvn_version =~ -SNAPSHOT$ ]] ; then | |
pattern="s/(.+)-SNAPSHOT/\1-"$pr_number"-SNAPSHOT/g" | |
mvn_version=$(echo $mvn_version | sed -E $pattern) | |
mvn versions:set -DnewVersion=$mvn_version -DgenerateBackupPoms=false -q -DforceStdout | |
elif [[ ! $mvn_version =~ -SNAPSHOT$ ]] ; then | |
echo Refusing to publish non-snapshot version $mvn_version | |
echo '::set-output name=skip-publish::true' | |
fi | |
- uses: samuelmeuli/[email protected] | |
if: | |
${{ steps.maven-version.outputs.skip-publish != 'true' }} | |
with: | |
gpg_private_key: ${{ secrets.OSSRH_GPG_KEY_ASCII }} | |
gpg_passphrase: ${{ secrets.OSSRH_GPG_PASSPHRASE }} | |
nexus_username: ${{ secrets.OSSRH_USERNAME }} | |
nexus_password: ${{ secrets.OSSRH_PASSWORD }} |