-
Notifications
You must be signed in to change notification settings - Fork 6
162 lines (144 loc) · 5.91 KB
/
flow-deploy-release-artifact.yaml
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
name: "Deploy Release Artifact"
on:
workflow_dispatch:
inputs:
java-version:
description: "Java JDK Version:"
type: string
required: false
default: "17.0.9"
java-distribution:
description: "Java JDK Distribution:"
type: string
required: false
default: "temurin"
push:
branches:
- main
tags:
- "v[0-9]+.[0-9]+.[0-9]+-?*"
defaults:
run:
shell: bash
permissions:
contents: read
env:
LC_ALL: C.UTF-8
PBJ_CORE: pbj-core
GRADLE_CACHE_USERNAME: ${{ secrets.GRADLE_CACHE_USERNAME }}
GRADLE_CACHE_PASSWORD: ${{ secrets.GRADLE_CACHE_PASSWORD }}
jobs:
prepare-release:
name: Release / Prepare
runs-on: [self-hosted, Linux, medium, ephemeral]
outputs:
mode: ${{ steps.info.outputs.mode }}
version: ${{ steps.info.outputs.version }}
prerelease: ${{ steps.info.outputs.prerelease }}
steps:
- name: Install Semantic Version Tools
run: |
echo "::group::Download SemVer Binary"
sudo curl -L -o /usr/local/bin/semver https://raw.githubusercontent.com/fsaintjacques/semver-tool/master/src/semver
echo "::endgroup::"
echo "::group::Change SemVer Binary Permissions"
sudo chmod -v +x /usr/local/bin/semver
echo "::endgroup::"
echo "::group::Show SemVer Binary Version Info"
semver --version
echo "::endgroup::"
- name: Extract Version Info
id: info
env:
IS_TAGGED_RELEASE: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') }}
run: |
if [[ "${IS_TAGGED_RELEASE}" == true ]]; then
RELEASE_VERSION="$(semver get release "${{ github.ref_name }}")"
PRERELEASE_VERSION="$(semver get prerel "${{ github.ref_name }}")"
RELEASE_MODE="specified"
FINAL_VERSION="${RELEASE_VERSION}"
PRERELEASE_FLAG="false"
[[ -n "${PRERELEASE_VERSION}" ]] && FINAL_VERSION="${RELEASE_VERSION}-${PRERELEASE_VERSION}"
[[ -n "${PRERELEASE_VERSION}" ]] && PRERELEASE_FLAG="true"
else
RELEASE_MODE="snapshot"
PRERELEASE_FLAG="true"
FINAL_VERSION=""
fi
echo "mode=${RELEASE_MODE}" >>"${GITHUB_OUTPUT}"
echo "version=${FINAL_VERSION}" >>"${GITHUB_OUTPUT}"
echo "prerelease=${PRERELEASE_FLAG}" >>"${GITHUB_OUTPUT}"
maven-central-release:
name: Release / Maven Central
runs-on: [self-hosted, Linux, medium, ephemeral]
needs:
- prepare-release
if: |
(needs.prepare-release.outputs.mode == 'specified' && needs.prepare-release.outputs.prerelease != 'true')
|| needs.prepare-release.outputs.mode == 'snapshot'
steps:
- name: Checkout Code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0
- name: Setup Java
uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0
with:
distribution: ${{ github.event.inputs.java-distribution || 'temurin' }}
java-version: ${{ github.event.inputs.java-version || '17.0.9' }}
- name: Setup Gradle
uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a # v2.9.0
with:
gradle-home-cache-strict-match: false
- name: Install GnuPG Tools
run: |
if ! command -v gpg2 >/dev/null 2>&1; then
echo "::group::Updating APT Repository Indices"
sudo apt update
echo "::endgroup::"
echo "::group::Installing GnuPG Tools"
sudo apt install -y gnupg2
echo "::endgroup::"
fi
- name: Import GPG key
id: gpg_key
uses: crazy-max/ghaction-import-gpg@82a020f1f7f605c65dd2449b392a52c3fcfef7ef # v6.0.0
with:
gpg_private_key: ${{ secrets.GPG_KEY_CONTENTS }}
passphrase: ${{ secrets.GPG_KEY_PASSPHRASE }}
git_config_global: true
git_user_signingkey: true
git_commit_gpgsign: true
git_tag_gpgsign: true
- name: Gradle Update Version (As Specified)
if: ${{ needs.prepare-release.outputs.mode == 'specified' && !cancelled() && !failure() }}
working-directory: ${{ env.PBJ_CORE }}
run: ./gradlew versionAsSpecified -PnewVersion=${{ needs.prepare-release.outputs.version }} --scan
- name: Gradle Update Version (Snapshot)
if: ${{ needs.prepare-release.outputs.mode == 'snapshot' && !cancelled() && !failure() }}
working-directory: ${{ env.PBJ_CORE }}
run: ./gradlew versionAsSnapshot --scan
- name: Gradle Version Summary
working-directory: ${{ env.PBJ_CORE }}
run: ./gradlew githubVersionSummary --scan
- name: Gradle Assemble
working-directory: ${{ env.PBJ_CORE }}
run: ./gradlew assemble --scan
- name: Gradle Maven Central Release
if: ${{ needs.prepare-release.outputs.mode == 'specified' && !cancelled() && !failure() }}
working-directory: ${{ env.PBJ_CORE }}
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
GRADLE_PUBLISH_KEY: ${{ secrets.GRADLE_PUBLISH_KEY }}
GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_PUBLISH_SECRET }}
run: |
./gradlew release --no-parallel --scan -PpublishSigningEnabled=true \
-Pgradle.publish.key=${GRADLE_PUBLISH_KEY} -Pgradle.publish.secret=${GRADLE_PUBLISH_SECRET}
- name: Gradle Maven Central Snapshot
if: ${{ needs.prepare-release.outputs.mode == 'snapshot' && !cancelled() && !failure() }}
working-directory: ${{ env.PBJ_CORE }}
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
run: ./gradlew releaseSnapshot --no-parallel --scan -PpublishSigningEnabled=true