-
Notifications
You must be signed in to change notification settings - Fork 16
123 lines (115 loc) · 4.84 KB
/
publish-maven.yaml
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
################################################################################
# Copyright (c) 2021,2023 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# SPDX-License-Identifier: Apache-2.0
################################################################################
---
name: Publish
on:
workflow_dispatch:
inputs:
releaseVersion:
description: The version you want to release
required: true
type: string
developmentVersion:
description: The development version to assign after the release
required: true
type: string
auto_release:
description: A switch for automatic release after closing the staging repository
required: false
type: boolean
default: false
# only committers can trigger this
jobs:
publish-maven:
runs-on: ubuntu-latest
steps:
- name: Checkout branch
uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17
distribution: temurin
# use the default GitHub runner user for the next steps
# this is needed during deploy, for pushing a tag
- name: Configure Git User
uses: fregante/setup-git-user@v2
# this is necessary because it creates gpg.conf, etc.
- name: List Keys
shell: bash
run: |
gpg -K --keyid-format=long
- name: Import GPG Private Key
shell: bash
run: |
echo "use-agent" >> ~/.gnupg/gpg.conf
echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf
echo -e "${{ secrets.ORG_GPG_PRIVATE_KEY }}" | gpg --import --batch
for fpr in $(gpg --list-keys --with-colons | awk -F: '/fpr:/ {print $10}' | sort -u);
do
echo -e "5\\ny\\n" | gpg --batch --command-fd 0 --expert --edit-key $fpr trust;
done
# Environment variables used in settings.xml and pom.xml
- name: Publish to Maven
shell: bash
env:
MAVEN_USERNAME: ${{ secrets.ORG_OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.ORG_OSSRH_PASSWORD }}
AUTO_RELEASE_AFTER_CLOSE: ${{ inputs.auto_release }}
GPG_PASSPHRASE: ${{ secrets.ORG_GPG_PASSPHRASE }}
# command summary
# -B/--batch-mode: only display progress and errors
# -U: update snapshot-releases
# -Pci-cd: apply the ci-cd profile (in pom.xml)
# release:prepare (comes from maven-release-plugin)
# release:perform (comes from maven-release-plugin)
# javadoc:jar: checks documentation strings
# source:jar: creates a <lib>-<version>-source.jar
# -s settings.xml: use custom settings file
# -D gpg.passphrase: a system property used by the build process for signing
# -D releaseVersion: set the version you're releasing (will also tag using this)
# -D developmentVersion: set the next dev version
run: |
./mvnw -B -U \
-Pci-cd \
release:prepare \
release:perform \
javadoc:jar \
source:jar \
-s settings.xml \
-D releaseVersion="${{ inputs.releaseVersion }}" \
-D developmentVersion="${{ inputs.developmentVersion }}" \
deploy
# artifact_name is cx-ssi-lib and the version should be the *-SNAPSHOT
# In the next step we'll use the releaseVersion to finalize the upload
- name: Get generated artifact name
shell: bash
run: |
echo "artifact_name=$(mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.artifactId -q -DforceStdout)" >> "$GITHUB_ENV"
echo "artifact_version=$(mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.version -q -DforceStdout)" >> "$GITHUB_ENV"
# Use the generated name to supply the input 'path' for the upload,
# but upload the final
# Example:
# input: cx-ssi-lib-0.0.1-SNAPSHOT.jar
# output: cx-ssi-lib-0.0.1.jar
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.artifact_name }}-${{ inputs.releaseVersion }}
path: ./target/${{ env.artifact_name }}-${{ env.artifact_version }}.jar