Skip to content

Commit

Permalink
Changes to enable a draft release for npm and homebrew
Browse files Browse the repository at this point in the history
  • Loading branch information
shrutiburman committed Nov 17, 2021
1 parent 14f7cb3 commit 733c0fb
Show file tree
Hide file tree
Showing 5 changed files with 22,861 additions and 4,044 deletions.
13 changes: 13 additions & 0 deletions .github/scripts/revert-commit-draft-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh
echo "Running revert last commit script"
echo $1
echo "Last commit to revert :"
echo $(git rev-parse --verify HEAD)
echo "Git configurations :"
git config --global user.email "team_interfaces+github@twilio.com"
git config --global user.name "twilio-dx"
git revert $(git rev-parse --verify HEAD)
git push origin refs/heads/$1:refs/heads/$1



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 install -g twilio-cli@${{ github.event.inputs.version }}
node src/asserts/validate_tests.js
- name: Global - Testing upgrade Twilio CLI (2)
run: |
npm install -g twilio-cli@${{ github.event.inputs.version }}
npm install -g twilio-cli
node src/asserts/validate_tests.js
- name: Local - Testing installation of Twilio CLI (1)
run: |
npm install twilio-cli
node src/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 src/asserts/validate_tests.js
61 changes: 58 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Cli Release
name: CLI Release
on:
workflow_dispatch:
inputs:
Expand All @@ -12,6 +12,9 @@ on:
homebrew-prerelease:
description: 'HomeBrew prerelease'
default: 'false'
draft-release:
description: 'Set to true to do a draft release for sanity testing'
default: 'false'

jobs:
test:
Expand Down Expand Up @@ -55,12 +58,31 @@ jobs:
run: |
git pull
npm install
- name: Semantic Release runs for draft release
if: ${{github.event.inputs.draft-release == 'true'}}
run: npx semantic-release -t \${version}-draft
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' }}
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": "${version}-draft" }'
- name: Update release
if: ${{steps.semantic-release.outputs.TAG_NAME != ''}}
run: node .github/scripts/update-release.js
Expand All @@ -69,9 +91,32 @@ 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'}}
runs-on: ubuntu-latest
needs: [release]
steps:
- name: Delete draft release
uses: dev-drprasad/delete-tag-and-release@v0.2.0
with:
delete_release: true
tag_name: \${version}-draft
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 }}"
oclif-release:
runs-on: ubuntu-latest
needs: [ release ]
needs: [release]
steps:
- name: Checkout cli repo
uses: actions/checkout@v2
Expand All @@ -82,14 +127,23 @@ 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.tag-name}}-draft", "pre-release": "${{github.event.inputs.homebrew-prerelease}}"}'
docker-release:
runs-on: ubuntu-latest
needs: [ release ]
Expand All @@ -111,6 +165,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
Loading

0 comments on commit 733c0fb

Please sign in to comment.