forked from twilio/twilio-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
201 lines (197 loc) · 7.67 KB
/
draft-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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
name: Cli Draft Release
on:
workflow_dispatch:
inputs:
change-log:
description: 'Open API Changelog.'
version-type:
description: 'Version to upgrade, Major: 0, Minor:1, Patch: 2'
homebrew-branch:
description: 'HomeBrew branch name'
default: main
homebrew-prerelease:
description: 'HomeBrew prerelease'
default: 'true'
draft-release:
description: 'Draft-release flag (true/false)'
default: 'true'
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 16.x, 14.x]
steps:
- name: Checkout cli repo
uses: actions/checkout@v2
- run: make install
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Run tests
run: npm test
update-api-definitions-changelog:
runs-on: ubuntu-latest
# needs: [test]
steps:
- name: Checkout cli
uses: actions/checkout@v2
with:
token: ${{ secrets.REPO_ACCESS_TOKEN }}
- name: Update Changelog
run: |
bash .github/scripts/commit-api-spec-change-log.sh "${{ github.event.inputs.change-log }}" ${{ github.event.inputs.version-type }}
release:
runs-on: ubuntu-latest
needs: [update-api-definitions-changelog]
outputs:
draft-tag-name: ${{ steps.semantic-release-draft.outputs.TAG_NAME }}
steps:
- name: Checkout cli
uses: actions/checkout@v2
with:
persist-credentials: false
- name: Run git and npm update
run: |
git pull
make install
- name: Semantic Release runs for draft release
id: semantic-release-draft
run: DEBUG=semantic-release:* $(npm bin)/semantic-release -t \${version}
env:
GITHUB_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Extract branch name
id: extract_branch
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
- name: Run testing for release-draft
if: ${{ github.event.inputs.draft-release == 'true' && steps.semantic-release-draft.outputs.TAG_NAME != '' }}
run: node .github/scripts/trigger-workflow.js
env:
WORKFLOW_NAME: '.github/workflows/cli-test-npm.yml'
REPO_NAME: twilio/twilio-cli
REPO_ACCESS_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}
BRANCH_NAME: ${{steps.extract_branch.outputs.branch}}
INPUTS: '{ "version": "${{ steps.semantic-release-draft.outputs.TAG_NAME }}" }'
- name: verify release required
if: ${{ steps.semantic-release-draft.outputs.TAG_NAME == ''}}
uses: actions/github-script@v3
with:
script: |
core.setFailed('There are no relevant changes, so no new version is released.')
- name: Update release
if: ${{steps.semantic-release-draft.outputs.TAG_NAME != ''}}
run: node .github/scripts/update-release.js
env:
TAG_NAME: ${{steps.semantic-release-draft.outputs.TAG_NAME}}
RELEASE_BODY: ${{github.event.inputs.change-log}}
REPO_NAME: twilio/twilio-cli
REPO_ACCESS_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
INPUTS: '{ "tag-name": "${{needs.release.outputs.draft-tag-name}}" }'
oclif-release:
runs-on: ubuntu-latest
needs: [release]
steps:
- name: Checkout cli repo
uses: actions/checkout@v2
- run: |
git pull
make install
- name: Extract branch name
id: extract_branch
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
- name: Invoke Oclif workflow for draft release
if: ${{needs.release.outputs.draft-tag-name != '' && github.event.inputs.draft-release == 'true'}}
run: node .github/scripts/trigger-workflow.js
env:
WORKFLOW_NAME: 'oclif-release.yml'
REPO_NAME: twilio/twilio-cli
REPO_ACCESS_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}
BRANCH_NAME: ${{steps.extract_branch.outputs.branch}}
INPUTS: '{ "home-brew-branch": "${{github.event.inputs.homebrew-branch}}", "tag-name": "${{needs.release.outputs.draft-tag-name}}", "formula": "twiliodraft", "pre-release": "${{github.event.inputs.homebrew-prerelease}}"}'
# oclif-draft-test:
# runs-on: ubuntu-latest
# needs: [oclif-release]
# steps:
# - name: Extract branch name
# id: extract_branch
# run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
# - name: Wait for draft release to succeed
# uses: lewagon/[email protected]
# with:
# ref: ${{steps.extract_branch.outputs.branch}}
# check-name: 'Oclif Release'
# repo-token: ${{ secrets.GITHUB_TOKEN }}
# wait-interval: 10
# - name: Run testing on release-draft
# if: ${{ github.event.inputs.draft-release == 'true' }}
# run: node .github/scripts/trigger-workflow.js
# env:
# WORKFLOW_NAME: '.github/workflows/cli-test-homebrew.yml'
# REPO_NAME: twilio/twilio-cli
# REPO_ACCESS_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}
# BRANCH_NAME: ${{steps.extract_branch.outputs.branch}}
# INPUTS: '{ "version": "${{ steps.semantic-release-draft.outputs.TAG_NAME }}" }'
docker-release:
runs-on: ubuntu-latest
needs: [ release ]
steps:
- name: Checkout cli repo
uses: actions/checkout@v2
- run: |
git pull
make install
- name: Extract branch name
id: extract_branch
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
- name: Invoke Docker workflow
if: ${{needs.release.outputs.tag-name != ''}}
run: node .github/scripts/trigger-workflow.js
env:
WORKFLOW_NAME: 'docker-release.yml'
REPO_NAME: twilio/twilio-cli
REPO_ACCESS_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}
BRANCH_NAME: ${{steps.extract_branch.outputs.branch}}
platform-executables-release:
runs-on: ubuntu-latest
needs: [ release ]
env:
REPO_NAME: twilio/twilio-cli
REPO_ACCESS_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}
strategy:
matrix:
executable_workflow: [ 'debian-executable-release.yml', 'macos-executable-release.yml', 'rpmbuild.yml', 'windows-executable-release.yml', 'apt-release.yml' ]
steps:
- name: Checkout cli repo
uses: actions/checkout@v2
- run: |
git pull
make install
- name: Extract branch name
id: extract_branch
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
- name: Invoke platform executable workflow
if: ${{needs.release.outputs.draft-tag-name != ''}}
run: node .github/scripts/trigger-workflow.js
env:
WORKFLOW_NAME: ${{ matrix.executable_workflow }}
BRANCH_NAME: ${{steps.extract_branch.outputs.branch}}
notify-complete-fail:
if: ${{ failure() || cancelled() }}
needs: [ release, oclif-release, platform-executables-release ]
name: Notify Release Failed
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Slack Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.ALERT_SLACK_WEB_HOOK }}
SLACK_COLOR: "#ff3333"
SLACK_USERNAME: CLI Draft Release Bot
SLACK_ICON_EMOJI: ":ship:"
SLACK_TITLE: "Twilio Cli - Draft Release"
SLACK_MESSAGE: 'CLI Draft Release workflow Failed'