Skip to content

Commit 6827dd2

Browse files
committed
First test run
1 parent 620dbae commit 6827dd2

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

.github/workflows/releasepublished.yml

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ jobs:
5959
- name: Check credentials
6060
run: |
6161
set -e
62-
echo "Checking SonaType SONATYPE_BASIC_AUTH_CREDENTIALS"
63-
curl --fail -X GET -H "Content-Type:application/xml" -u "${{ secrets.SONATYPE_BASIC_AUTH_CREDENTIALS }}" https://oss.sonatype.org/service/local/staging/profiles/b39883a429024e > /dev/null
62+
echo "Checking SonaType PORTAL_ACCESS_TOKEN"
63+
curl --fail -H "Accept:application/json" -H "Authorization: Bearer ${{ secrets.PORTAL_ACCESS_TOKEN }}" 'https://ossrh-staging-api.central.sonatype.com/manual/search/repositories?state=open'
6464
echo "Checking GitHub ACCESS_TOKEN"
6565
curl -f -H "Authorization: Bearer ${{ secrets.ACCESS_TOKEN }}" -H 'Accept: application/vnd.github.v3.raw' -s https://api.github.com/repos/$REPO > /dev/null
6666
- name: Configure GPG key
@@ -143,6 +143,9 @@ jobs:
143143
- name: GPG sign all Maven files
144144
run: |
145145
cd unpacked/maven
146+
# remove all files expect one artifact, and remove all empty folders temporary to avoid wasting time waiting for process to go over all artifacts
147+
find . ! -name 'oci-java-sdk-3.68.0.pom' -type f -exec rm -f {} +
148+
find . -type d -empty -delete
146149
find . -type f -not -name \*.asc | xargs -n 1 -I % gpg --output %.asc --detach-sig %
147150
- name: Checksum all Maven files
148151
run: |
@@ -155,10 +158,11 @@ jobs:
155158
# Code mostly by mezzargh
156159
set -e
157160
WD=`pwd`
161+
# we use the description field for cross identification between APIs (I could not find an alternative yet), so we can fetch correct repo for promotion.
158162
START_XML=$(cat << EOF
159163
<promoteRequest>
160164
<data>
161-
<description>Publish ${GITHUB_REPOSITORY} ${RELEASE} Artifacts</description>
165+
<description>sdk-${{github.run_id}}-${{github.run_attempt}}</description>
162166
</data>
163167
</promoteRequest>
164168
EOF
@@ -169,8 +173,13 @@ jobs:
169173
cd unpacked/maven/repository
170174
cp $WD/start.xml start.xml
171175
cat start.xml
172-
curl --fail -v -X POST -d @start.xml -H "Content-Type:application/xml" -u "${{ secrets.SONATYPE_BASIC_AUTH_CREDENTIALS }}" https://oss.sonatype.org/service/local/staging/profiles/b39883a429024e/start -o $WD/finish.xml
176+
curl --fail -v -X POST -d @start.xml -H "Content-Type:application/xml" -H "Authorization: Bearer ${{ secrets.PORTAL_ACCESS_TOKEN }}" https://oss.sonatype.org/service/local/staging/profiles/b39883a429024e/start -o $WD/finish.xml
173177
rm start.xml
178+
curl --fail -H "Accept:application/json" -H "Authorization: Bearer ${{ secrets.PORTAL_ACCESS_TOKEN }}" 'https://ossrh-staging-api.central.sonatype.com/manual/search/repositories?state=open' -o results.json
179+
cat results.json
180+
cat results.json | jq --raw-output --arg SELECTOR "sdk-${{github.run_id}}-${{github.run_attempt}}" '.[][] | select(.description == "${SELECTOR}").key' | jq -sRr '@uri'
181+
repository_namespace=$(cat results.json | jq --raw-output --arg SELECTOR "sdk-${{github.run_id}}-${{github.run_attempt}}" '.[][] | select(.description == "${SELECTOR}").key' | jq -sRr '@uri')
182+
echo $repository_namespace
174183
ls -lahn $WD
175184
cat $WD/finish.xml
176185
staging_dir=$(echo $(awk -F '[<>]' '/stagedRepositoryId/{print $3}' $WD/finish.xml))
@@ -179,8 +188,9 @@ jobs:
179188
ls -lahn $WD
180189
echo "Uploading $(wc -l $WD/artifacts.list | sed "s/^ *\([0-9]*\) .*$/\1/") artifacts"
181190
awk '{printf "%5d\t%s\n", NR, $0}' < $WD/artifacts.list
182-
cat $WD/artifacts.list | xargs -n 1 -I {} curl --fail -u "${{ secrets.SONATYPE_BASIC_AUTH_CREDENTIALS }}" --upload-file {} https://oss.sonatype.org/service/local/staging/deployByRepositoryId/${staging_dir}/{}
191+
cat $WD/artifacts.list | xargs -n 1 -I {} curl --fail -H "Authorization: Bearer ${{ secrets.PORTAL_ACCESS_TOKEN }}" --upload-file {} https://oss.sonatype.org/service/local/staging/deployByRepositoryId/${staging_dir}/{}
183192
cp $WD/finish.xml finish.xml
184-
cat finish.xml
185-
curl --fail -X POST -d @finish.xml -H "Content-Type:application/xml" -u "${{ secrets.SONATYPE_BASIC_AUTH_CREDENTIALS }}" -H "Content-Type:application/xml" https://oss.sonatype.org/service/local/staging/profiles/b39883a429024e/finish
186-
echo https://oss.sonatype.org/content/repositories/${staging_dir}
193+
curl -X POST -H "Accept:application/json" -H "Authorization: Bearer ${{ secrets.PORTAL_ACCESS_TOKEN }}" https://ossrh-staging-api.central.sonatype.com/manual/upload/repository/${repository_namespace}?publishing_type=user_managed -o status.json
194+
cat status.json
195+
portal_id=$(cat status.json | jq --raw-output --arg SELECTOR "sdk-${{github.run_id}}-${{github.run_attempt}}" '.[][] | select(.description == "${SELECTOR}").portal_deployment_id')
196+
echo https://central.sonatype.com/api/v1/publisher/deployment/${portal_id}/download/

0 commit comments

Comments
 (0)