|
| 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 | + |
| 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 }} |
0 commit comments