-
Notifications
You must be signed in to change notification settings - Fork 32
194 lines (192 loc) · 7.22 KB
/
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
name: Cli-core Release
on:
workflow_dispatch:
inputs:
cli-branch:
description: 'Run cli workflow in the given branch'
default: main
homebrew-branch:
description: 'HomeBrew branch name'
default: main
homebrew-prerelease:
description: 'HomeBrew prerelease'
default: 'false'
jobs:
cli-core-token-validation:
runs-on: ubuntu-latest
steps:
- name: Checkout cli-core 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: Trigger CLI token validation workflow
run: |
fileName="$GITHUB_WORKSPACE/.github/scripts/trigger-workflow.js"
node -e "require('$fileName').triggerWorkflow()"
env:
WORKFLOW_NAME: '.github/workflows/release-token-validation.yml'
REPO_NAME: ${{ github.repository_owner }}/twilio-cli
REPO_ACCESS_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}
BRANCH_NAME: ${{steps.extract_branch.outputs.branch}}
- name: Validate REPO_ACCESS_TOKEN
uses: actions/checkout@v2
with:
repository: '${{ github.repository_owner }}/twilio-oai'
token: ${{ secrets.REPO_ACCESS_TOKEN }}
- name: Validate AWS tokens
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-session-token: ${{ secrets.AWS_SESSION_TOKEN }}
aws-region: us-east-1
cli-token-validation:
needs: [ cli-core-token-validation ]
runs-on: ubuntu-latest
steps:
- name: Checkout cli-core repo
uses: actions/checkout@v2
- name: Execute py script to validate twilio-cli tokens
id: cli_token
run: |
output=$(python3 .github/scripts/validate_cli_tokens.py)
echo "::set-output name=tokenStatus::$output"
- name: Print status
run: echo "${{ steps.cli_token.outputs.tokenStatus }}"
- name: Validate the github workflow
if: ${{ steps.cli_token.outputs.tokenStatus != 'success'}}
run: exit 1
# notify-start:
# needs: [ cli-token-validation ]
# name: Notify Release Started
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - name: Extract branch name
# id: extract_branch
# run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
# - name: Slack Notification
# if: ${{steps.extract_branch.outputs.branch == 'main' }}
# uses: rtCamp/action-slack-notify@v2
# env:
# SLACK_WEBHOOK: ${{ secrets.SLACK_WEB_HOOK }}
# SLACK_COLOR: "#36a64f"
# SLACK_USERNAME: CLI Release Bot
# SLACK_ICON_EMOJI: ":ship:"
# SLACK_TITLE: "Twilio Cli"
# SLACK_MESSAGE: 'Release Started :rocket:'
# MSG_MINIMAL: actions url
test:
needs: [ cli-token-validation ]
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x, 16.x, 18.x]
steps:
- name: Checkout cli-core 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: make test
update-api-specs:
runs-on: ubuntu-latest
needs: [ test ]
outputs:
change-log: ${{ steps.update-specs.outputs.change-log }}
version-type: ${{ steps.update-specs.outputs.version-type }}
steps:
- name: Create temporary folder for copying json files from OAI repo
run: mkdir -p ~/oai_definitions/json
- name: Checkout OAI repo
uses: actions/checkout@v2
with:
repository: '${{ github.repository_owner }}/twilio-oai'
token: ${{ secrets.REPO_ACCESS_TOKEN }}
- run: |
cp -R spec/json/. ~/oai_definitions/json/
cp -R CHANGES.md ~/oai_definitions/CHANGES.md
- name: Checkout cli-core repo
uses: actions/checkout@v2
with:
token: ${{ secrets.REPO_ACCESS_TOKEN }}
- name: Update OAI specs
id: update-specs
run: |
make install
cp -R ~/oai_definitions/CHANGES.md OAI_CHANGES.md
source .github/scripts/update-api-spec-with-changelog.sh
echo "::set-output name=change-log::$changeLog"
echo "::set-output name=version-type::$versionType"
release:
runs-on: ubuntu-latest
needs: [update-api-specs]
outputs:
tag-name: ${{ steps.semantic-release.outputs.TAG_NAME }}
steps:
- name: Checkout cli-core repo
uses: actions/checkout@v2
with:
persist-credentials: false
- run: |
git pull
make install
- name: semanticRelease
id: semantic-release
run: DEBUG=semantic-release:* npx semantic-release -t \${version}
env:
GITHUB_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Update release
run: |
fileName="$GITHUB_WORKSPACE/.github/scripts/update-release.js"
node -e "require('$fileName').updateRelease()"
env:
REPO_ACCESS_TOKEN: ${{ github.token }}
TAG_NAME: ${{ steps.semantic-release.outputs.TAG_NAME }}
RELEASE_BODY: ${{needs.update-api-specs.outputs.change-log}}
REPO_NAME: ${{ github.repository }}
triggerCliWorkflow:
runs-on: ubuntu-latest
needs: [ update-api-specs, release]
steps:
- name: Checkout cli-core repo
uses: actions/checkout@v2
- run: |
git pull
make install
- name: Invoke CLI workflow with changelog and version-type
run: |
fileName="$GITHUB_WORKSPACE/.github/scripts/trigger-workflow.js"
node -e "require('$fileName').triggerWorkflow()"
env:
REPO_ACCESS_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}
WORKFLOW_NAME: 'release.yml'
BRANCH_NAME: ${{github.event.inputs.cli-branch}}
REPO_NAME: ${{ github.repository_owner }}/twilio-cli
INPUTS: '{ "change-log": ${{ toJSON(needs.update-api-specs.outputs.change-log) }}, "version-type": "${{needs.update-api-specs.outputs.version-type}}", "homebrew-branch": "${{github.event.inputs.homebrew-branch}}", "homebrew-prerelease": "${{github.event.inputs.homebrew-prerelease}}" }'
# notify-complete-fail:
# if: ${{ (needs.cli-token-validation.result != 'failure' || needs.cli-core-token-validation.result != 'failure' ) && (failure() || cancelled()) }}
# needs: [ triggerCliWorkflow ]
# 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 Release Bot
# SLACK_ICON_EMOJI: ":ship:"
# SLACK_TITLE: "Twilio Cli-core"
# SLACK_MESSAGE: 'Release workflow Failed'
# MSG_MINIMAL: actions url