Skip to content

Commit 29ad02a

Browse files
authored
ci: Gha gpg (#1187)
* 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
1 parent a27d6f4 commit 29ad02a

File tree

4 files changed

+45
-5
lines changed

4 files changed

+45
-5
lines changed

.github/workflows/deploy.yml

+22-5
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,17 @@ jobs:
6464
env:
6565
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
6666
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
67-
run: echo ::set-output name=IS_NEW_RELEASE::$(npx semantic-release --dry-run | grep -c -i "Published release")
67+
run: |
68+
echo ::set-output name=IS_NEW_RELEASE::$(npx semantic-release --dry-run | grep -c -i "Published release")
69+
echo "The full TAG - ${{ github.ref }}"
70+
71+
- name: Get the nextRelease.version from semantic release
72+
if: ${{ steps.is_new_release.outputs.IS_NEW_RELEASE == '1' }}
73+
id: next_release
74+
env:
75+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
76+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
77+
run: echo ::set-output name=NEXT_RELEASE::$(npx semantic-release --dry-run | grep -oP "Published release \K[0-9]+\.[0-9]+\.[0-9]+")
6878

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

7686
- name: Publish to Maven Central
77-
if: ${{ steps.is_new_release.outputs.IS_NEW_RELEASE == '1' }}
87+
if: "startsWith(github.ref, 'refs/tags/v')"
7888
env:
79-
GHA_TAG: ${{ github.ref }} # non PR only need to get last part
89+
GHA_TAG: ${{ github.ref }} # for setMavenVersion_gha
8090
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} # for .travis.settings.xml
8191
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
92+
GPG_KEYNAME: ${{ secrets.SIGNING_KEY }}
93+
GPG_PASSPHRASE: ${{ secrets.SIGNING_PASSWORD }}
94+
SIGNING_PASSPHRASE: ${{ secrets.SIGNING_PASSPHRASE }} # for setupSigning_gha
8295
run: |
83-
build/setupSigning.sh
96+
echo -e "\n\033[0;35mCommand: setupSigning"
97+
build/setupSigning_gha.sh
98+
echo -e "\n\033[0;35mCommand: setMavenVersion"
8499
build/setMavenVersion_gha.sh
100+
echo -e "\n\033[0;35mCommand: mvn deploy"
85101
mvn deploy --settings build/.travis.settings.xml -DskipITs -Dskip.unit.tests -P central $MVN_ARGS
86102
87103
- name: Publish Java docs
88-
if: ${{ steps.is_new_release.outputs.IS_NEW_RELEASE == '1' }}
104+
if: "startsWith(github.ref, 'refs/tags/v')"
89105
env:
90106
GH_TOKEN: ${{ secrets.GH_TOKEN }}
91107
GHA_REPO_SLUG: ${{ github.repository }}
@@ -104,3 +120,4 @@ jobs:
104120
if: ${{ steps.is_new_release.outputs.IS_NEW_RELEASE == '0' }}
105121
run: |
106122
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"
123+
echo "The NEXT_RELEASE - ${{ steps.next_release.outputs.NEXT_RELEASE }}"

build/setupSigning_gha.sh

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
# export GPG_TTY=$(tty)
3+
4+
set -x
5+
6+
# This script is responsible for decrypting your encrypted signing key file
7+
# (build/signing.key.enc), and importing it into the gpg keystore.
8+
# This is done so that your maven build will be able to properly sign your jars
9+
# prior to publishing them on maven central.
10+
11+
echo "Importing signing key..."
12+
13+
# Modify the command below to use the correct environment variables
14+
# that were added to your Travis build settings when you encrypted your signing.key file.
15+
gpg --quiet --batch --yes --decrypt --passphrase="$SIGNING_PASSPHRASE" --output ./build/signing.key ./build/signing.key.gpg
16+
17+
gpg --version
18+
gpg --no-tty --batch --yes --import ./build/signing.key
19+
rm ./build/signing.key
20+
21+
echo "Signing key import finished!"

build/signing.key.gpg

2.52 KB
Binary file not shown.

pom.xml

+2
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,8 @@
512512
<gpgArgument>--batch</gpgArgument>
513513
<gpgArgument>--yes</gpgArgument>
514514
<gpgArgument>--no-tty</gpgArgument>
515+
<gpgArgument>--pinentry-mode</gpgArgument>
516+
<gpgArgument>loopback</gpgArgument>
515517
</gpgArguments>
516518
</configuration>
517519
</plugin>

0 commit comments

Comments
 (0)