-
Notifications
You must be signed in to change notification settings - Fork 72
148 lines (126 loc) · 5.45 KB
/
Copy pathrelease.yml
File metadata and controls
148 lines (126 loc) · 5.45 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
146
147
148
name: Release
on:
workflow_dispatch:
inputs:
release_version:
description: 'Release version (e.g. 3.6). If unspecified, derived from POM version by removing -dev suffix.'
required: false
next_version:
description: 'Next development version (e.g. 3.7-dev). If unspecified, bumps minor version and appends -dev.'
required: false
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v5
with:
java-version: '17'
distribution: 'temurin'
cache: maven
server-id: jboss-releases-repository
server-username: NEXUS_USER
server-password: NEXUS_TOKEN
- name: Determine versions
id: versions
run: |
POM_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "POM version: $POM_VERSION"
if [ -n "${{ github.event.inputs.release_version }}" ]; then
RELEASE_VERSION="${{ github.event.inputs.release_version }}"
else
RELEASE_VERSION="${POM_VERSION%-dev}"
if [ "$RELEASE_VERSION" = "$POM_VERSION" ]; then
echo "::error::POM version '$POM_VERSION' does not end with -dev and no release version was specified."
exit 1
fi
fi
if [ -n "${{ github.event.inputs.next_version }}" ]; then
NEXT_VERSION="${{ github.event.inputs.next_version }}"
else
MAJOR="${RELEASE_VERSION%%.*}"
MINOR="${RELEASE_VERSION#*.}"
NEXT_MINOR=$((MINOR + 1))
NEXT_VERSION="${MAJOR}.${NEXT_MINOR}-dev"
fi
echo "Release version: $RELEASE_VERSION"
echo "Next version: $NEXT_VERSION"
echo "release_version=$RELEASE_VERSION" >> "$GITHUB_OUTPUT"
echo "next_version=$NEXT_VERSION" >> "$GITHUB_OUTPUT"
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Set release version
run: |
mvn versions:set -DnewVersion=${{ steps.versions.outputs.release_version }} -DgenerateBackupPoms=false
git commit -am "Release ${{ steps.versions.outputs.release_version }}"
- name: Build and deploy
run: mvn clean deploy -Prelease -DskipTests
env:
NEXUS_USER: ${{ secrets.NEXUS_USER }}
NEXUS_TOKEN: ${{ secrets.NEXUS_TOKEN }}
MAVEN_GPG_KEY: ${{ secrets.GPG_ARMORED }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
- name: Tag release
run: |
git tag -a "v${{ steps.versions.outputs.release_version }}" -m "Release ${{ steps.versions.outputs.release_version }}"
- name: Set next development version
run: |
mvn versions:set -DnewVersion=${{ steps.versions.outputs.next_version }} -DgenerateBackupPoms=false
git commit -am "Next version ${{ steps.versions.outputs.next_version }}"
- name: Push changes and tag
run: |
git push origin HEAD
git push origin "v${{ steps.versions.outputs.release_version }}"
- name: Generate release notes
id: notes
env:
GH_TOKEN: ${{ github.token }}
run: |
RELEASE_VERSION="${{ steps.versions.outputs.release_version }}"
PREV_TAG=$(git tag --sort=-v:refname | grep -v "v${RELEASE_VERSION}" | head -1)
echo "Previous tag: $PREV_TAG"
NOTES_FILE=$(mktemp)
echo "## What's New in ${RELEASE_VERSION}" >> "$NOTES_FILE"
echo "" >> "$NOTES_FILE"
# Collect issues closed by commits in this release
ISSUES=$(git log "${PREV_TAG}..v${RELEASE_VERSION}" --oneline \
| grep -oP '#\d+' | sort -t'#' -k2 -n -u | tr -d '#')
if [ -n "$ISSUES" ]; then
echo "### Issues" >> "$NOTES_FILE"
echo "" >> "$NOTES_FILE"
for issue in $ISSUES; do
TITLE=$(gh issue view "$issue" --json title -q '.title' 2>/dev/null || echo "")
STATE=$(gh issue view "$issue" --json state -q '.state' 2>/dev/null || echo "")
if [ -n "$TITLE" ]; then
if [ "$STATE" = "CLOSED" ]; then
echo "- ~~#${issue}~~ ${TITLE}" >> "$NOTES_FILE"
else
echo "- #${issue} ${TITLE}" >> "$NOTES_FILE"
fi
fi
done
echo "" >> "$NOTES_FILE"
fi
# Categorize commits
echo "### Changes" >> "$NOTES_FILE"
echo "" >> "$NOTES_FILE"
git log "${PREV_TAG}..v${RELEASE_VERSION}" --oneline --no-merges \
| grep -v "Release \|Next version \|Bump " \
| sed 's/^[0-9a-f]* /- /' >> "$NOTES_FILE"
echo "" >> "$NOTES_FILE"
echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/${PREV_TAG}...v${RELEASE_VERSION}" >> "$NOTES_FILE"
echo "notes_file=$NOTES_FILE" >> "$GITHUB_OUTPUT"
- name: Create GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "v${{ steps.versions.outputs.release_version }}" \
--title "Release ${{ steps.versions.outputs.release_version }}" \
--notes-file "${{ steps.notes.outputs.notes_file }}"