diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..c26f7da --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,52 @@ +name: release + +on: + push: + branches: [ main ] + tags: 'ipresource-*' + +jobs: + build: + if: github.repository == 'RIPE-NCC/ipresource' + runs-on: ubuntu-latest + steps: + - name: Prepare environment + run: | + sudo apt-get install rsync git gnupg + + - name: Checkout Code + uses: actions/checkout@v3.2.0 + + - name: Setup Java + uses: actions/setup-java@v1.4.3 + with: + java-version: 8 + + - name: Release + env: + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + GPG_KEY: ${{ secrets.GPG_KEY }} + SONATYPE_NEXUS_SNAPSHOTS_USERNAME: ${{ secrets.SONATYPE_NEXUS_SNAPSHOTS_USERNAME }} + SONATYPE_NEXUS_SNAPSHOTS_PASSWORD: ${{ secrets.SONATYPE_NEXUS_SNAPSHOTS_PASSWORD }} + SONATYPE_NEXUS_STAGING_USERNAME: ${{ secrets.SONATYPE_NEXUS_STAGING_USERNAME }} + SONATYPE_NEXUS_STAGING_PASSWORD: ${{ secrets.SONATYPE_NEXUS_STAGING_PASSWORD }} + run: | + # checking GPG signing support + if [ -n "$GPG_KEY" ]; then + echo "$GPG_KEY" | gpg --batch --no-tty --allow-secret-key-import --import - + unset GPG_KEY + export GPG_KEYID=$(gpg --with-colon --list-secret-keys | head -n1 | cut -d : -f 5) + + # GPG stuff works, do the release + export MAVEN_OPTS="-Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=$HOME/.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true" + + VERSION=$(echo ${GITHUB_REF#refs/*/} | sed -e 's/ipresource-//') + echo "Will be releasing ${VERSION}" + + mvn versions:set -DnewVersion=${VERSION} + mvn $MAVEN_CLI_OPTS deploy -s ci_settings.xml -P default,release + echo "done" + else + echo -e "\033[0;31m****** GPG signing disabled ******\033[0m" + fi + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 3a3e131..67d2d37 100644 --- a/pom.xml +++ b/pom.xml @@ -282,6 +282,9 @@ org.apache.maven.plugins maven-release-plugin 2.5.3 + + false +