|
| 1 | +name: CD |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version: |
| 7 | + description: "which version to bump(major, minor, patch, premajor, preminor, prepatch, prerelease)" |
| 8 | + required: true |
| 9 | + default: "prerelease" |
| 10 | + preid: |
| 11 | + description: "preid name(alpha or rc)" |
| 12 | + required: false |
| 13 | + default: "alpha" |
| 14 | + force: |
| 15 | + description: "force release even if no update(set --force-publish if necessary)" |
| 16 | + required: false |
| 17 | + default: "" |
| 18 | + |
| 19 | +jobs: |
| 20 | + cd: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + |
| 23 | + steps: |
| 24 | + - name: Checkout dev branch |
| 25 | + if: ${{ github.event_name == 'schedule' }} |
| 26 | + uses: actions/checkout@v2 |
| 27 | + with: |
| 28 | + fetch-depth: 0 |
| 29 | + token: ${{ secrets.CD_PAT }} |
| 30 | + ref: dev |
| 31 | + |
| 32 | + - name: Checkout release branch |
| 33 | + if: ${{ github.event_name != 'schedule' }} |
| 34 | + uses: actions/checkout@v2 |
| 35 | + with: |
| 36 | + fetch-depth: 0 |
| 37 | + token: ${{ secrets.CD_PAT }} |
| 38 | + ref: ${{ github.ref }} |
| 39 | + |
| 40 | + - name: Setup node |
| 41 | + uses: actions/setup-node@v2.1.2 |
| 42 | + with: |
| 43 | + node-version: 14 |
| 44 | + |
| 45 | + - name: Setup npm registry |
| 46 | + run: | |
| 47 | + echo "${{ secrets.NPMRC }}" > ~/.npmrc |
| 48 | +
|
| 49 | + - name: generate templates |
| 50 | + run: .github/scripts/template-zip-autogen.sh |
| 51 | + |
| 52 | + - name: release templates' daily version to github |
| 53 | + if: ${{ github.ref == 'refs/heads/dev' && startsWith(github.event.inputs.version, 'pre') }} |
| 54 | + uses: marvinpinto/action-automatic-releases@latest |
| 55 | + with: |
| 56 | + repo_token: ${{ secrets.CD_PAT }} |
| 57 | + prerelease: true |
| 58 | + automatic_release_tag: "templates@0.0.0-alpha" |
| 59 | + files: | |
| 60 | + ./*.zip |
| 61 | +
|
| 62 | + - name: release templates' prerelease version to github |
| 63 | + if: ${{ startsWith(github.ref, 'refs/heads/release/') && github.event.inputs.version == 'prerelease' }} |
| 64 | + uses: marvinpinto/action-automatic-releases@latest |
| 65 | + with: |
| 66 | + repo_token: ${{ secrets.CD_PAT }} |
| 67 | + prerelease: true |
| 68 | + automatic_release_tag: "templates@0.0.0-rc" |
| 69 | + files: | |
| 70 | + ./*.zip |
| 71 | +
|
| 72 | + - name: cleanup templates |
| 73 | + run: rm -rf ./*.zip |
| 74 | + |
| 75 | + - name: Download Simple Auth bits |
| 76 | + uses: nick-invision/retry@v2 |
| 77 | + with: |
| 78 | + timeout_minutes: 10 |
| 79 | + max_attempts: 10 |
| 80 | + retry_on: error |
| 81 | + shell: pwsh |
| 82 | + command: | |
| 83 | + $version=Get-Content packages/fx-core/templates/plugins/resource/simpleauth/version.txt |
| 84 | + $tag = "simpleauth@"+$version |
| 85 | + $fileName="Microsoft.TeamsFx.SimpleAuth_$version.zip" |
| 86 | + $url = "https://github.com/OfficeDev/TeamsFx/releases/download/"+$tag+"/"+$fileName |
| 87 | + Invoke-WebRequest $url -OutFile packages/fx-core/templates/plugins/resource/simpleauth/SimpleAuth.zip |
| 88 | +
|
| 89 | + - name: Setup project |
| 90 | + run: | |
| 91 | + npm run setup |
| 92 | +
|
| 93 | + - name: Setup git |
| 94 | + run: | |
| 95 | + git config --global user.name 'MSFT-yiz' |
| 96 | + git config --global user.email 'yiz@microsoft.com' |
| 97 | +
|
| 98 | + - name: check whether vscode extension changed or not |
| 99 | + id: extension-checker |
| 100 | + run: | |
| 101 | + if npx lerna changed | grep 'ms-teams-vscode-extension'; |
| 102 | + then |
| 103 | + echo "::set-output name=CHANGED::true" |
| 104 | + else |
| 105 | + echo "::set-output name=CHANGED::false" |
| 106 | + fi |
| 107 | +
|
| 108 | + - name: release prerelease npm packages to npmjs.org |
| 109 | + if: ${{ github.ref == 'refs/heads/dev' && startsWith(github.event.inputs.version, 'pre') }} |
| 110 | + run: | |
| 111 | + npx lerna publish --no-private --preid=${{github.event.inputs.preid }} --dist-tag=${{github.event.inputs.preid }} ${{ github.event.inputs.version }} --yes ${{ github.event.inputs.force }} |
| 112 | +
|
| 113 | + - name: release stable npm packages to npmjs.org |
| 114 | + if: ${{ startsWith(github.ref, 'refs/heads/master') && !startsWith(github.event.inputs.version, 'pre') }} |
| 115 | + run: | |
| 116 | + npx lerna publish --no-private --dist-tag=latest ${{ github.event.inputs.version }} --yes ${{ github.event.inputs.force }} |
| 117 | +
|
| 118 | + - name: pack vsix |
| 119 | + id: pack-vsix |
| 120 | + uses: nick-invision/retry@v2 |
| 121 | + with: |
| 122 | + timeout_minutes: 10 |
| 123 | + max_attempts: 10 |
| 124 | + retry_on: error |
| 125 | + command: | |
| 126 | + sleep 5 |
| 127 | + cd ./packages/vscode-extension |
| 128 | + npm install |
| 129 | + npx vsce package |
| 130 | + VERSION=`ls *.vsix | awk -F '.vsix' '{print $1}'` |
| 131 | + echo "::set-output name=VERSION::$VERSION" |
| 132 | +
|
| 133 | + - name: release VSCode extension to github |
| 134 | + if: ${{ steps.extension-checker.outputs.CHANGED == 'true' || github.event.inputs.force == '--force-publish' }} |
| 135 | + uses: marvinpinto/action-automatic-releases@latest |
| 136 | + with: |
| 137 | + repo_token: ${{ secrets.CD_PAT }} |
| 138 | + prerelease: true |
| 139 | + automatic_release_tag: ${{ steps.pack-vsix.outputs.VERSION }} |
| 140 | + files: | |
| 141 | + ./packages/**/*.vsix |
0 commit comments