-
Notifications
You must be signed in to change notification settings - Fork 3
75 lines (64 loc) · 2.51 KB
/
helper-release-jira.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
# Copyright (C) 2023 Dynamic Solutions
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: 'Helper: Create JIRA release'
on:
workflow_dispatch:
inputs:
tag:
description: "Tag"
type: string
required: false
workflow_call:
inputs:
tag:
description: "Tag"
type: string
required: false
env:
JIRA_PROJECT_ID: ${{ vars.ATLASSIAN_CLOUD_JIRA_PROJECT_ID }}
JIRA_PROJECT_NAME: ${{ vars.ATLASSIAN_CLOUD_JIRA_PROJECT_NAME }}
jobs:
create-jira-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: '0'
- name: Prepare release
run: |
RELEASE_NAME_PREFIX=""
if [ -z "${{ inputs.tag }}" ]; then
RELEASED_VERSION=$(git describe --tags --abbrev=0)
else
RELEASED_VERSION=${{ inputs.tag }}
fi
echo "Released version: ${RELEASED_VERSION}"
PREVIOUS_VERSION=$(git describe --abbrev=0 ${RELEASED_VERSION}^)
echo "Previous version: ${PREVIOUS_VERSION}"
COMMITS=$(git log ${PREVIOUS_VERSION}..${RELEASED_VERSION} --pretty=format:"%s" | grep ${ env.JIRA_PROJECT_NAME } || true)
TICKETS=$(echo "${COMMITS}" | grep -o ${ env.JIRA_PROJECT_NAME '\-[0-9]\+' | sort -u | paste -sd "," - || true)
echo "Tickets found in commit messages: ${TICKETS}"
echo "RELEASE_NAME=${RELEASE_NAME_PREFIX}${RELEASED_VERSION}" >> $GITHUB_ENV
echo "TICKETS=${TICKETS}" >> $GITHUB_ENV
- name: Release Jira Version
uses: charpi/[email protected]
with:
create: true
email: ${{ secrets.ATLASSIAN_CLOUD_USER }}
api_token: ${{ secrets.ATLASSIAN_CLOUD_APIKEY }}
subdomain: ${{ secrets.ATLASSIAN_CLOUD_DOMAIN }}
jira_project: ${{ env.JIRA_PROJECT_ID }}
tickets: ${{ env.TICKETS }}
release_name: ${{ env.RELEASE_NAME }}