Skip to content

CD

CD #84

Workflow file for this run

name: CD
on:
workflow_dispatch:
inputs:
preid:
description: "preid name(alpha, prerelease, rc, stable)"
required: true
default: "rc"
skip-version-rc:
description: "release RC version just with lerna publish, skip run lerna version(yes or no)"
required: false
default: "no"
pkgs:
type: string
required: false
description: "Please enter the package names you want to publish, such as cli, vscode, sdk, server and template. Please separate multiple entries with spaces"
schedule:
- cron: "0 0 * * *"
jobs:
cd:
runs-on: ubuntu-latest
steps:
- name: Validate CD branch
if: ${{ github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/heads/hotfix/') && github.ref != 'refs/heads/dev' && github.ref != 'refs/heads/prerelease' }}
run: |
echo It's not allowed to run CD on other branch except main, dev and prerelease.
exit 1
- name: Validate inputs for main or hotfix
if: ${{ github.event_name == 'workflow_dispatch' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/hotfix/')) && github.event.inputs.preid != 'rc' && github.event.inputs.preid != 'stable' }}
run: |
echo It's only allowed to release RC and stable on main branch.
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 }}
ref: ${{ github.ref }}
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 14
- name: Install wine64
run: |
sudo apt update
sudo apt install wine64 -y
- name: Setup npm registry
run: |
echo "${{ secrets.NPMRC }}" > ~/.npmrc
- name: manage pkgs to release
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.pkgs }}
run: bash .github/scripts/lerna.sh ${{github.event.inputs.pkgs}}
- name: Setup project
run: |
npm run setup
env:
REQUEST_TOKEN: ${{ secrets.CD_PAT }}
- name: Setup git
run: |
git config --global user.name 'MSFT-yiz'
git config --global user.email '[email protected]'
- name: release alpha npm packages to npmjs.org
if: ${{ github.ref == 'refs/heads/dev' }}
run: |
npx lerna version prerelease --preid=alpha.$(git rev-parse --short HEAD) --exact --no-push --allow-branch dev --yes
- name: release beta packages to npmjs.org
if: ${{ github.ref == 'refs/heads/prerelease' }}
run: |
npx lerna version prerelease --preid=beta.$(date "+%Y%m%d%H") --exact --no-push --allow-branch prerelease --yes
- name: version rc npm packages to npmjs.org
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.preid == 'rc' && github.ref == 'refs/heads/main' && github.event.inputs.skip-version-rc == 'no'}}
run: |
npx lerna version --conventional-commits --conventional-prerelease --preid=rc --no-changelog --yes
- name: version rc npm packages to npmjs.org on hotfix
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.preid == 'rc' && startsWith(github.ref, 'refs/heads/hotfix/') && github.event.inputs.skip-version-rc == 'no'}}
run: |
npx lerna version --conventional-commits --conventional-prerelease --preid=rc-hotfix --no-changelog --allow-branch ${GITHUB_REF#refs/*/} --yes
- name: version stable npm packages to npmjs.org
if: ${{ github.event_name == 'workflow_dispatch' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/hotfix/')) && github.event.inputs.preid == 'stable' }}
run: |
npx lerna version --conventional-commits --conventional-graduate --no-changelog --allow-branch ${GITHUB_REF#refs/*/} --yes
- name: version change
id: version-change
run: |
echo "CHANGED=$(git tag --points-at HEAD | xargs)" >> $GITHUB_OUTPUT
echo "TEMPLATE_VERSION=$(git tag --points-at HEAD | grep templates)" >> $GITHUB_OUTPUT
echo "EXTENSION_VERSION_NUM=$(git tag --points-at HEAD | grep ms-teams-vscode-extension@ | cut -d '@' -f2)" >> $GITHUB_OUTPUT
echo "EXTENSION_VERSION=$(git tag --points-at HEAD | grep ms-teams-vscode-extension@)" >> $GITHUB_OUTPUT
echo "SERVER_VERSION_NUM=$(git tag --points-at HEAD | grep @microsoft/teamsfx-server@ | cut -d '@' -f3)" >> $GITHUB_OUTPUT
echo "SERVER_VERSION=$(git tag --points-at HEAD| grep @microsoft/teamsfx-server@)" >> $GITHUB_OUTPUT
echo "SIMPLEAUTH_VERSION=$(git tag --points-at HEAD | grep simpleauth)" >> $GITHUB_OUTPUT
echo "SIMPLEAUTH_VERSION_NUM=$(git tag --points-at HEAD| grep simpleauth| cut -d '@' -f2)" >> $GITHUB_OUTPUT
if git tag --points-at HEAD | grep templates | grep rc;
then
git push -d origin $(git tag --points-at HEAD | grep templates | grep rc)
fi
- name: generate templates v3
run: |
.github/scripts/template-zip-autogen-v3.sh ${{ runner.temp }}/teamsfx_templates_v3
- name: update templates prerelease tag
uses: richardsimko/update-tag@v1
if: ${{ contains(steps.version-change.outputs.CHANGED, 'templates@') && github.ref == 'refs/heads/prerelease' }}
with:
tag_name: "templates-0.0.0-prerelease"
env:
GITHUB_TOKEN: ${{ secrets.CD_PAT }}
- name: release templates' prerelease version to github
if: ${{ contains(steps.version-change.outputs.CHANGED, 'templates@') && github.ref == 'refs/heads/prerelease' }}
uses: ncipollo/[email protected]
with:
token: ${{ secrets.CD_PAT }}
prerelease: true
tag: "templates-0.0.0-prerelease"
artifacts: ${{ runner.temp }}/teamsfx_templates_v3/*.zip
allowUpdates: true
removeArtifacts: true
- name: update template rc tag
uses: richardsimko/update-tag@v1
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: "[email protected]"
env:
GITHUB_TOKEN: ${{ secrets.CD_PAT }}
- 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/[email protected]
with:
token: ${{ secrets.CD_PAT }}
prerelease: true
tag: "[email protected]"
artifacts: ${{ runner.temp }}/teamsfx_templates_v3/*.zip
allowUpdates: true
removeArtifacts: true
- name: Create Templates Stable Release
if: ${{ contains(steps.version-change.outputs.CHANGED, 'templates@') && github.event_name == 'workflow_dispatch' && github.event.inputs.preid == 'stable' }}
uses: ncipollo/[email protected]
with:
artifacts: ${{ runner.temp }}/teamsfx_templates_v3/*.zip
name: "Release for ${{ steps.version-change.outputs.TEMPLATE_VERSION }}"
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.version-change.outputs.TEMPLATE_VERSION }}
allowUpdates: true
- name: Generate Tag List
if: ${{ contains(steps.version-change.outputs.CHANGED, 'templates@') && github.event_name == 'workflow_dispatch' && github.event.inputs.preid == 'stable' }}
run: git tag | grep templates > ${{ runner.temp }}/template-tags.txt
- name: Update Template Tag list Release
if: ${{ contains(steps.version-change.outputs.CHANGED, 'templates@') && github.event_name == 'workflow_dispatch' && github.event.inputs.preid == 'stable' }}
uses: ncipollo/[email protected]
with:
artifacts: ${{ runner.temp }}/template-tags.txt
name: "Template Tag List"
body: "Release to maintain template tag list."
token: ${{ secrets.github_token }}
tag: "template-tag-list"
allowUpdates: true
- name: download simpleauth to fx-core
uses: nick-invision/retry@v2
with:
timeout_minutes: 10
max_attempts: 10
retry_on: error
command: |
bash ./.github/scripts/download-simpleauth.sh
- name: replace sideloading placeholders
run: bash .github/scripts/sideloading-replace.sh
env:
SIDELOADING_SERVICE_ENDPOINT: ${{ secrets.SIDELOADING_SERVICE_ENDPOINT }}
SIDELOADING_SERVICE_SCOPE: ${{ secrets.SIDELOADING_SERVICE_SCOPE }}
- name: commit change on local
run: |
git add packages/fx-core/src/common/m365/serviceConstant.ts
git commit -m "chore: replace sideloading placeholders"
- name: update cli ai key
if: ${{ github.event_name == 'workflow_dispatch' && ( github.ref == 'refs/heads/main' || github.ref == 'refs/heads/prerelease' ) }}
uses: jossef/action-set-json-field@v1
with:
file: ./packages/cli/package.json
field: aiKey
value: ${{ secrets.CLI_PUBLIC_AIKEY }}
- name: update extension ai key
if: ${{ github.event_name == 'workflow_dispatch' && ( github.ref == 'refs/heads/main' || github.ref == 'refs/heads/prerelease' ) }}
uses: jossef/action-set-json-field@v1
with:
file: ./packages/vscode-extension/package.json
field: aiKey
value: ${{ secrets.EXT_PUBLIC_AIKEY }}
- name: commit change on local
if: ${{ github.event_name == 'workflow_dispatch' && ( github.ref == 'refs/heads/main' || github.ref == 'refs/heads/prerelease' ) }}
run: |
git add ./packages/cli/package.json ./packages/vscode-extension/package.json
git commit -m "chore: update ai key"
- name: publish alpha release to npm org
if: ${{ github.ref == 'refs/heads/dev'}}
run: |
npx lerna publish from-package --dist-tag=alpha --yes --allow-branch dev
env:
TEMPLATE_PATH: ${{ runner.temp }}/teamsfx_templates_v3
- name: publish beta release to npm org
if: ${{ github.ref == 'refs/heads/prerelease' }}
run: |
npx lerna publish from-package --dist-tag=beta --yes --allow-branch prerelease
env:
TEMPLATE_PATH: ${{ runner.temp }}/teamsfx_templates_v3
- name: publish rc npm packages to npmjs.org
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.preid == 'rc' }}
run: |
npx lerna publish from-package --dist-tag=rc --yes
env:
TEMPLATE_PATH: ${{ runner.temp }}/teamsfx_templates_v3
- name: publish stable npm packages to npmjs.org
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.preid == 'stable' }}
run: |
npx lerna publish from-package --yes
env:
TEMPLATE_PATH: ${{ runner.temp }}/teamsfx_templates_v3
- name: pack server bits
if: ${{ contains(steps.version-change.outputs.CHANGED, '@microsoft/teamsfx-server') }}
uses: nick-invision/retry@v2
with:
timeout_minutes: 10
max_attempts: 10
retry_on: error
command: |
sleep 20
cd ./packages/server
npm run package
- name: pack vsix
if: ${{ contains(steps.version-change.outputs.CHANGED, 'ms-teams-vscode-extension@') && github.ref != 'refs/heads/prerelease' }}
env:
NODE_OPTIONS: "--max_old_space_size=4096"
uses: nick-invision/retry@v2
with:
timeout_minutes: 10
max_attempts: 10
retry_on: error
command: |
sleep 20
cd ./packages/vscode-extension
npm install --only=production
npx vsce package
- 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/[email protected]
with:
token: ${{ secrets.CD_PAT }}
tag: ${{ steps.version-change.outputs.EXTENSION_VERSION }}
artifacts: ./packages/**/*.vsix
artifactErrorsFailBuild: true
bodyFile: ./CHANGELOG.md
- name: Calculate Version Num
id: preview-version
working-directory: packages/vscode-extension
run: |
DATE_WITH_TIME=`date "+%Y%m%d%H"`
PRERELEASE_VERSION=4.99
TTK_VERSION=$PRERELEASE_VERSION.$DATE_WITH_TIME
echo "version=$TTK_VERSION" >> $GITHUB_OUTPUT
echo $TTK_VERSION
- name: set vsc version for prerelease
if: ${{ contains(steps.version-change.outputs.CHANGED, 'ms-teams-vscode-extension@') && github.ref == 'refs/heads/prerelease' }}
uses: jossef/action-set-json-field@v1
with:
file: ./packages/vscode-extension/package.json
field: version
value: ${{ steps.preview-version.outputs.version }}
- name: pack vsix for preview
if: ${{ contains(steps.version-change.outputs.CHANGED, 'ms-teams-vscode-extension@') && github.ref == 'refs/heads/prerelease' }}
env:
RELEASE: preview
NODE_OPTIONS: "--max_old_space_size=4096"
uses: nick-invision/retry@v2
with:
timeout_minutes: 10
max_attempts: 10
retry_on: error
command: |
sleep 20
cd ./packages/vscode-extension
touch test.vsix
rm *.vsix
npm install --only=production
npx vsce package --pre-release ${{ steps.preview-version.outputs.version }}
- 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
mv ./packages/vscode-extension/*.vsix .
mv ./packages/server/lib/*.exe server.exe
- name: upload release info to artifact
uses: actions/upload-artifact@v3
with:
name: release
path: |
changed.txt
versions.json
*.vsix
*.exe