Skip to content

Commit

Permalink
feat: Enable a draft release for npm and homebrew for sanity testing (t…
Browse files Browse the repository at this point in the history
  • Loading branch information
shrutiburman committed Nov 24, 2021
1 parent 7b9abb1 commit 9899fdf
Show file tree
Hide file tree
Showing 8 changed files with 22,944 additions and 4,044 deletions.
24 changes: 24 additions & 0 deletions .github/scripts/revert-commit-draft-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh
echo "Running revert last commit script"
branch="$1"
echo "Git configurations :"
git config --global user.email "team_interfaces+github@twilio.com"
git config --global user.name "twilio-dx"
echo $branch
nCommit=$(git rev-parse --verify HEAD)
nCommitAuthor=$(git log -n 1 --pretty=format:'%an' $nCommit)
if [[ $nCommitAuthor == *"semantic-release-bot"* ]]; then
echo "Reverting commit by semantic release bot:"
echo $(git rev-parse --verify HEAD)
git revert $(git rev-parse --verify HEAD)
git push origin refs/heads/$1:refs/heads/$1
fi
nCommit=$(git rev-parse --verify HEAD)
nCommitAuthor=$(git log -n 1 --pretty=format:'%an' $nCommit)
if [[ $nCommitAuthor == *"twilio-dx"* ]]; then
echo "Reverting commit for oai spec:"
echo $(git rev-parse --verify HEAD)
git revert $(git rev-parse --verify HEAD)
git push origin refs/heads/$1:refs/heads/$1
fi

29 changes: 29 additions & 0 deletions .github/workflows/cli-test-homebrew.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CLI Tests on brew installations
on:
workflow_dispatch:
inputs:
version:
description: 'Version to use for running test cases'
required: true

jobs:
test:
runs-on: macos-latest
strategy:
matrix:
node-version: [16.x, 14.x, 10.x]
steps:
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Global - Testing installation of Twilio CLI (1)
run: |
brew tap twilio/brew && brew install twilio@${{ github.event.inputs.version }}
node test/asserts/validate_tests.js
- name: Global - Testing upgrade Twilio CLI (2)
run: |
brew tap twilio/brew && brew install twilio@${{ github.event.inputs.version }}
brew upgrade twilio
node test/asserts/validate_tests.js
38 changes: 38 additions & 0 deletions .github/workflows/cli-test-npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: CLI Tests on npm installations
on:
workflow_dispatch:
inputs:
version:
description: 'Version to use for running test cases'
required: true

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x, 14.x, 10.x]
steps:
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Global - Testing installation of Twilio CLI (1)
run: |
npm make install -g twilio-cli@${{ github.event.inputs.version }}
node test/asserts/validate_tests.js
- name: Global - Testing upgrade Twilio CLI (2)
run: |
npm make install -g twilio-cli@${{ github.event.inputs.version }}
npm install -g twilio-cli
node test/asserts/validate_tests.js
- name: Local - Testing installation of Twilio CLI (1)
run: |
npm install twilio-cli
node test/asserts/validate_tests.js
- name: Local - Testing upgrade Twilio CLI (2)
run: |
npm install twilio-cli@${{ github.event.inputs.version }}
npm install twilio-cli
node test/asserts/validate_tests.js
29 changes: 29 additions & 0 deletions .github/workflows/delete-draft-tag-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Delete draft tagged release
on:
workflow_dispatch:
inputs:
tag-name:
description: 'Tag name to delete'

jobs:
delete-draft-release:
runs-on: ubuntu-latest
steps:
- name: Delete draft release oclif
uses: dev-drprasad/delete-tag-and-release@v0.2.0
with:
delete_release: true
tag_name: ${{github.event.inputs.tag-name}}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Extract branch name
id: extract_branch
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ steps.extract_branch.outputs.branch }}
fetch-depth: 0
- name: Undo Push
run: |
bash .github/scripts/revert-commit-draft-release.sh "${{ steps.extract_branch.outputs.branch }}"
91 changes: 88 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ on:
homebrew-prerelease:
description: 'HomeBrew prerelease'
default: 'false'
draft-release:
description: 'Draft-release flag (true/false)'
default: 'false'

jobs:
test:
Expand Down Expand Up @@ -45,7 +48,8 @@ jobs:
runs-on: ubuntu-latest
needs: [update-api-definitions-changelog]
outputs:
tag-name: ${{ steps.semantic-release.outputs.TAG_NAME }}
tag-name: ${{ steps.semantic-release-draft.outputs.TAG_NAME }}
draft-tag-name: ${{ steps.semantic-release-draft.outputs.TAG_NAME }}
steps:
- name: Checkout cli
uses: actions/checkout@v2
Expand All @@ -55,12 +59,32 @@ jobs:
run: |
git pull
make install
- name: Semantic Release runs for draft release
if: ${{github.event.inputs.draft-release == 'true'}}
id: semantic-release-draft
run: npx semantic-release -t \${version}
env:
GITHUB_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Semantic Release runs
if: ${{github.event.inputs.draft-release != 'true'}}
id: semantic-release
run: npx 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 sanity testing for on 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: Update release
if: ${{steps.semantic-release.outputs.TAG_NAME != ''}}
run: node .github/scripts/update-release.js
Expand All @@ -69,9 +93,23 @@ jobs:
TAG_NAME: ${{steps.semantic-release.outputs.TAG_NAME}}
RELEASE_BODY: ${{github.event.inputs.change-log}}
REPO_NAME: twilio/twilio-cli
delete-draft-release:
if: ${{github.event.inputs.draft-release == 'true' && needs.release.outputs.draft-tag-name != ''}}
runs-on: ubuntu-latest
needs: [release]
steps:
- name: Delete draft release
if: ${{github.event.inputs.draft-release == 'true'}}
run: node .github/scripts/trigger-workflow.js
env:
WORKFLOW_NAME: '.github/workflows/delete-draft-tag-release.yml'
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 ]
needs: [release]
steps:
- name: Checkout cli repo
uses: actions/checkout@v2
Expand All @@ -82,14 +120,60 @@ jobs:
id: extract_branch
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
- name: Invoke Oclif workflow
if: ${{needs.release.outputs.tag-name != ''}}
if: ${{needs.release.outputs.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.tag-name}}", "pre-release": "${{github.event.inputs.homebrew-prerelease}}"}'
- name: Invoke Oclif workflow for draft release
if: ${{needs.release.outputs.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}}-draft", "pre-release": "${{github.event.inputs.homebrew-prerelease}}"}'
oclif-draft-sanity-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/wait-on-check-action@v1.0.0
with:
ref: ${{steps.extract_branch.outputs.branch}}
check-name: 'Oclif Release'
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 10
- name: Run sanity 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 }}" }'
delete-draft-release-oclif:
runs-on: ubuntu-latest
needs: [oclif-release]
steps:
- name: Delete draft release
if: ${{github.event.inputs.draft-release == 'true'}}
run: node .github/scripts/trigger-workflow.js
env:
WORKFLOW_NAME: '.github/workflows/delete-draft-tag-release.yml'
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}}" }'

docker-release:
runs-on: ubuntu-latest
needs: [ release ]
Expand All @@ -111,6 +195,7 @@ jobs:
REPO_ACCESS_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}
BRANCH_NAME: ${{steps.extract_branch.outputs.branch}}
platform-executables-release:
if: ${{github.event.inputs.draft-release != 'true'}}
runs-on: ubuntu-latest
needs: [ release ]
steps:
Expand Down
4 changes: 4 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
{
"name": "release_feature_branch",
"prerelease": "rc"
},
{
"name": "main",
"prerelease": "draft"
}
],
"plugins": [
Expand Down
Loading

0 comments on commit 9899fdf

Please sign in to comment.