-
Notifications
You must be signed in to change notification settings - Fork 53
44 lines (39 loc) · 1.68 KB
/
Copy pathpublish-snapshot.yaml
File metadata and controls
44 lines (39 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
name: Publish SNAPSHOT to Maven Central snapshots
# Manual only: pick the branch to publish from in the "Run workflow" dialog, or
# gh workflow run publish-snapshot.yaml --ref <branch>
# Snapshots may be overwritten and are removed by Sonatype after about 90 days,
# so this is for letting people try a build, not for permanent artifacts.
on:
workflow_dispatch:
jobs:
publish-snapshot:
name: Publish snapshot
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Set up Maven Central Repository
uses: actions/setup-java@v5
with:
java-version: '11'
distribution: 'zulu'
server-id: central
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.GPG_SIGNING_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
# A release version published here would land in the snapshot repository
# instead of going through the Central Portal release flow, so refuse it.
- name: Verify the version is a SNAPSHOT
run: |
VERSION=$(mvn -q -DforceStdout help:evaluate -Dexpression=project.version)
echo "Project version: $VERSION"
case "$VERSION" in
*-SNAPSHOT) echo "OK, publishing $VERSION" ;;
*) echo "::error::Refusing to publish non-SNAPSHOT version $VERSION"; exit 1 ;;
esac
- name: Publish snapshot
run: mvn -P release --batch-mode deploy -DskipTests
env:
MAVEN_USERNAME: ${{ secrets.CENTRAL_TOKEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.CENTRAL_TOKEN_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_SIGNING_KEY_PASSWORD }}