Skip to content

Commit

Permalink
ci: Gha gpg (#1187)
Browse files Browse the repository at this point in the history
* ci: fix gpg

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* ci: fix
  • Loading branch information
Mikemosca authored Aug 31, 2021
1 parent a27d6f4 commit 29ad02a
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 5 deletions.
27 changes: 22 additions & 5 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,17 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: echo ::set-output name=IS_NEW_RELEASE::$(npx semantic-release --dry-run | grep -c -i "Published release")
run: |
echo ::set-output name=IS_NEW_RELEASE::$(npx semantic-release --dry-run | grep -c -i "Published release")
echo "The full TAG - ${{ github.ref }}"
- name: Get the nextRelease.version from semantic release
if: ${{ steps.is_new_release.outputs.IS_NEW_RELEASE == '1' }}
id: next_release
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: echo ::set-output name=NEXT_RELEASE::$(npx semantic-release --dry-run | grep -oP "Published release \K[0-9]+\.[0-9]+\.[0-9]+")

- name: Publish to Git Releases and Tags
if: ${{ steps.is_new_release.outputs.IS_NEW_RELEASE == '1' }}
Expand All @@ -74,18 +84,24 @@ jobs:
run: npx semantic-release # --dry-run --branches 9662_addcheck

- name: Publish to Maven Central
if: ${{ steps.is_new_release.outputs.IS_NEW_RELEASE == '1' }}
if: "startsWith(github.ref, 'refs/tags/v')"
env:
GHA_TAG: ${{ github.ref }} # non PR only need to get last part
GHA_TAG: ${{ github.ref }} # for setMavenVersion_gha
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} # for .travis.settings.xml
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
GPG_KEYNAME: ${{ secrets.SIGNING_KEY }}
GPG_PASSPHRASE: ${{ secrets.SIGNING_PASSWORD }}
SIGNING_PASSPHRASE: ${{ secrets.SIGNING_PASSPHRASE }} # for setupSigning_gha
run: |
build/setupSigning.sh
echo -e "\n\033[0;35mCommand: setupSigning"
build/setupSigning_gha.sh
echo -e "\n\033[0;35mCommand: setMavenVersion"
build/setMavenVersion_gha.sh
echo -e "\n\033[0;35mCommand: mvn deploy"
mvn deploy --settings build/.travis.settings.xml -DskipITs -Dskip.unit.tests -P central $MVN_ARGS
- name: Publish Java docs
if: ${{ steps.is_new_release.outputs.IS_NEW_RELEASE == '1' }}
if: "startsWith(github.ref, 'refs/tags/v')"
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
GHA_REPO_SLUG: ${{ github.repository }}
Expand All @@ -104,3 +120,4 @@ jobs:
if: ${{ steps.is_new_release.outputs.IS_NEW_RELEASE == '0' }}
run: |
echo -e "\n\033[0;35mCommand: Skipping the deployment because semantic release has determined there are no relevant changes that warrent a new release.\n"
echo "The NEXT_RELEASE - ${{ steps.next_release.outputs.NEXT_RELEASE }}"
21 changes: 21 additions & 0 deletions build/setupSigning_gha.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
# export GPG_TTY=$(tty)

set -x

# This script is responsible for decrypting your encrypted signing key file
# (build/signing.key.enc), and importing it into the gpg keystore.
# This is done so that your maven build will be able to properly sign your jars
# prior to publishing them on maven central.

echo "Importing signing key..."

# Modify the command below to use the correct environment variables
# that were added to your Travis build settings when you encrypted your signing.key file.
gpg --quiet --batch --yes --decrypt --passphrase="$SIGNING_PASSPHRASE" --output ./build/signing.key ./build/signing.key.gpg

gpg --version
gpg --no-tty --batch --yes --import ./build/signing.key
rm ./build/signing.key

echo "Signing key import finished!"
Binary file added build/signing.key.gpg
Binary file not shown.
2 changes: 2 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,8 @@
<gpgArgument>--batch</gpgArgument>
<gpgArgument>--yes</gpgArgument>
<gpgArgument>--no-tty</gpgArgument>
<gpgArgument>--pinentry-mode</gpgArgument>
<gpgArgument>loopback</gpgArgument>
</gpgArguments>
</configuration>
</plugin>
Expand Down

0 comments on commit 29ad02a

Please sign in to comment.