File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
2+
3+ name : Maven Build & Deploy
4+
5+ on :
6+ push :
7+ workflow_dispatch :
8+
9+ jobs :
10+ build :
11+ runs-on : ubuntu-latest
12+ permissions :
13+ contents : read
14+ packages : write
15+
16+ steps :
17+ - uses : actions/checkout@v3
18+ - name : Set up JDK 11
19+ uses : actions/setup-java@v3
20+ with :
21+ java-version : ' 11'
22+ distribution : ' temurin'
23+ server-id : github # Value of the distributionManagement/repository/id field of the pom.xml
24+ settings-path : ${{ github.workspace }} # location for the settings.xml file
25+
26+ - name : Build with Maven
27+ if : ${{ github.ref != 'refs/heads/master' }}
28+ run : mvn clean package --file pom.xml
29+
30+ - name : Set up Maven Central Repository
31+ uses : actions/setup-java@v3
32+ with :
33+ java-version : ' 11'
34+ distribution : ' adopt'
35+ server-id : ossrh
36+ server-username : MAVEN_USERNAME
37+ server-password : MAVEN_PASSWORD
38+
39+ - name : Import GPG key
40+ id : import_gpg
41+ uses : crazy-max/ghaction-import-gpg@v5
42+ with :
43+ gpg_private_key : ${{ secrets.GPG_PRIVATE_KEY }}
44+ passphrase : ${{ secrets.GPG_PASSPHRASE }}
45+
46+ - name : Publish package
47+ if : contains(github.ref, 'release')
48+ run : mvn clean -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} --batch-mode deploy -DskipTests=true -P release
49+ env :
50+ MAVEN_USERNAME : ${{ secrets.MVN_USERNAME }}
51+ MAVEN_PASSWORD : ${{ secrets.MVN_PASSWORD }}
You can’t perform that action at this time.
0 commit comments