Skip to content

Commit 74fbf2d

Browse files
[DXP-1209] Add GH action to put release version into jira ticket (#121)
1 parent e1a8fb1 commit 74fbf2d

File tree

2 files changed

+88
-1
lines changed

2 files changed

+88
-1
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Copyright (C) 2024 Dynamic Solutions
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: 'Helper: Create JIRA release'
16+
17+
on:
18+
workflow_dispatch:
19+
inputs:
20+
tag:
21+
description: "Tag"
22+
type: string
23+
required: false
24+
workflow_call:
25+
inputs:
26+
tag:
27+
description: "Tag"
28+
type: string
29+
required: false
30+
31+
env:
32+
JIRA_PROJECT: ${{ vars.ATLASSIAN_CLOUD_JIRA_PROJECT }}
33+
34+
jobs:
35+
create-jira-release:
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: actions/checkout@v4
39+
with:
40+
fetch-depth: '0'
41+
- name: Prepare release
42+
run: |
43+
RELEASE_NAME_PREFIX=""
44+
45+
if [ -z "${{ inputs.tag }}" ]; then
46+
RELEASED_VERSION=$(git describe --tags --abbrev=0)
47+
else
48+
RELEASED_VERSION=${{ inputs.tag }}
49+
echo "Using provided tag from inputs"
50+
fi
51+
52+
echo "Released version: ${RELEASED_VERSION}"
53+
54+
PREVIOUS_VERSION=$(git describe --abbrev=0 ${RELEASED_VERSION}^ --tags)
55+
echo "Previous version: ${PREVIOUS_VERSION}"
56+
57+
COMMITS=$(git log ${PREVIOUS_VERSION}..${RELEASED_VERSION} --pretty=format:"%s" | grep ${{ env.JIRA_PROJECT }} || true)
58+
TICKETS=$(echo "${COMMITS}" | grep -o '${{ env.JIRA_PROJECT }}\-[0-9]\+' | sort -u | paste -sd "," - || true)
59+
echo "Tickets found in commit messages: ${TICKETS}"
60+
61+
echo "RELEASE_NAME=${RELEASE_NAME_PREFIX}${RELEASED_VERSION}" >> $GITHUB_ENV
62+
echo "TICKETS=${TICKETS}" >> $GITHUB_ENV
63+
64+
- name: Release Jira Version
65+
uses: charpi/[email protected]
66+
with:
67+
create: true
68+
email: ${{ secrets.ATLASSIAN_CLOUD_USER }}
69+
api_token: ${{ secrets.ATLASSIAN_CLOUD_APIKEY }}
70+
subdomain: ${{ secrets.ATLASSIAN_CLOUD_DOMAIN }}
71+
jira_project: ${{ env.JIRA_PROJECT }}
72+
tickets: ${{ env.TICKETS }}
73+
release_name: ${{ env.RELEASE_NAME }}

.github/workflows/release.yaml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ permissions:
1010
jobs:
1111
release:
1212
runs-on: ubuntu-latest
13+
outputs:
14+
released-version: ${{ steps.prepare-release.outputs.RELEASED_VERSION }}
1315
steps:
1416
- name: Checkout
1517
uses: actions/checkout@v4
@@ -38,7 +40,12 @@ jobs:
3840
distribution: 'adopt'
3941

4042
- name: Release prepare
41-
run: ./mvnw -B release:prepare
43+
id: prepare-release
44+
run: |
45+
./mvnw -B release:prepare
46+
RELEASED_VERSION=$(git describe --tags --abbrev=0)
47+
echo "RELEASED_VERSION=${RELEASED_VERSION}" >> $GITHUB_ENV
48+
echo "RELEASED_VERSION=${RELEASED_VERSION}" >> $GITHUB_OUTPUT
4249
4350
- name: Release perform
4451
env:
@@ -47,3 +54,10 @@ jobs:
4754
JRELEASER_SCOOP_GITHUB_TOKEN: ${{ secrets.JRELEASER_SCOOP_GITHUB_TOKEN }}
4855
run: |
4956
./mvnw -B release:perform -P release
57+
58+
release-jira:
59+
needs: release
60+
uses: ./.github/workflows/helper-release-jira.yaml
61+
secrets: inherit
62+
with:
63+
tag: ${{ needs.release.outputs.released-version }}

0 commit comments

Comments
 (0)