-
Notifications
You must be signed in to change notification settings - Fork 51
120 lines (109 loc) · 3.98 KB
/
stable_patch_deployment.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
name: Stable Release
run-name: "Stable Release for ${{ github.ref_name }}"
on:
push:
branches:
- 'stable/**'
jobs:
determine-if-deploy:
runs-on: ubuntu-latest
outputs:
deploy: ${{ steps.tag_exists.outputs.exists == 'false' }}
version: ${{ steps.latest_version.outputs.version }}
steps:
- uses: actions/checkout@v3
- uses: actions/[email protected]
with:
python-version: "3.11"
- name: Install Changelogger
run: pip install changelogged==0.11.3
- name: Get Latest Version
id: latest_version
run: |
VERSION=$(changelogger versions --latest)
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- uses: mukunku/[email protected]
id: tag_exists
with:
tag: ${{ steps.latest_version.outputs.version }}
get-stable-tag:
runs-on: ubuntu-latest
continue-on-error: true
needs: determine-if-deploy
if: needs.determine-if-deploy.outputs.deploy == 'true'
outputs:
version: ${{ steps.bump_version.outputs.version || steps.init_version.outputs.version }}
steps:
- name: Extract Branch Version
shell: bash
run: |
# Strip the `stable/` prefix and the `x` suffix from the current
# release branch
VERSION_PREFIX=$(echo "${GITHUB_REF#refs/heads/}" | sed -e "s/^stable\///" -e "s/x//")
echo "version_prefix=${VERSION_PREFIX}" >> $GITHUB_OUTPUT
id: extract_version_prefix
- name: Find Latest Version
uses: oprypin/find-latest-tag@v1
with:
repository: ${{ github.repository }}
prefix: ${{ steps.extract_version_prefix.outputs.version_prefix }}
id: latest_patch
- name: Bump Patch Version
run: |
VERSION=$(echo ${{ steps.latest_patch.outputs.tag }} | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.)
echo "version=${VERSION}" >> $GITHUB_OUTPUT
id: bump_version
- name: Initial Release
if: failure()
run: |
# Version prefix is in the format `x.y.`, so we need to append a `0`
# to the end
echo "version=${{ steps.extract_version_prefix.outputs.version_prefix }}0" >> $GITHUB_OUTPUT
id: init_version
github-tag-and-release:
runs-on: ubuntu-latest
needs: [determine-if-deploy, get-stable-tag]
if: needs.determine-if-deploy.outputs.version == needs.get-stable-tag.outputs.version
steps:
- uses: actions/checkout@v3
- name: Setup Python 3.11
uses: actions/[email protected]
with:
python-version: '3.11'
- name: Install Changelogger
run: pip install changelogged==0.11.3
- name: Get Changelog Contents
id: changelog
run: |
DELIMITER=$(openssl rand -base64 12)
VERSION=${{ needs.determine-if-deploy.outputs.version }}
# Need to capture multiline output in env to preserve newlines
echo "content<<${DELIMITER}" >> $GITHUB_ENV
# Add changelog content to the env for release notes
changelogger notes $VERSION --no-pretty >> $GITHUB_ENV
echo ${DELIMITER} >> $GITHUB_ENV
- name: Create GitHub Tag & Release
uses: ncipollo/release-action@v1
with:
tag: ${{ needs.determine-if-deploy.outputs.version }}
commit: ${{ github.sha }}
name: Release ${{ needs.determine-if-deploy.outputs.version }}
body: ${{ env.content }}
prerelease: true
- name: Send PagerDuty alert on failure
if: ${{ failure() }}
uses: award28/[email protected]
with:
pagerduty-integration-key: '${{ secrets.PAGERDUTY_INTEGRATION_KEY }}'
pagerduty-dedup-key: magneto_two_cd
integration-release:
runs-on: ubuntu-latest
needs: [determine-if-deploy, github-tag-and-release]
steps:
- run: echo "Releasing to Magento2"
- name: Send PagerDuty alert on failure
if: ${{ failure() }}
uses: award28/[email protected]
with:
pagerduty-integration-key: '${{ secrets.PAGERDUTY_INTEGRATION_KEY }}'
pagerduty-dedup-key: magento_two_cd