-
Notifications
You must be signed in to change notification settings - Fork 0
131 lines (111 loc) · 4.22 KB
/
release.yml
File metadata and controls
131 lines (111 loc) · 4.22 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
name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., 2.1, 3.0)'
required: true
type: string
permissions:
contents: write
packages: write
jobs:
release:
name: Build and Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 11
uses: actions/setup-java@v4
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: MAVEN_GPG_PASSPHRASE
- name: Configure Git
run: |
git config user.name "GitHub Actions Bot"
git config user.email "actions@github.com"
- name: Validate version format
run: |
VERSION="${{ github.event.inputs.version }}"
if ! echo "$VERSION" | grep -qE '^[0-9]+\.[0-9]+$'; then
echo "ERROR: Version must be in format X.Y (e.g., 2.1, 3.0)"
exit 1
fi
- name: Update pom.xml version
run: |
mvn versions:set -DnewVersion=${{ github.event.inputs.version }}
mvn versions:commit
- name: Build and Test
run: mvn clean verify
- name: Deploy to Maven Central
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
run: |
mvn deploy -P release
- name: Create Git tag
run: |
git add pom.xml
git commit -m "Release version ${{ github.event.inputs.version }}"
git tag -a v${{ github.event.inputs.version }} -m "Release v${{ github.event.inputs.version }}"
git push origin main
git push origin v${{ github.event.inputs.version }}
- name: Generate Changelog
id: changelog
run: |
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
if [ -z "$PREV_TAG" ]; then
CHANGELOG=$(git log --pretty=format:"* %s (%h)" --no-merges)
else
CHANGELOG=$(git log ${PREV_TAG}..HEAD --pretty=format:"* %s (%h)" --no-merges)
fi
echo "changelog<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGELOG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ github.event.inputs.version }}
release_name: Release v${{ github.event.inputs.version }}
body: |
## Release v${{ github.event.inputs.version }}
### Changes
${{ steps.changelog.outputs.changelog }}
### Installation
```xml
<dependency>
<groupId>org.flossware</groupId>
<artifactId>classloader-java</artifactId>
<version>${{ github.event.inputs.version }}</version>
</dependency>
```
### Documentation
- [README](https://github.com/FlossWare/classloader-java/blob/v${{ github.event.inputs.version }}/README.md)
- [SECURITY](https://github.com/FlossWare/classloader-java/blob/v${{ github.event.inputs.version }}/SECURITY.md)
- [CHANGELOG](https://github.com/FlossWare/classloader-java/blob/v${{ github.event.inputs.version }}/CHANGELOG.md)
draft: false
prerelease: false
- name: Bump to next development version
run: |
CURRENT_VERSION="${{ github.event.inputs.version }}"
MAJOR=$(echo $CURRENT_VERSION | cut -d. -f1)
MINOR=$(echo $CURRENT_VERSION | cut -d. -f2)
NEXT_MINOR=$((MINOR + 1))
NEXT_VERSION="${MAJOR}.${NEXT_MINOR}"
mvn versions:set -DnewVersion=${NEXT_VERSION}-SNAPSHOT
mvn versions:commit
git add pom.xml
git commit -m "Prepare for next development iteration: ${NEXT_VERSION}-SNAPSHOT"
git push origin main