forked from operaton/operaton
-
Notifications
You must be signed in to change notification settings - Fork 0
150 lines (139 loc) · 5.12 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
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
name: Release
on:
workflow_dispatch:
inputs:
release_branch:
description: 'The branch to release from'
required: true
default: 'main'
next_version:
description: 'The next development version to set (without -SNAPSHOT suffix)'
required: true
dry_run:
description: 'Dry-Run: Skips remote operations when true'
type: boolean
required: true
default: false
jobs:
precheck:
name: Precheck
runs-on: ubuntu-latest
outputs:
version: ${{steps.version.outputs.version}}
is_prerelease: ${{steps.version.outputs.is_prerelease}}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{github.event.inputs.release_branch}}
- name: Version
id: version
shell: bash
run: |
RELEASE_VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout | tail -n 1 | sed -e 's/-SNAPSHOT//')
echo "version=$RELEASE_VERSION" >> $GITHUB_OUTPUT
if [[ "$RELEASE_VERSION" == *"alpha"* || "$RELEASE_VERSION" == *"beta"* ]]; then
echo "⚙ Releasing version '$RELEASE_VERSION' (Pre-Release)"
echo "is_prerelease=true" >> $GITHUB_OUTPUT
else
echo "⚙ Releasing version '$RELEASE_VERSION'"
echo "is_prerelease=false" >> $GITHUB_OUTPUT
fi
./mvnw versions:set -DnewVersion=$RELEASE_VERSION
if ! git diff-index --quiet HEAD --; then
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git commit -am "[releng] Releasing version $RELEASE_VERSION"
git push origin ${{github.event.inputs.release_branch}}
fi
release_build:
name: Release Build
needs: precheck
runs-on: ubuntu-latest
outputs:
output1: ${{steps.upload-release-artifacts.outputs.artifact-id}}
steps:
- name: Check out the code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{github.event.inputs.release_branch}}
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Maven Build
run: |
./mvnw clean deploy -Prelease -DaltDeploymentRepository=local::file:./target/staging-deploy
# https://slack-chats.kotlinlang.org/t/16407246/anyone-tried-the-https-central-sonatype-org-publish-publish-
find target -name maven-metadata.* -delete
- name: Upload Artifacts
id: upload-release-artifacts
uses: actions/upload-artifact@v4
with:
name: release-artifacts
path: ./*/staging-deploy/**
release:
name: Release
needs:
- precheck
- release_build
runs-on: ubuntu-latest
steps:
- name: Check out the code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{github.event.inputs.release_branch}}
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: release-artifacts
- name: Release with JReleaser
uses: jreleaser/release-action@v2
env:
JRELEASER_PROJECT_VERSION: ${{needs.precheck.outputs.version}}
JRELEASER_GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
JRELEASER_GPG_PUBLIC_KEY: ${{secrets.GPG_PUBLIC_KEY}}
JRELEASER_GPG_SECRET_KEY: ${{secrets.GPG_PRIVATE_KEY}}
JRELEASER_GPG_PASSPHRASE: ${{secrets.GPG_PASSPHRASE}}
JRELEASER_MAVENCENTRAL_USERNAME: ${{secrets.OSSRH_USERNAME}}
JRELEASER_MAVENCENTRAL_PASSWORD: ${{secrets.OSSRH_PASSWORD}}
JRELEASER_NEXUS2_USERNAME: ${{secrets.OSSRH_USERNAME}}
JRELEASER_NEXUS2_PASSWORD: ${{secrets.OSSRH_PASSWORD}}
JRELEASER_DRY_RUN: ${{github.event.inputs.dry_run}}
JRELEASER_PRERELEASE_ENABLED: ${{needs.precheck.outputs.is_prerelease}}
- name: Upload Build Reports
if: always()
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: ${{ github.workspace }}/**/**
retention-days: 1
post_release:
name: Post-Release
needs: release
runs-on: ubuntu-latest
steps:
- name: Check out the code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{github.event.inputs.release_branch}}
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Set next development version
run: |
NEXT_VERSION=${{github.event.inputs.next_version}}-SNAPSHOT
./mvnw versions:set -DnewVersion=$NEXT_VERSION
if ! git diff-index --quiet HEAD --; then
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git commit --allow-empty -am "[releng] Bump version to $NEXT_VERSION"
git push origin ${{github.event.inputs.release_branch}}
fi