-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (73 loc) · 2.58 KB
/
Copy pathrelease.yml
File metadata and controls
85 lines (73 loc) · 2.58 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
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
name: Release to Maven Central
on:
push:
tags:
- 'v*.*.*'
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Validate release tag and Maven versions
env:
RELEASE_TAG: ${{ github.ref_name }}
run: |
set -euo pipefail
if [[ ! "$RELEASE_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Release tag must match vX.Y.Z: $RELEASE_TAG" >&2
exit 1
fi
expected_version="${RELEASE_TAG#v}"
python3 - "$expected_version" <<'PY'
import sys
import xml.etree.ElementTree as ET
expected = sys.argv[1]
poms = [
"pom.xml",
"pgcache-core/pom.xml",
"pgcache-spring/pom.xml",
"pgcache-quarkus/pom.xml",
]
mismatches = []
for path in poms:
project = ET.parse(path).getroot()
namespace = {"m": project.tag.partition("}")[0].lstrip("{")}
versions = [("project", project.findtext("m:version", namespaces=namespace))]
if path != "pom.xml":
versions.append(("parent", project.findtext("m:parent/m:version", namespaces=namespace)))
for location, actual in versions:
if actual != expected:
mismatches.append(f"{path} {location} version is {actual!r}, expected {expected!r}")
if mismatches:
raise SystemExit("Release version mismatch:\n" + "\n".join(mismatches))
PY
- name: Set up JDK 11
uses: actions/setup-java@v5
with:
java-version: '11'
distribution: 'temurin'
cache: maven
server-id: central
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: GPG_PASSPHRASE
- name: Build and Test
run: mvn clean verify -B
- name: Deploy to Maven Central
run: mvn deploy -Prelease -B -DskipTests
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v3
with:
generate_release_notes: true
files: |
pgcache-core/target/*.jar
pgcache-spring/target/*.jar
pgcache-quarkus/target/*.jar