Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: use github token replace the CD path token since cd pat retire #13085

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 11 additions & 59 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ on:
- cron: "0 16 * * *"

permissions:
actions: read
contents: read
actions: write
contents: write

jobs:
cd:
Expand All @@ -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
Expand Down Expand Up @@ -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'}}
Expand All @@ -122,19 +98,17 @@ jobs:

- name: update template rc tag
uses: richardsimko/[email protected]
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/[email protected]
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
Expand All @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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/[email protected]
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
Loading