Skip to content

Commit eaa22b6

Browse files
committed
Move 'release to maven central' to its own workflow
Signed-off-by: Wei-Qiang Zhou <wei-qiang.zhou@alliander.com>
1 parent 93c2d74 commit eaa22b6

2 files changed

Lines changed: 81 additions & 54 deletions

File tree

‎.github/workflows/java-gradle-ci.yml‎

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@ name: Java CI with Gradle for library
77
on:
88
push:
99
workflow_dispatch:
10-
inputs:
11-
create_release:
12-
type: boolean
13-
description: Create a release when CI passes
14-
default: false
15-
required: true
1610

1711
concurrency:
1812
group: ${{ github.workflow }}-${{ github.ref }}
@@ -57,51 +51,3 @@ jobs:
5751
reuse-compliance:
5852
name: REUSE Compliance
5953
uses: ./.github/workflows/reuse-compliance.yml
60-
61-
publish:
62-
name: Publish to maven central
63-
needs: [build-and-test]
64-
if: github.ref_type == 'tag'
65-
runs-on: ubuntu-latest
66-
environment: release
67-
permissions:
68-
contents: read
69-
70-
steps:
71-
- name: Checkout repository
72-
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # 7.0.1
73-
with:
74-
fetch-depth: 1
75-
persist-credentials: false
76-
77-
- name: Setup runtime
78-
uses: ./.github/actions/setup-runtime
79-
80-
- name: Cache Gradle
81-
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 #v6.1.0
82-
with:
83-
path: |
84-
~/.gradle/caches
85-
~/.gradle/wrapper
86-
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/settings.gradle*') }}
87-
88-
- name: Optimize Gradle
89-
shell: bash
90-
run: |
91-
mkdir -p ~/.gradle
92-
echo "org.gradle.caching=true" >> ~/.gradle/gradle.properties
93-
echo "org.gradle.configuration-cache=true" >> ~/.gradle/gradle.properties
94-
95-
- name: Gradle Release Build
96-
env:
97-
JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
98-
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }}
99-
JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
100-
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.MAVEN_USERNAME }}
101-
JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
102-
SANITIZED_TAG: ${{ github.ref_name }}
103-
run: |
104-
echo "Performing release Gradle publish for tag: $SANITIZED_TAG"
105-
106-
./gradlew clean build publish -Pversion=$SANITIZED_TAG
107-
./gradlew jreleaserDeploy -Pversion=$SANITIZED_TAG

‎.github/workflows/release.yaml.yml‎

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
2+
#
3+
# SPDX-License-Identifier: MPL-2.0
4+
5+
name: Release to Maven central
6+
7+
on:
8+
workflow_dispatch:
9+
inputs:
10+
version:
11+
type: string
12+
description: Version tag
13+
required: true
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref }}
17+
cancel-in-progress: true
18+
19+
jobs:
20+
21+
publish:
22+
name: Publish to Maven central
23+
runs-on: ubuntu-latest
24+
environment: release
25+
permissions:
26+
contents: read
27+
28+
steps:
29+
- name: Checkout repository
30+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # 7.0.1
31+
with:
32+
fetch-depth: 1
33+
persist-credentials: false
34+
35+
- name: Setup runtime
36+
uses: ./.github/actions/setup-runtime
37+
38+
- name: Cache Gradle
39+
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 #v6.1.0
40+
with:
41+
path: |
42+
~/.gradle/caches
43+
~/.gradle/wrapper
44+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/settings.gradle*') }}
45+
46+
- name: Optimize Gradle
47+
shell: bash
48+
run: |
49+
mkdir -p ~/.gradle
50+
echo "org.gradle.caching=true" >> ~/.gradle/gradle.properties
51+
echo "org.gradle.configuration-cache=true" >> ~/.gradle/gradle.properties
52+
53+
- name: generate GitHub App token
54+
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
55+
id: generate-token
56+
with:
57+
client-id: ${{ secrets.RELEASE_BOT_APP_ID }}
58+
private-key: ${{ secrets.RELEASE_BOT_PRIVATE_KEY }}
59+
repositories: ${{ github.repository }}
60+
permission-contents: write
61+
62+
- name: Create GitHub release
63+
uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3.0.3
64+
with:
65+
tag_name: ${{ inputs.version }}
66+
generate_release_notes: true
67+
target_commitish: ${{ github.sha }}
68+
token: ${{ steps.generate-token.outputs.token }}
69+
70+
- name: Gradle Release Build
71+
env:
72+
JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
73+
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }}
74+
JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
75+
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.MAVEN_USERNAME }}
76+
JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
77+
run: |
78+
echo "Performing release Gradle publish for tag: ${{ inputs.version }}"
79+
80+
./gradlew clean build publish -Pversion=${{ inputs.version }}
81+
./gradlew jreleaserDeploy -Pversion=${{ inputs.version }}

0 commit comments

Comments
 (0)