-
Notifications
You must be signed in to change notification settings - Fork 0
163 lines (155 loc) · 6.36 KB
/
publish-release.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
name: "Publish new release"
on:
pull_request:
branches:
- stable
types:
- closed
jobs:
release:
name: Publish new release
runs-on: ubuntu-latest
outputs:
change_bq: ${{ steps.changes.outputs.bigquery }}
change_db: ${{ steps.changes.outputs.databricks }}
change_pg: ${{ steps.changes.outputs.postgres }}
change_rs: ${{ steps.changes.outputs.redshift }}
change_sf: ${{ steps.changes.outputs.snowflake }}
# only merged pull requests that begin with 'release/' or 'hotfix/' must trigger this job
if: github.event.pull_request.merged == true &&
(startsWith(github.event.pull_request.head.ref, 'release/') || startsWith(github.event.pull_request.head.ref, 'hotfix/'))
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.PERSONAL_GITHUB_TOKEN }}
- name: Extract version from branch name (for release branches)
if: startsWith(github.event.pull_request.head.ref, 'release/')
run: |
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
VERSION=${BRANCH_NAME#release/}
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
- name: Extract version from branch name (for hotfix branches)
if: startsWith(github.event.pull_request.head.ref, 'hotfix/')
run: |
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
VERSION=${BRANCH_NAME#hotfix/}
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
bigquery:
- 'clouds/bigquery/version'
databricks:
- 'clouds/databricks/version'
postgres:
- 'clouds/postgres/version'
redshift:
- 'clouds/redshift/version'
snowflake:
- 'clouds/snowflake/version'
base: stable
- name: Create release body
run: |
BQ_VERSION=$(cat clouds/bigquery/version)
DB_VERSION=$(cat clouds/databricks/version)
PG_VERSION=$(cat clouds/postgres/version)
RS_VERSION=$(cat clouds/redshift/version)
SF_VERSION=$(cat clouds/snowflake/version)
RELEASE_BODY="# Release version ${{ env.RELEASE_VERSION }}"
if [[ ${{ steps.changes.outputs.bigquery }} = "true" ]]; then
RELEASE_BODY+="\n- Bigquery release version $BQ_VERSION - [CHANGELOG](https://github.com/${{ github.repository }}/blob/stable/clouds/bigquery/CHANGELOG.md)"
fi
if [[ ${{ steps.changes.outputs.databricks }} = "true" ]]; then
RELEASE_BODY+="\n- Databricks release version $DB_VERSION - [CHANGELOG](https://github.com/${{ github.repository }}/blob/stable/clouds/databricks/CHANGELOG.md)"
fi
if [[ ${{ steps.changes.outputs.postgres }} = "true" ]]; then
RELEASE_BODY+="\n- Postgres release version $PG_VERSION - [CHANGELOG](https://github.com/${{ github.repository }}/blob/stable/clouds/postgres/CHANGELOG.md)"
fi
if [[ ${{ steps.changes.outputs.redshift }} = "true" ]]; then
RELEASE_BODY+="\n- Redshift release version $RS_VERSION - [CHANGELOG](https://github.com/${{ github.repository }}/blob/stable/clouds/redshift/CHANGELOG.md)"
fi
if [[ ${{ steps.changes.outputs.snowflake }} = "true" ]]; then
RELEASE_BODY+="\n- Snowflake release version $SF_VERSION - [CHANGELOG](https://github.com/${{ github.repository }}/blob/stable/clouds/snowflake/CHANGELOG.md)"
fi
echo -e "body - $RELEASE_BODY"
echo 'RELEASE_BODY<<EOF' >> $GITHUB_ENV
echo -e $RELEASE_BODY >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Create Release
uses: ncipollo/release-action@v1
with:
commit: ${{ github.event.pull_request.merge_commit_sha }}
tag: ${{ env.RELEASE_VERSION }}
name: ${{ env.RELEASE_VERSION }}
draft: false
prerelease: false
token: ${{ secrets.GITHUB_TOKEN }}
body: ${{ env.RELEASE_BODY }}
- name: Create PR from stable into main branch
uses: repo-sync/pull-request@v2
id: pull_request
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
source_branch: ${{ github.event.pull_request.head.ref }}
destination_branch: main
pr_title: Merge master into dev branch
pr_body: |
This PR merges the master branch back into dev.
This happens to ensure that the updates that happend on the release branch, i.e. CHANGELOG and manifest updates are also present on the dev branch.
- name: Merge PR if possible
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_GITHUB_TOKEN }}
run: |
gh pr merge ${{ steps.pull_request.outputs.pr_number }} --auto --merge
publish-bq:
needs: release
if: needs.release.outputs.change_bq == 'true'
name: "Publish AT for BigQuery"
uses: aarroyosal/AT-poc/.github/workflows/bigquery.yml@stable
secrets: inherit
publish-db:
needs: release
if: needs.release.outputs.change_db == 'true'
name: "Publish AT for Databricks"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: deploy-db
run: |
DB_VERSION=$(cat clouds/databricks/version)
echo "publish databricks version ${DB_VERSION}"
publish-pg:
needs: release
if: needs.release.outputs.change_pg == 'true'
name: "Publish AT for Postgres"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: deploy-pg
run: |
PG_VERSION=$(cat clouds/postgres/version)
echo "publish postgres version ${PG_VERSION}"
publish-rs:
needs: release
if: needs.release.outputs.change_rs == 'true'
name: "Publish AT for Redshift"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: deploy-rs
run: |
RS_VERSION=$(cat clouds/redshift/version)
echo "publish redshift version ${RS_VERSION}"
publish-sf:
needs: release
if: needs.release.outputs.change_sf == 'true'
name: "Publish AT for Snowflake"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: deploy-sf
run: |
SF_VERSION=$(cat clouds/snowflake/version)
echo "publish snowflake version ${SF_VERSION}}"