diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 2d81704b137..d54963dfdd3 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -23,8 +23,8 @@ on: - cron: "0 16 * * *" permissions: - actions: read - contents: read + actions: write + contents: write jobs: cd: @@ -33,35 +33,11 @@ jobs: CI: true PREID: ${{ github.event.inputs.preid }} steps: - - name: Validate CD branch - if: ${{ github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/dev' && !startsWith(github.ref, 'refs/heads/release/') }} - run: | - echo It's allowed to run CD on dev or release branch. - exit 1 - - - name: Validate inputs for release - if: ${{ github.event_name == 'workflow_dispatch' && startsWith(github.ref, 'refs/heads/release/') && github.event.inputs.preid == 'alpha' }} - run: | - echo It's not allowed to run CD on release branch for alpha. - exit 1 - - - name: Valiadte inputs for dev - if: ${{ github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/dev' && github.event.inputs.preid != 'alpha' }} - run: | - echo It's only allowed to alpha on dev branch. - exit 1 - - - name: Validate schedule - if: ${{ github.event_name == 'schedule' && github.ref != 'refs/heads/dev' }} - run: | - echo It's not allowed to run schedule release except dev branch. - exit 1 - - name: Checkout branch uses: actions/checkout@v3 with: fetch-depth: 0 - token: ${{ secrets.CD_PAT }} + token: ${{ secrets.GITHUB_TOKEN }} ref: ${{ github.ref }} - uses: actions/setup-node@v3 @@ -100,7 +76,7 @@ jobs: - name: release beta packages to npmjs.org if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.preid == 'beta' }} run: | - npx lerna version prerelease --preid=beta.$(date "+%Y%m%d%H") --exact --no-push --allow-branch ${GITHUB_REF#refs/*/} --yes + npx lerna version prerelease --preid=beta.$(date "+%Y%m%d%H") --exact --allow-branch ${GITHUB_REF#refs/*/} --yes - name: version rc npm packages to npmjs.org if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.preid == 'rc' && github.event.inputs.skip-version-rc == 'no'}} @@ -122,19 +98,17 @@ jobs: - name: update template rc tag uses: richardsimko/update-tag@v1.0.7 - if: ${{ (contains(steps.version-change.outputs.CHANGED, 'templates@') || contains(steps.version-change.outputs.CHANGED, '@microsoft/teamsfx')) && github.event_name == 'workflow_dispatch' && github.event.inputs.preid == 'rc' }} with: - tag_name: "templates@0.0.0-rc" + tag_name: "templates@8.8.8-beta" env: - GITHUB_TOKEN: ${{ secrets.CD_PAT }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: release templates' RC version to github - if: ${{ (contains(steps.version-change.outputs.CHANGED, 'templates@') || contains(steps.version-change.outputs.CHANGED, '@microsoft/teamsfx')) && github.event_name == 'workflow_dispatch' && github.event.inputs.preid == 'rc' }} uses: ncipollo/release-action@v1.10.0 with: - token: ${{ secrets.CD_PAT }} + token: ${{ secrets.GITHUB_TOKEN }} prerelease: true - tag: "templates@0.0.0-rc" + tag: "templates@8.8.8-beta" artifacts: ${{ github.workspace }}/templates/build/*.zip allowUpdates: true removeArtifacts: true @@ -145,7 +119,7 @@ jobs: with: artifacts: ${{ github.workspace }}/templates/build/*.zip name: "Release for ${{ steps.version-change.outputs.TEMPLATE_VERSION }}" - token: ${{ secrets.CD_PAT }} + token: ${{ secrets.GITHUB_TOKEN }} tag: ${{ steps.version-change.outputs.TEMPLATE_VERSION }} allowUpdates: true @@ -160,7 +134,7 @@ jobs: artifacts: ${{ runner.temp }}/template-tags.txt name: "Template Tag List" body: "Release to maintain template tag list." - token: ${{ secrets.CD_PAT }} + token: ${{ secrets.GITHUB_TOKEN }} tag: "template-tag-list" allowUpdates: true @@ -265,7 +239,6 @@ jobs: [ -d ./packages/server/lib ] && find ./packages/server/lib -type f -name '*.exe' -exec mv {} server.exe \; - name: pack vsix - if: ${{ contains(steps.version-change.outputs.CHANGED, 'ms-teams-vscode-extension@') }} env: NODE_OPTIONS: "--max_old_space_size=4096" uses: nick-invision/retry@v2 @@ -284,31 +257,10 @@ jobs: fi - name: release stable VSCode extension to github - if: ${{ contains(steps.version-change.outputs.CHANGED, 'ms-teams-vscode-extension@') && github.event_name == 'workflow_dispatch' && github.event.inputs.preid == 'stable' }} uses: ncipollo/release-action@v1.10.0 with: - token: ${{ secrets.CD_PAT }} + token: ${{ secrets.GITHUB_TOKEN }} tag: ${{ steps.version-change.outputs.EXTENSION_VERSION }} artifacts: ./packages/**/*.vsix artifactErrorsFailBuild: true bodyFile: ./CHANGELOG.md - - - name: save release info - run: | - rm -f changed.txt - rm -f versions.json - echo ${{steps.version-change.outputs.CHANGED}} > changed.txt - npx lerna ls -all --json > versions.json - echo ${{ inputs.series }} > series.txt - find ./packages/vscode-extension -type f -name '*.vsix' -exec mv {} . \; - - - name: upload release info to artifact - uses: actions/upload-artifact@v3 - with: - name: release - path: | - changed.txt - series.txt - versions.json - *.vsix - *.exe