Skip to content

Commit

Permalink
feat: oclif v2 migration (twilio#466)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: upgrade to oclif v2
  • Loading branch information
shrutiburman committed Sep 14, 2022
1 parent df00986 commit a9d57dc
Show file tree
Hide file tree
Showing 30 changed files with 6,415 additions and 1,646 deletions.
3 changes: 2 additions & 1 deletion .github/actions/build-rpm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"devDependencies": {
"@types/node": "^16.4.10",
"@vercel/ncc": "^0.25.1",
"typescript": "^4.0.5"
"typescript": "^4.0.5",
"oclif": "^3"
}
}
4 changes: 2 additions & 2 deletions .github/scripts/pack_macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ pack_macos() {
# if [ "$REPOSITORY_OWNER" == "twilio" ]
# then
import_certificate
npx oclif-dev pack:macos
npx oclif pack:macos
notarize_and_staple
# else
# npx oclif-dev pack:macos
# npx oclif pack:macos
# fi
}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/debian-draft-executable-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
echo "::set-output name=TAG_NAME::$(git describe --tags $(git rev-list --tags --max-count=1))"
- run: |
make install
sudo $(npm bin)/oclif-dev pack:deb
sudo $(npm bin)/oclif pack:deb
cd dist/deb
sudo mv ${{ github.event.inputs.formula }}_$(awk -F- '{print $1}' <<< ${{ steps.get-tag.outputs.TAG_NAME }})-1_amd64.deb ${{ github.event.inputs.formula }}_${{ steps.get-tag.outputs.TAG_NAME }}-1_amd64.deb
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/debian-executable-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,27 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Getting last sha
id: get-sha
run: echo "::set-output name=SHA_SHORT::$(git rev-parse --short HEAD)"
- name: Getting latest tag
id: get-tag
run: |
git fetch --prune --unshallow
echo "::set-output name=TAG_NAME::$(git describe --tags $(git rev-list --tags --max-count=1))"
- run: |
make install
sudo $(npm bin)/oclif-dev pack:deb
sudo chown -R 1001:121 "/root/.npm"
sudo $(npm bin)/oclif pack:deb
- name: Upload binaries to release
run: node .github/scripts/update-platform-executables.js
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FILE: dist/deb/${{ github.event.inputs.formula }}_${{ steps.get-tag.outputs.TAG_NAME }}-1_amd64.deb
FILE: dist/deb/${{ github.event.inputs.formula }}_${{ steps.get-tag.outputs.TAG_NAME }}.${{ steps.get-sha.outputs.SHA_SHORT }}-1_amd64.deb
ASSET_NAME: ${{ github.event.inputs.formula }}-${{ steps.get-tag.outputs.TAG_NAME }}.deb
TAG_NAME: ${{ steps.get-tag.outputs.TAG_NAME }}
REPO_NAME: ${{ github.repository }}

notify-complete-fail:
if: ${{ failure() || cancelled() }}
needs: [ debian-executable-release ]
Expand All @@ -44,4 +48,4 @@ jobs:
SLACK_ICON_EMOJI: ":ship:"
SLACK_TITLE: "Twilio Cli"
SLACK_MESSAGE: 'Debian Executable Release Failed'
MSG_MINIMAL: actions url
MSG_MINIMAL: actions url
32 changes: 27 additions & 5 deletions .github/workflows/macos-executable-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,19 @@ jobs:
run: |
git fetch --prune --unshallow
echo "::set-output name=TAG_NAME::$(git describe --tags $(git rev-list --tags --max-count=1))"
get-sha:
runs-on: macos-11
outputs:
SHA_SHORT: ${{steps.get-sha.outputs.SHA_SHORT}}
steps:
- uses: actions/checkout@v2
- name: Getting short sha
id: get-sha
run: |
git fetch --prune --unshallow
echo "::set-output name=SHA_SHORT::$(git rev-parse --short HEAD)"
pack-macos:
needs: [get-tag]
needs: [get-tag, get-sha]
runs-on: macos-11
steps:
- uses: actions/checkout@v2
Expand All @@ -29,17 +40,28 @@ jobs:
APPLE_ID: ${{ secrets.APPLE_ID}}
APPLE_ID_APP_PASSWORD: ${{ secrets.APPLE_ID_APP_PASSWORD}}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID}}
FILE_PATH: dist/macos/${{ github.event.inputs.formula }}-v${{ needs.get-tag.outputs.TAG_NAME }}.pkg
FILE_PATH: dist/macos/${{ github.event.inputs.formula }}-v${{ needs.get-tag.outputs.TAG_NAME }}-${{ needs.get-sha.outputs.SHA_SHORT }}.pkg
REPOSITORY_OWNER: ${{ github.repository_owner }}
- name: Upload binaries to release
- name: Upload binaries to release - arm64
if: always()
run: node .github/scripts/update-platform-executables.js
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FILE: dist/macos/${{ github.event.inputs.formula }}-v${{ needs.get-tag.outputs.TAG_NAME }}.pkg
ASSET_NAME: ${{ github.event.inputs.formula }}-${{ needs.get-tag.outputs.TAG_NAME }}.pkg
FILE: dist/macos/${{ github.event.inputs.formula }}-v${{ needs.get-tag.outputs.TAG_NAME }}-${{ needs.get-sha.outputs.SHA_SHORT }}-arm64.pkg
ASSET_NAME: ${{ github.event.inputs.formula }}-${{ needs.get-tag.outputs.TAG_NAME }}-arm64.pkg
TAG_NAME: ${{ needs.get-tag.outputs.TAG_NAME }}
REPO_NAME: ${{ github.repository }}
- name: Upload binaries to release - x64
if: always()
run: |
node .github/scripts/update-platform-executables.js
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FILE: dist/macos/${{ github.event.inputs.formula }}-v${{ needs.get-tag.outputs.TAG_NAME }}-${{ needs.get-sha.outputs.SHA_SHORT }}-x64.pkg
ASSET_NAME: ${{ github.event.inputs.formula }}-${{ needs.get-tag.outputs.TAG_NAME }}-x64.pkg
TAG_NAME: ${{ needs.get-tag.outputs.TAG_NAME }}
REPO_NAME: ${{ github.repository }}


notify-complete-fail:
if: ${{ failure() || cancelled() }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/oclif-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ jobs:
id: sha256
if: ${{matrix.publish == 'homebrew'}}
run: |
make clean
make install
npx oclif-dev publish
brew install coreutils
if [ "${{github.event.inputs.formula}}" == "twiliorc" ]; then
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/windows-executable-draft-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ jobs:
- run: |
make install
brew install makensis
npx oclif-dev pack:win
npx oclif pack:win
cd dist/win
sudo mv ${{env.FORMULA_NAME}}-v${{ needs.get-tag.outputs.TAG_NAME }}.${{ steps.get-sha.outputs.SHA_SHORT }}-x86.exe ${{env.FORMULA_NAME}}-v${{ needs.get-tag.outputs.TAG_NAME }}-x86.exe
- name: upload artifact
uses: actions/upload-artifact@v2
with:
Expand Down
19 changes: 14 additions & 5 deletions .github/workflows/windows-executable-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ env:
FORMULA_NAME: 'twilio'

jobs:
get-sha:
runs-on: macos-latest
outputs:
SHA_SHORT: ${{steps.get-sha.outputs.SHA_SHORT}}
steps:
- uses: actions/checkout@v2
- name: Getting latest sha
id: get-sha
run: echo "::set-output name=SHA_SHORT::$(git rev-parse --short HEAD)"
get-tag:
runs-on: macos-latest
outputs:
Expand All @@ -18,22 +27,22 @@ jobs:
echo "::set-output name=TAG_NAME::$(git describe --tags $(git rev-list --tags --max-count=1))"
pack-windows-release:
runs-on: macos-latest
needs: [get-tag]
needs: [get-tag, get-sha]
steps:
- uses: actions/checkout@v2
- run: |
make install
brew install makensis
npx oclif-dev pack:win
npx oclif pack:win
- name: upload artifact
uses: actions/upload-artifact@v2
with:
name: ${{env.FORMULA_NAME}}-${{ needs.get-tag.outputs.TAG_NAME }}.exe
path: dist/win/${{env.FORMULA_NAME}}-v${{ needs.get-tag.outputs.TAG_NAME }}-x86.exe
path: dist/win32/${{env.FORMULA_NAME}}-v${{ needs.get-tag.outputs.TAG_NAME }}-${{ needs.get-sha.outputs.SHA_SHORT }}-x86.exe
retention-days: 1

sign-windows-release:
needs: [pack-windows-release, get-tag]
needs: [pack-windows-release, get-tag, get-sha]
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -59,7 +68,7 @@ jobs:
run: node .github/scripts/update-platform-executables.js
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FILE: ${{steps.download.outputs.download-path}}\${{env.FORMULA_NAME}}-v${{ needs.get-tag.outputs.TAG_NAME }}-x86.exe
FILE: ${{steps.download.outputs.download-path}}\${{env.FORMULA_NAME}}-v${{ needs.get-tag.outputs.TAG_NAME }}-${{ needs.get-sha.outputs.SHA_SHORT }}-x86.exe
ASSET_NAME: ${{env.FORMULA_NAME}}-${{ needs.get-tag.outputs.TAG_NAME }}.exe
TAG_NAME: ${{ needs.get-tag.outputs.TAG_NAME }}
REPO_NAME: ${{ github.repository }}
Expand Down
18 changes: 18 additions & 0 deletions bin/dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env node

const oclif = require('@oclif/core')

const path = require('path')
const project = path.join(__dirname, '..', 'tsconfig.json')

// In dev mode -> use ts-node and dev plugins
process.env.NODE_ENV = 'development'

require('ts-node').register({project})

// In dev mode, always show stack traces
oclif.settings.debug = true;
require('@twilio/cli-core').configureEnv();

// Start the CLI
oclif.run().then(oclif.flush).catch(oclif.Errors.handle)
3 changes: 3 additions & 0 deletions bin/dev.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off

node "%~dp0\dev" %*
9 changes: 3 additions & 6 deletions bin/run
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#!/usr/bin/env node
// Load up the command module *first* so that we're the parent rather than
// some other dependency.
const command = require('@oclif/command');

const oclif = require('@oclif/core')
require('@twilio/cli-core').configureEnv();
command.run()
.then(require('@oclif/command/flush'))
.catch(require('@oclif/errors/handle'));

oclif.run().then(require('@oclif/core/flush')).catch(require('@oclif/core/handle'))
Loading

0 comments on commit a9d57dc

Please sign in to comment.