|
1 | | -name: Publish to maven repository |
2 | | - |
3 | | -on: |
4 | | - release: |
5 | | - types: |
6 | | - - published |
7 | | - |
8 | | -permissions: |
9 | | - contents: read |
10 | | - |
11 | | -jobs: |
12 | | - package_and_publish: |
13 | | - name: Publish to maven repository |
14 | | - runs-on: ubuntu-latest |
15 | | - |
16 | | - steps: |
17 | | - - uses: actions/checkout@v4 |
18 | | - - name: Setup java SDK 17 |
19 | | - uses: actions/setup-java@v4 |
20 | | - with: |
21 | | - java-version: '17' |
22 | | - distribution: 'temurin' |
23 | | - cache: maven |
24 | | - - |
25 | | - name: Import GPG key |
26 | | - uses: crazy-max/ghaction-import-gpg@v6 |
27 | | - with: |
28 | | - gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} |
29 | | - #passphrase: ${{ secrets.PASSPHRASE }} |
30 | | - |
31 | | - - name: Create bundle and upload to oss.sonatype.org (staging) |
32 | | - # Fail on first error |
33 | | - run: | |
34 | | - set -e |
35 | | - version=${{ github.event.release.name }} |
36 | | - artifact=smart-id-java-client-$version |
37 | | - echo "[INFO] Artifact name: $artifact" |
38 | | - ./mvnw versions:set -DnewVersion="$version" |
39 | | - ./mvnw package -DskipTests |
40 | | - cd target |
41 | | - rm -rf ee/sk/smartid/smart-id-java-client/$version |
42 | | - mkdir -p ee/sk/smartid/smart-id-java-client/$version |
43 | | - cp $artifact.jar ee/sk/smartid/smart-id-java-client/$version/ |
44 | | - cp $artifact-sources.jar ee/sk/smartid/smart-id-java-client/$version/ |
45 | | - cp $artifact-javadoc.jar ee/sk/smartid/smart-id-java-client/$version/ |
46 | | - cp ../pom.xml ee/sk/smartid/smart-id-java-client/$version/$artifact.pom |
47 | | - cd ee/sk/smartid/smart-id-java-client/$version |
48 | | - gpg -ab $artifact.pom |
49 | | - gpg -ab $artifact.jar |
50 | | - gpg -ab $artifact-sources.jar |
51 | | - gpg -ab $artifact-javadoc.jar |
52 | | - find . -type f \( -name '*.jar' -o -name '*.pom' \) -exec sh -c 'for file; do sha256sum "$file" | cut -d " " -f 1 > "$file.sha256"; done' _ {} + |
53 | | - find . -type f \( -name '*.jar' -o -name '*.pom' \) -exec sh -c 'for file; do sha1sum "$file" | cut -d " " -f 1 > "$file.sha1"; done' _ {} + |
54 | | - find . -type f \( -name '*.jar' -o -name '*.pom' \) -exec sh -c 'for file; do md5sum "$file" | cut -d " " -f 1 > "$file.md5"; done' _ {} + |
55 | | - cd ../../../../../ |
56 | | - zip bundle.zip ee/sk/smartid/smart-id-java-client/$version/* |
57 | | - CODE=$(curl -w "%{http_code}" -o curl_response.txt -s --request POST --verbose --header 'Authorization: Bearer ${{ secrets.SONATYPETOKEN }}' --form bundle=@bundle.zip https://central.sonatype.com/api/v1/publisher/upload) |
58 | | - echo "[INFO] ------------------------------------------------------------------------" |
59 | | - echo "[INFO] Upload to central.sonatype.com ResponseCode: $CODE" |
60 | | - cat curl_response.txt |
61 | | - echo -e "\n[INFO] Login to central.sonatype.com for releasing $artifact" |
62 | | - echo "[INFO] ------------------------------------------------------------------------" |
63 | | - [[ $CODE == 201 ]] && exit 0 || exit 1 |
64 | | - |
| 1 | +name: Publish to maven repository |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: |
| 6 | + - published |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: read |
| 10 | + |
| 11 | +jobs: |
| 12 | + package_and_publish: |
| 13 | + name: Publish to maven repository |
| 14 | + runs-on: ubuntu-latest |
| 15 | + |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v4 |
| 18 | + - name: Setup java SDK 17 |
| 19 | + uses: actions/setup-java@v4 |
| 20 | + with: |
| 21 | + java-version: '17' |
| 22 | + distribution: 'temurin' |
| 23 | + cache: maven |
| 24 | + - |
| 25 | + name: Import GPG key |
| 26 | + uses: crazy-max/ghaction-import-gpg@v6 |
| 27 | + with: |
| 28 | + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} |
| 29 | + #passphrase: ${{ secrets.PASSPHRASE }} |
| 30 | + |
| 31 | + - name: Create bundle and upload to oss.sonatype.org (staging) |
| 32 | + # Fail on first error |
| 33 | + run: | |
| 34 | + set -e |
| 35 | + version=${{ github.event.release.name }} |
| 36 | + artifact=smart-id-java-client-$version |
| 37 | + echo "[INFO] Artifact name: $artifact" |
| 38 | + ./mvnw versions:set -DnewVersion="$version" |
| 39 | + ./mvnw package -DskipTests |
| 40 | + cd target |
| 41 | + rm -rf ee/sk/smartid/smart-id-java-client/$version |
| 42 | + mkdir -p ee/sk/smartid/smart-id-java-client/$version |
| 43 | + cp $artifact.jar ee/sk/smartid/smart-id-java-client/$version/ |
| 44 | + cp $artifact-sources.jar ee/sk/smartid/smart-id-java-client/$version/ |
| 45 | + cp $artifact-javadoc.jar ee/sk/smartid/smart-id-java-client/$version/ |
| 46 | + cp ../pom.xml ee/sk/smartid/smart-id-java-client/$version/$artifact.pom |
| 47 | + cd ee/sk/smartid/smart-id-java-client/$version |
| 48 | + gpg -ab $artifact.pom |
| 49 | + gpg -ab $artifact.jar |
| 50 | + gpg -ab $artifact-sources.jar |
| 51 | + gpg -ab $artifact-javadoc.jar |
| 52 | + find . -type f \( -name '*.jar' -o -name '*.pom' \) -exec sh -c 'for file; do sha256sum "$file" | cut -d " " -f 1 > "$file.sha256"; done' _ {} + |
| 53 | + find . -type f \( -name '*.jar' -o -name '*.pom' \) -exec sh -c 'for file; do sha1sum "$file" | cut -d " " -f 1 > "$file.sha1"; done' _ {} + |
| 54 | + find . -type f \( -name '*.jar' -o -name '*.pom' \) -exec sh -c 'for file; do md5sum "$file" | cut -d " " -f 1 > "$file.md5"; done' _ {} + |
| 55 | + cd ../../../../../ |
| 56 | + zip bundle.zip ee/sk/smartid/smart-id-java-client/$version/* |
| 57 | + CODE=$(curl -w "%{http_code}" -o curl_response.txt -s --request POST --verbose --header 'Authorization: Bearer ${{ secrets.SONATYPETOKEN }}' --form bundle=@bundle.zip https://central.sonatype.com/api/v1/publisher/upload) |
| 58 | + echo "[INFO] ------------------------------------------------------------------------" |
| 59 | + echo "[INFO] Upload to central.sonatype.com ResponseCode: $CODE" |
| 60 | + cat curl_response.txt |
| 61 | + echo -e "\n[INFO] Login to central.sonatype.com for releasing $artifact" |
| 62 | + echo "[INFO] ------------------------------------------------------------------------" |
| 63 | + [[ $CODE == 201 ]] && exit 0 || exit 1 |
| 64 | + |
0 commit comments