-
Notifications
You must be signed in to change notification settings - Fork 24
116 lines (98 loc) · 3.51 KB
/
release.yml
File metadata and controls
116 lines (98 loc) · 3.51 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
name: Release
on:
push:
tags:
- 'v*'
jobs:
build-and-release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v6.0.2
with:
ref: main
fetch-depth: 0
- name: Extract version from tag
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Set version from tag
env:
VERSION: ${{ steps.get_version.outputs.VERSION }}
run: |
echo "version=$VERSION" > gradle.properties
echo "gradle.properties criado:"
cat gradle.properties
- name: Set up JDK 17
uses: actions/setup-java@v5.2.0
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: validate specs
run: ./gradlew specsValidation
- name: Build with Gradle
run: ./gradlew build
- name: Validate Maven Central credentials
run: |
if [ -z "${{ secrets.MAVEN_CENTRAL_TOKEN }}" ]; then
echo "❌ MAVEN_CENTRAL_TOKEN secret is not set"
exit 1
fi
echo "✅ Maven Central token is set (length: ${#MAVEN_CENTRAL_TOKEN})"
env:
MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
- name: Check curl version
run: curl --version
- name: Publish to Maven Central
run: ./gradlew publishToMavenCentral
env:
MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
- name: Update README version
run: |
VERSION=${{ steps.get_version.outputs.VERSION }}
sed -i "s/jtoon:[0-9]\+\.[0-9]\+\.[0-9]\+/jtoon:$VERSION/g" README.md
sed -i "s/<version>[0-9]\+\.[0-9]\+\.[0-9]\+<\/version>/<version>$VERSION<\/version>/g" README.md
- name: Commit README changes
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add README.md build.gradle
git diff --staged --quiet || git commit -m "docs: update version to ${{ steps.get_version.outputs.VERSION }} in README"
git push origin main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v3.0.0
with:
files: build/libs/*.jar
generate_release_notes: true
draft: false
prerelease: ${{ contains(steps.get_version.outputs.VERSION, '-') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Generate JaCoCo Badge
uses: cicirello/jacoco-badge-generator@v2.12.1
with:
generate-branches-badge: true
jacoco-csv-file: build/customJacocoReportDir/test/jacocoTestReport.csv
- name: Commit and push the badge
uses: EndBug/add-and-commit@v10.0.0
with:
default_author: github_actions
message: 'Update the Coverage Badge for the README.md'
add: '*.svg'
- name: Upload build artifacts
uses: actions/upload-artifact@v7.0.1
if: always()
with:
name: build-artifacts
path: |
build/libs/*.jar
build/reports/tests/test/
retention-days: 30