-
-
Notifications
You must be signed in to change notification settings - Fork 0
145 lines (129 loc) · 5.87 KB
/
Copy pathrelease.yml
File metadata and controls
145 lines (129 loc) · 5.87 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
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
---
name: Release
permissions:
contents: write
packages: write
statuses: write
checks: write
on:
workflow_dispatch:
jobs:
release:
permissions:
contents: write
id-token: write
attestations: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: webfactory/ssh-agent@v0.10.0
with:
ssh-private-key: ${{ secrets.MAVEN_RELEASE_SSH_KEY }}
- uses: actions/setup-java@v5
with:
java-version: "25"
distribution: "temurin"
cache: "maven"
server-id: central
server-username: OSSRH_USERNAME
server-password: OSSRH_TOKEN
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: Publish package to Maven Central
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
mvn -B -ntp -Dstyle.color=always release:prepare -P sign
cat release.properties
RELEASE_TAG=$(grep '^scm.tag=' release.properties | cut -d'=' -f2)
echo "RELEASE_TAG=${RELEASE_TAG}" >> "$GITHUB_ENV"
echo "RELEASE_VERSION=${RELEASE_TAG#v}" >> "$GITHUB_ENV"
mvn -B -ntp -Dstyle.color=always release:perform -P sign -DconnectionUrl=scm:git:https://github.com/${{ github.repository }}.git
echo "Released ${RELEASE_TAG} 🚀" >> "$GITHUB_STEP_SUMMARY"
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
- name: Generate build provenance attestation
uses: actions/attest-build-provenance@v4
with:
subject-path: |
target/checkout/mjml-java-core/target/mjml-java-core-${{ env.RELEASE_VERSION }}.jar
target/checkout/mjml-java-resolvers/target/mjml-java-resolvers-${{ env.RELEASE_VERSION }}.jar
target/checkout/mjml-java-spring/target/mjml-java-spring-${{ env.RELEASE_VERSION }}.jar
- name: Generate SBOM attestation (core)
uses: actions/attest-sbom@v4
with:
subject-path: target/checkout/mjml-java-core/target/mjml-java-core-${{ env.RELEASE_VERSION }}.jar
sbom-path: target/checkout/mjml-java-core/target/bom.json
- name: Generate SBOM attestation (resolvers)
uses: actions/attest-sbom@v4
with:
subject-path: target/checkout/mjml-java-resolvers/target/mjml-java-resolvers-${{ env.RELEASE_VERSION }}.jar
sbom-path: target/checkout/mjml-java-resolvers/target/bom.json
- name: Generate SBOM attestation (spring)
uses: actions/attest-sbom@v4
with:
subject-path: target/checkout/mjml-java-spring/target/mjml-java-spring-${{ env.RELEASE_VERSION }}.jar
sbom-path: target/checkout/mjml-java-spring/target/bom.json
- name: Stage SBOMs for release upload
run: |
mkdir -p sboms
for module in mjml-java-core mjml-java-resolvers mjml-java-spring; do
cp "target/checkout/${module}/target/bom.json" "sboms/${module}-${RELEASE_VERSION}-bom.json"
cp "target/checkout/${module}/target/bom.xml" "sboms/${module}-${RELEASE_VERSION}-bom.xml"
done
- name: Update docs with released version
run: |
# Strip leading 'v' if present (e.g., v1.0.1 -> 1.0.1)
RELEASE_VERSION="${RELEASE_TAG#v}"
FILES=(
README.md
docs/docs/getting-started/installation.md
docs/docs/guides/resolvers.md
docs/docs/guides/spring-boot.md
)
for f in "${FILES[@]}"; do
if [ -f "$f" ]; then
# Replace any semver or semver-SNAPSHOT with the released version
sed -i "s/[0-9]\+\.[0-9]\+\.[0-9]\+\(-SNAPSHOT\)\{0,1\}/${RELEASE_VERSION}/g" "$f"
fi
done
if git diff --quiet; then
echo "No doc version changes needed"
else
git add "${FILES[@]}"
git commit -m "docs: update version references to ${RELEASE_VERSION}"
git push
fi
- name: Create GitHub Release
run: |
# Find previous release tag
PREV_TAG=$(git describe --tags --abbrev=0 "${RELEASE_TAG}^" 2>/dev/null || echo "")
if [ -n "$PREV_TAG" ]; then
COMMITS=$(git log "${PREV_TAG}..${RELEASE_TAG}" --pretty=format:"- %s" \
| grep -v '\[maven-release-plugin\]')
else
COMMITS=$(git log "${RELEASE_TAG}" --pretty=format:"- %s" \
| grep -v '\[maven-release-plugin\]')
fi
# Generate release notes via Claude API, fall back to raw commits on failure
NOTES=$(curl -sf https://api.anthropic.com/v1/messages \
-H "x-api-key: ${ANTHROPIC_API_KEY}" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d "$(jq -n --arg commits "$COMMITS" '{
model: "claude-haiku-4-5-20251001",
max_tokens: 1024,
messages: [{role: "user", content: ("Categorize these git commits into GitHub release notes. Use these sections as needed: ## New Features, ## Bug Fixes, ## Dependency Updates, ## Other Changes. Use bulleted markdown lists. Only include sections that have entries. Do not add any preamble or explanation, just the categorized notes.\n\nCommits:\n" + $commits)}]
}')" | jq -r '.content[0].text') || NOTES="${COMMITS}"
gh release create "${RELEASE_TAG}" \
--title "${RELEASE_TAG}" \
--notes "${NOTES}" \
--latest \
sboms/*
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}