-
-
Notifications
You must be signed in to change notification settings - Fork 1
119 lines (100 loc) · 4.13 KB
/
release.yml
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
name: release
on:
push:
tags:
- "**"
env:
GRADLE_OPTS: -Dorg.gradle.jvmargs="-XX:MaxMetaspaceSize=2g"
JDK_VERSION: 19
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
outputs:
module_name: ${{ steps.module.outputs.module_name }}
version: ${{ steps.tag.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Set up JDK ${{ env.JDK_VERSION }}
uses: actions/setup-java@v4
with:
java-version: ${{ env.JDK_VERSION }}
distribution: temurin
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v3
- uses: gradle/gradle-build-action@v2
- name: Save tag prefix
id: module
run: echo "module_name=$(echo $GITHUB_REF_NAME | cut -d'/' -f1)" >> $GITHUB_OUTPUT
- name: Save tag version
id: tag
run: echo "version=$(echo $GITHUB_REF_NAME | cut -d'/' -f2)" >> $GITHUB_OUTPUT
# publish-plugin assumes its a snapshot without this
- name: remove SNAPSHOT on root gradle.properties
run: sed -i '/^VERSION=/ s/-SNAPSHOT//' gradle.properties
# this avoids relying on early-version snapshot dependency on kipher-core
- name: remove SNAPSHOT suffix on kipher-core version
if: ${{ steps.module.outputs.module_name }} != "kipher-core"
run: |
cd kipher-core
# remove VERSION from gradle.properties
sed -i '/VERSION/d' gradle.properties
# use CURRENT_RELEASE as VERSION
sed -i "s/CURRENT_RELEASE/VERSION/" gradle.properties
- name: replace version on project gradle.properties
run: |
cd ${{ steps.module.outputs.module_name }}
sed -i "/^VERSION=/ s/=.*/=${{ steps.tag.outputs.version }}/" gradle.properties
- name: Gradle build
run: ./gradlew ${{ steps.module.outputs.module_name }}:clean ${{ steps.module.outputs.module_name }}:build --scan
- name: Publish module on GPR
run: ./gradlew ${{ steps.module.outputs.module_name }}:publishAllPublicationsToGitHubPackagesRepository
- name: Publish module on Sonatype
run: ./gradlew ${{ steps.module.outputs.module_name }}:publishToSonatype
env:
SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
SONATYPE_PASS: ${{ secrets.SONATYPE_PASS }}
- name: Close sonatype staging repository
run: ./gradlew findSonatypeStagingRepository closeAndReleaseSonatypeStagingRepository
env:
SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
SONATYPE_PASS: ${{ secrets.SONATYPE_PASS }}
- name: Get Changelog Entry
id: changelog_reader
uses: mindsers/changelog-reader-action@v2
with:
validation_level: warn
version: ${{ steps.tag.outputs.version }}
path: docs/CHANGELOG-${{ steps.module.outputs.module_name }}.md
- name: Create release
uses: ncipollo/release-action@v1
if: startsWith(github.ref, 'refs/tags/')
with:
tag: ${{ steps.module.outputs.module_name }}/${{ steps.changelog_reader.outputs.version }}
name: ${{ steps.module.outputs.module_name }} v${{ steps.changelog_reader.outputs.version }}
body: ${{ steps.changelog_reader.outputs.changes }}
prerelease: ${{ steps.changelog_reader.outputs.status == 'prerelease' }}
draft: ${{ steps.changelog_reader.outputs.status == 'unreleased' }}
allowUpdates: true
artifactErrorsFailBuild: false
artifacts: |
${{ steps.module.outputs.module_name }}/build/libs/*
record:
needs: publish
uses: ./.github/workflows/release-record.yml
with:
project: ${{ needs.publish.outputs.module_name }}
version: ${{ needs.publish.outputs.version }}
secrets: inherit
docs:
needs: publish
uses: ./.github/workflows/docs.yml
with:
project: ${{ needs.publish.outputs.module_name }}
version: ${{ needs.publish.outputs.version }}
secrets: inherit