-
Notifications
You must be signed in to change notification settings - Fork 0
144 lines (138 loc) · 6.64 KB
/
release.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
name: Release
run-name: "Release ${{ inputs.version }} from branch ${{ inputs.target-branch }} ${{ inputs.dry-run && '(DRY RUN)' || ''}}"
on:
workflow_dispatch:
inputs:
target-branch:
description: "Branch to release"
required: true
type: choice
default: 'main'
options:
- "main"
- "24.4"
- "2.5"
- "2.4"
- "2.3"
- "2.2"
- "2.1"
- "1.3"
version:
description: "Version to release (e.g. 1.1.0 or 1.2.0-alpha1)"
required: true
type: string
hilla-version:
description: |
Version of Hilla to pin for this release. If not provided, the value of the hilla.version property in will be used.
If the Hilla version is a SNAPSHOT, the latest available release compatible with quarkus-hilla major.minor will be used.
required: false
type: string
dry-run:
description: "Dry run (skips remote operations)"
required: true
type: boolean
default: false
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- uses: actions-cool/check-user-permission@main
id: checkUser
with:
username: ${{github.triggering_actor}}
check-contributor: true
require: 'write'
- name: Fail on workflow triggered by external contributor
if: ${{ steps.checkUser.outputs.require-result != 'true' }}
run: |
echo "🚫 **${{ github.actor }}** is an external contributor, only **${{ github.repository }}** team members can perform a release" \
| tee -a $GITHUB_STEP_SUMMARY && exit 1
- name: Validate Workflow branch
if: ${{ !github.event.inputs.dry-run }}
run: |
BRANCH_NAME=${GITHUB_REF##*/}
if [[ "main" != "${BRANCH_NAME}" ]]; then
echo "🚫 Release Workflow must be dispatched on 'main' branch." \
| tee -a $GITHUB_STEP_SUMMARY
exit 1
fi
- name: Checkout
uses: actions/checkout@v3
with:
ref: refs/heads/${{ inputs.target-branch }}
fetch-depth: 0
- name: Validate version
run: |
VERSION_REGEX='^[0-9]+\.[0-9]+\.[0-9]+(-(alpha|beta|rc)[0-9]+)?$'
if [[ ! "${{ inputs.version }}" =~ $VERSION_REGEX ]]; then
echo "🚫 Invalid version specified: '${{ inputs.version }}'. Please enter a valid SemVer version, like '1.2.3' or '1.0.0-alpha1'." \
| tee -a $GITHUB_STEP_SUMMARY
exit 1
fi
if [[ "${{ inputs.target-branch }}" != "main" && ! "${{ inputs.version }}" = "${{ inputs.target-branch }}."* ]]; then
echo "🚫 Invalid version specified: '${{ inputs.version }}' does not match the release branch '${{ inputs.target-branch }}'." \
| tee -a $GITHUB_STEP_SUMMARY
exit 1
fi
if git rev-parse -q --verify "refs/tags/${{ inputs.version }}" > /dev/null; then
echo "🚫 Version '${{ inputs.version }}' already exists. Please choose a different version." \
| tee -a $GITHUB_STEP_SUMMARY
exit 1
fi
echo "Releasing version '${{ inputs.version }}' from branch '${{ inputs.target-branch }}'." | tee -a $GITHUB_STEP_SUMMARY
if [[ "${{ github.event.inputs.dry-run }}" == "true" ]]; then
echo "⚠️ dry-run execution, artifacts will not be published on Maven Central." | tee -a $GITHUB_STEP_SUMMARY
fi
- name: Pin Hilla version
run: |
hilla_version=$(mvn -ntp -N -q help:evaluate -Dexpression=hilla.version -DforceStdout)
hilla_version_major_minor=$(echo "${hilla_version/-*/}" | cut -d. -f1,2)
echo "POM file Hilla version: $hilla_version." | tee -a $GITHUB_STEP_SUMMARY
if [[ -n "${{ inputs.hilla-version }}" ]]; then
if [[ "${{ inputs.hilla-version }}" = "${hilla_version_major_minor}."* ]]; then
mvn -N -ntp versions:set-property -Dproperty=hilla.version -DnewVersion="${{ inputs.hilla-version }}"
echo "⚠️ Hilla version manually forced to ${{ inputs.hilla-version }}." | tee -a $GITHUB_STEP_SUMMARY
hilla_version="${{ inputs.hilla-version }}"
else
echo "🚫 Forced Hilla version '${{ inputs.hilla-version }}' does not match Hilla version on release branch '$hilla_version_major_minor'." \
| tee -a $GITHUB_STEP_SUMMARY
exit 1
fi
fi
if [[ "$hilla_version" =~ .*-SNAPSHOT ]]; then
mvn -N -ntp -Dproperty=hilla.version -DallowMinorUpdates=false -DgenerateBackupPoms=false -Dmaven.version.rules=file://$(pwd)/etc/release-version-rules.xml versions:update-property
hilla_version=$(mvn -ntp -N -q help:evaluate -Dexpression=hilla.version -DforceStdout)
echo "⚠️ SNAPSHOT detected for Hilla version. Automatically forcing version to $hilla_version." | tee -a $GITHUB_STEP_SUMMARY
fi
if [[ "$hilla_version" =~ .*-SNAPSHOT ]]; then
echo "🚫 Hilla version '${{ inputs.hilla-version }}' is a SNAPSHOT. Please provide a proper release version." \
| tee -a $GITHUB_STEP_SUMMARY
exit 1
fi
- name: Setup Java
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'
- name: Staging artifacts
run: |
mvn -V -ntp -Pdistribution,default-modules -Drevision=${{ inputs.version }} -DaltDeploymentRepository=local::file:./target/staging-deploy ${{ github.event.inputs.dry-run && '-DskipTests' || '' }} deploy
- name: Run JReleaser
env:
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JRELEASER_DEPLOY_MAVEN_ARTIFACTORY_TOKEN: ${{ secrets.JFROG_TOKEN }}
JRELEASER_NEXUS2_MAVEN_CENTRAL_USERNAME: ${{ secrets.JRELEASER_NEXUS2_MAVEN_CENTRAL_USERNAME }}
JRELEASER_NEXUS2_MAVEN_CENTRAL_PASSWORD: ${{ secrets.JRELEASER_NEXUS2_MAVEN_CENTRAL_PASSWORD }}
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.JRELEASER_GPG_PUBLIC_KEY }}
JRELEASER_GPG_SECRET_KEY: ${{ secrets.JRELEASER_GPG_SECRET_KEY }}
JRELEASER_GPG_PASSPHRASE: ${{ secrets.JRELEASER_GPG_PASSPHRASE }}
run: |
mvn -N -V -ntp -Pdistribution -Drevision=${{ inputs.version }} -Djreleaser.dry.run="${{ github.event.inputs.dry-run }}" ${{ github.event.inputs.dry-run && '-DskipTests' || '' }} jreleaser:full-release
- name: JReleaser release output
if: always()
uses: actions/upload-artifact@v3
with:
name: jreleaser-release
path: |
target/jreleaser/**