-
Notifications
You must be signed in to change notification settings - Fork 3
135 lines (119 loc) · 4.34 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
name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'Release version'
required: true
version-fragment:
description: 'Version fragment to increase for next development cycle'
required: true
default: 'minor'
type: choice
options:
- major
- minor
- patch
env:
BOT_USER_NAME: eclipse-cbi-bot
BOT_EMAIL: [email protected]
JAVA_VERSION: 17
JAVA_DISTRO: 'temurin'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
precheck:
runs-on: ubuntu-22.04
permissions:
contents: write
if: github.repository == 'eclipse-cbi/macos-notarization-service'
outputs:
release-version: ${{ steps.prepare-release.outputs.RELEASE_VERSION }}
steps:
- name: Check ref
shell: bash
run: |
if [ "${{ github.ref }}" != "refs/heads/main" ]; then
echo "Release shall only be made from 'main' branch, triggered branch '${{ github.ref_name }}', aborting."
exit 1
fi
- name: Setup Git User
run: |
git config --global user.name '${{ env.BOT_USER_NAME }}'
git config --global user.email '${{ env.BOT_EMAIL }}'
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
ref: ${{ github.ref }}
fetch-depth: 0
- name: Setup Java
uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRO }}
cache: maven
- name: Prepare release
id: prepare-release
shell: bash
run: |
PROJECT_VERSION="$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)"
RELEASE_VERSION="${{ github.event.inputs.version }}"
echo "PROJECT_VERSION=$(echo $PROJECT_VERSION)" >> $GITHUB_OUTPUT
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_OUTPUT
echo "Project version: $PROJECT_VERSION"
echo "Release version: $RELEASE_VERSION"
if git show-ref --tags --verify --quiet "refs/tags/v${RELEASE_VERSION}"; then
echo "Release Tag 'v${RELEASE_VERSION}' already exists, aborting."
exit 1
fi
if [ "$PROJECT_VERSION" != "$RELEASE_VERSION" ]; then
./mvnw -B versions:set versions:commit -DnewVersion=$RELEASE_VERSION
git commit -a -m "Releasing version $RELEASE_VERSION"
git push origin ${{ github.ref }}
fi
release:
needs: ['precheck']
permissions:
contents: write
actions: read
packages: write
id-token: write
uses: jreleaser/release-action/.github/workflows/[email protected] # ignore: pin
with:
project-version: ${{ needs.precheck.outputs.release-version }}
branch: ${{ github.ref_name }}
jreleaser-version: '1.9.0'
java-version: 17
java-distribution: 'temurin'
rekor-log-public: true
secrets:
github-token: ${{ secrets.GITHUB_TOKEN }}
prepare-for-next-development-cycle:
runs-on: ubuntu-22.04
needs: ['precheck', 'release']
permissions:
contents: write
steps:
- name: Setup Git User
run: |
git config --global user.name '${{ env.BOT_USER_NAME }}'
git config --global user.email '${{ env.BOT_EMAIL }}'
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
ref: ${{ github.ref }}
- name: Setup Java
uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRO }}
cache: maven
- id: increase-semver
uses: ./.github/actions/increase-semver
with:
current-version: ${{ needs.precheck.outputs.release-version }}
version-fragment: ${{ github.event.inputs.version-fragment }}
- name: Update next development version in POMs
run: |
./mvnw -B versions:set versions:commit -DnewVersion=${{ steps.increase-semver.outputs.next-version }}-SNAPSHOT -DgenerateBackupPoms=false
git commit -a -m "Prepare for next development cycle"
git push origin ${{ github.ref }}