-
Notifications
You must be signed in to change notification settings - Fork 98
73 lines (71 loc) · 3.51 KB
/
mock_release.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
name: "Relase JGiven to Maven Mock"
on: [pull_request]
jobs:
mock-release-jgiven:
name: Mock-release JGiven
runs-on: ubuntu-latest
env:
KEYSTORE_PASSWORD: 'clearlyNotARealPassword'
KEYSTORE_NAME: 'server.p12'
SONATYPE_PASSWORD: 'notARealPassword'
SONATYPE_USERNAME: 'notARealUsername'
GPG_PASSWORD: 'espalhando'
GPG_KEY_ID: '[email protected]'
VERSION: '0.0.1-TEST'
steps:
- name: Set up JDK 17
uses: actions/[email protected]
with:
java-version: '17'
distribution: 'adopt'
- name: Set up a server certificate
run: |
openssl genrsa -out server.key 2048
openssl req -new -key server.key -out server.csr -subj '/C=DE/ST=Berlin/L=Berlin/O=JGiven/OU=JGiven/CN=localhost'
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
openssl pkcs12 -export -in server.crt -inkey server.key -out ${KEYSTORE_NAME} -name "localhost" -password "pass:${KEYSTORE_PASSWORD}"
keytool -import -cacerts -storepass changeit -noprompt -alias "localhost" -file server.crt
- name: Set up openpgp signing keys
run: |
gpg --quick-gen-key --batch --passphrase "${GPG_PASSWORD}" "${GPG_KEY_ID}"
gpg --list-keys
- name: Set up mock server
run: |
wget https://repo1.maven.org/maven2/org/wiremock/wiremock-standalone/3.3.1/wiremock-standalone-3.3.1.jar
wiremock=$(find ./ -name "wiremock-standalone-*.jar")
java -jar "${wiremock}" --port 7000 --https-port 8443 --verbose --https-keystore "${KEYSTORE_NAME}" \
--keystore-password "${KEYSTORE_PASSWORD}" --keystore-type PKCS12 --key-manager-password "${KEYSTORE_PASSWORD}" &
counter=0
while ! nc -z localhost 7000; do
sleep 0.1 # wait for 1/10 of the second before check again
counter=$((counter + 1))
if [ $counter -gt 100 ]; then
echo "Server failed to start"
exit 1
fi
done
- name: Add mock server mappings
run: |
curl -X POST --data '{"request": {"urlPattern": "/com/tngtech/jgiven/[^/]+/[^/]+/[^/]+", "method": "PUT"}, "response": {"status": 200, "body": "OK"}}' http://localhost:7000/__admin/mappings
curl -X POST --data '{"request": {"urlPattern": "/com/tngtech/jgiven/.*?/maven-metadata.xml(?:[.]sha(?:1|512|256)|[.]md5)?", "method": "PUT"}, "response": {"status": 200, "body": "OK"}}' http://localhost:7000/__admin/mappings
- uses: actions/[email protected]
- name: set an alternate version
run: "source scripts/source_files/helper_functions.sh && updateAllVersionInformation ${VERSION}"
- name: Release JGiven to Mock Repository
run: >
./gradlew publishMavenPublicationToMavenRepository
-PsigningKey="$(gpg --batch --pinentry-mode=loopback --yes --passphrase "${GPG_PASSWORD}" --armor --export-secret-key "${GPG_KEY_ID}")"
-PsigningPassword="${GPG_PASSWORD}" -PmavenRepo.releaseUrl=https://localhost:8443
env:
RELEASE: TRUE
- name: Upload test results html files
continue-on-error: true
if: ${{failure()}}
uses: actions/[email protected]
with:
name: test-report.zip
path: /home/runner/work/JGiven/JGiven/*/build/reports/tests
if-no-files-found: ignore
- name: shut down server
continue-on-error: true
run: curl -X POST http://localhost:7000/__admin/shutdown