-
Notifications
You must be signed in to change notification settings - Fork 0
144 lines (130 loc) · 4.57 KB
/
create_rc_release.yml
File metadata and controls
144 lines (130 loc) · 4.57 KB
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
name: Create Release Candidate
on:
# workflow_dispatch: {}
push:
tags:
- "*-rc[0-9]+"
# pull_request:
# types: [ opened, synchronize, reopened ]
# branches:
# - "*-rc[0-9]+"
# branches: [ main ]
permissions:
id-token: write
contents: write
concurrency:
cancel-in-progress: true
group: report-server-build-app-rc
#PR src: ${{ github.event.pull_request.head.ref }}
#PR dst: ${{ github.event.pull_request.base.ref }}
jobs:
should-run:
runs-on: ubuntu-latest
# TODO Might not need this check because the tag is filtered at workflow trigger
# TODO Also we are not a pull request anymore
#if: github.event.pull_request.merged == true && (contains(toJSON(github.event.pull_request.head.ref), 'release/') || contains(toJSON(github.event.pull_request.head.ref), 'hotfix/'))
steps:
- run: |
if [[ echo '${{ github.event.ref }}' | grep -E -e '-rc[0-9]+' ]]; then
echo "Branch is valid to deploy a release candidate. Proceeding ..."
else
echo "Branch does not match release candidate branch pattern."
exit 1
fi
# steps:
# - name: Check Branch
# run: |
# if [[ ${{ github.ref }} == 'refs/heads/release/'* ]]; then
# echo "Branch is valid to deploy a release candidate. Proceeding ..."
# else
# echo "Branch don't match release candidate branch pattern."
# exit 1
# fi
debug:
runs-on: ubuntu-latest
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- name: Dump job context
env:
JOB_CONTEXT: ${{ toJson(job) }}
run: echo "$JOB_CONTEXT"
tag:
runs-on: ubuntu-latest
needs: should-run
outputs:
tag: ${{ steps.tag.outputs.current }}
previous: ${{ steps.tag.outputs.previous }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Get RC Version
id: tag
run: |
# echo "current=$(echo '${{ github.event.pull_request.head.ref }}' | sed 's:.*/::')" >> $GITHUB_OUTPUT
echo "current=${{ github.ref_name }}" >> $GITHUB_OUTPUT
echo "previous=$(gh release list --exclude-drafts --exclude-pre-releases --json tagName,isLatest | jq -r '.[] | select(.isLatest == true) | .tagName')" >> $GITHUB_OUTPUT
# Done via the script
# - name: Push tag to Repository
# run: |
# git config --global user.name "Automated User"
# git config --global user.email "automateduser@mindlogger"
# git tag ${{ steps.tag.outputs.current }}
# git push origin refs/tags/${{ steps.tag.outputs.current }}
build:
name: Build Release Candidate
runs-on: ubuntu-latest
# uses: ./.github/workflows/build_push.yaml
needs: tag
# with:
# tag: ${{ needs.tag.outputs.tag }}
steps:
- name: Build
run: echo "Building..."
deploy:
name: Deploy
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: main
- name: Deploy Release Candidate
run: echo "Deploy"
# When the RC successfully deploys, create a Github Release
create-release:
name: Publish Release Candidate
needs: [tag, deploy]
if: ${{ !cancelled() && needs.deploy.result == 'success' }}
runs-on: ubuntu-latest
steps:
- name: Create Release
run: |
gh release create ${{ needs.tag.outputs.tag }} --title "${{ needs.tag.outputs.tag }}" --target main --generate-notes --notes-start-tag ${{ needs.tag.outputs.previous }} --prerelease
env:
GH_TOKEN: ${{ github.token }}
slack-notify:
name: Notify slack
needs: [tag, deploy]
runs-on: ubuntu-latest
steps:
- name: Get JIRA issues
run: |
tickets=$(gh release view ${{ needs.tag.outputs.tag }} --json body | jq -r .body | grep -io 'M2-[0-9]\+' | tr '[:lower:]' '[:upper:]' | sort | uniq | tr '\n' ' ')
if [ -z "$tickets" ]; then
echo "No Jira tickets found in the release."
else
echo "Jira ticket numbers found: ${tickets}"
file="jira-tickets.json"
echo "{ \"issues\": $(echo "${tickets}" | jq -R -s -c 'split(" ")[:-1]') }" > "${file}"
echo "Jira ticket numbers saved to ${file}"
fi
fi
# TODO Send issue list to #release-communications