File tree Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change
1
+ import base64
2
+ import json
3
+ import os
4
+ import sys
5
+ import urllib .request
6
+
7
+ username = os .environ .get ('NEXUS_USERNAME' )
8
+ password = os .environ .get ('NEXUS_PASSWORD' )
9
+
10
+ def get (url , username , password ):
11
+ req = urllib .request .Request (url )
12
+ base64_auth = base64 .b64encode (bytes ('{}:{}' .format (username , password ),'ascii' ))
13
+ req .add_header ("Authorization" , "Basic {}" .format (base64_auth .decode ('utf-8' )))
14
+ req .add_header ('Accept' , 'application/json' )
15
+ with urllib .request .urlopen (req ) as response :
16
+ return response .read ()
17
+
18
+ def getRepositories (username , password ):
19
+ return json .loads (get ("https://oss.sonatype.org/service/local/staging/profile_repositories" , username , password ))
20
+
21
+ repositories = getRepositories (username , password ).get ("data" )
22
+ if len (repositories ) != 1 :
23
+ sys .stderr .write ("Zero or more than one staging repository. Exiting. Please execute the process manually." )
24
+ exit (1 )
25
+
26
+ repositoryId = repositories [0 ].get ("repositoryId" )
27
+ print (repositoryId )
28
+
29
+
Original file line number Diff line number Diff line change 82
82
- name : Publish
83
83
run : |
84
84
./gradlew publish
85
+
86
+ finish-release :
87
+ runs-on : ubuntu-latest
88
+ needs : publish
89
+ env :
90
+ NEXUS_USERNAME : ${{ secrets.MAVEN_USERNAME }}
91
+ NEXUS_PASSWORD : ${{ secrets.MAVEN_PASSWORD }}
92
+ steps :
93
+ - id : get_staging_repository_id
94
+ name : Get staging repository id
95
+ run : |
96
+ echo "staging_repository_id=$(python3 .github/get_staging_repository_id.py)" >> $GITHUB_OUTPUT
97
+ - name : Release
98
+ uses : nexus-actions/release-nexus-staging-repo@main
99
+ with :
100
+ username : ${{ secrets.MAVEN_USERNAME }}
101
+ password : ${{ secrets.MAVEN_PASSWORD }}
102
+ staging_repository_id : ${{ steps.get_staging_repository_id.outputs.staging_repository_id }}
You can’t perform that action at this time.
0 commit comments