From 58cdb0fc835d6371fddc311a9f3183fc12c600b6 Mon Sep 17 00:00:00 2001 From: Kesava Krishnan Madavan Date: Mon, 28 Jul 2025 07:45:27 +0530 Subject: [PATCH 1/3] chore(tooling): add manual publish script --- .github/workflows/manual-deploy.yml | 317 ++++++++++++++++++++++++++++ 1 file changed, 317 insertions(+) create mode 100644 .github/workflows/manual-deploy.yml diff --git a/.github/workflows/manual-deploy.yml b/.github/workflows/manual-deploy.yml new file mode 100644 index 00000000000..b7a1ce88693 --- /dev/null +++ b/.github/workflows/manual-deploy.yml @@ -0,0 +1,317 @@ +name: Manual Deploy +run-name: ${{ github.actor }} is manually deploying packages to version ${{ inputs.version }} + +on: + workflow_dispatch: + inputs: + version: + description: 'Version number to deploy (e.g., 1.2.3)' + required: true + type: string + +env: + rid: ${{ github.run_id }}-${{ github.run_number }} + token: ${{ secrets.NPM_TOKEN }} + GIT_AUTHOR_NAME: ${{ github.actor }} + GIT_AUTHOR_EMAIL: ${{ github.actor }}@users.noreply.github.com + +jobs: + initialize: + name: Initialize Project + runs-on: ubuntu-latest + # This sets the environment for the job, which can be used to control secrets, environment protection rules, and auditability in GitHub Actions. + environment: deployer + + steps: + - name: Validate Version Format + run: | + if [[ ! "${{ inputs.version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "Error: Version must be in format x.y.z (e.g., 1.2.3)" + exit 1 + fi + + - name: Checkout Project + uses: actions/checkout@v3 + with: + # fetch-depth: 0 downloads the complete git history instead of just the latest commit. + # This is needed for changelog generation, version comparisons, and tag operations. + fetch-depth: 0 + + - name: Setup Node + uses: actions/setup-node@v3.7.0 + with: + node-version-file: '.nvmrc' + registry-url: 'https://registry.npmjs.org' + cache: 'yarn' + + - name: Install Dependencies + run: yarn + + - name: Cache Dependencies + uses: actions/cache@v3 + with: + path: '**/node_modules' + key: node-modules-${{ hashFiles('./yarn.lock') }} + + build: + name: Build Packages + needs: initialize + runs-on: ubuntu-latest + environment: deployer + + steps: + - name: Checkout Project + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Setup Node + uses: actions/setup-node@v3.7.0 + with: + node-version-file: '.nvmrc' + registry-url: 'https://registry.npmjs.org' + cache: 'yarn' + + - name: Uncache Dependencies + uses: actions/cache@v3 + with: + path: '**/node_modules' + key: node-modules-${{ hashFiles('./yarn.lock') }} + + - name: Synchronize Packages + run: yarn + + - name: Build Tools + run: yarn workspaces foreach --from '@webex/*-tools' --topological-dev --parallel --verbose run build:src + + - name: Build Webex Core + run: yarn workspace @webex/webex-core run build:src + + - name: Build Other Packages + run: yarn workspaces foreach --parallel --verbose run build:src + + - name: Cache Distributables + uses: actions/cache@v3 + with: + path: '**/dist' + key: dist-${{ env.rid }} + + publish-npm: + name: Publish - NPM + needs: build + runs-on: ubuntu-latest + environment: deployer + + steps: + - name: Checkout Project + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Setup Node + uses: actions/setup-node@v3.7.0 + with: + node-version-file: '.nvmrc' + registry-url: 'https://registry.npmjs.org' + cache: 'yarn' + + - name: Uncache Dependencies + uses: actions/cache@v3 + with: + path: '**/node_modules' + key: node-modules-${{ hashFiles('./yarn.lock') }} + + - name: Uncache Distributables + uses: actions/cache@v3 + with: + path: '**/dist' + key: dist-${{ env.rid }} + + - name: Add NPM token to .yarnrc.yml file + run: | + echo "npmAuthToken: ${{ env.token }}" >> ~/.yarnrc.yml + + - name: Synchronize Packages + run: yarn + + - name: Set Package Versions + run: yarn package-tools version set ${{ inputs.version }} --all + + - name: Display Package Information + run: | + echo "Setting all packages to version: ${{ inputs.version }}" + echo "Packages will be published with 'latest' tag" + + - name: Build all packages for publish + run: yarn run build:publish + + - name: Build a webex UMD + run: yarn run build:script + + - name: Deploy Packages + run: yarn workspaces foreach --all --verbose run deploy:npm --access public --tag latest + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + publish-documentation: + name: Publish - Documentation + needs: publish-npm + runs-on: ubuntu-latest + environment: deployer + + steps: + - name: Documentation Deploy Steps + run: echo "Documentation Deploy Steps for Manual Deployment" + + - name: Checkout Project + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Setup Node + uses: actions/setup-node@v3.7.0 + with: + node-version-file: '.nvmrc' + registry-url: 'https://registry.npmjs.org' + cache: 'yarn' + + - name: Uncache Dependencies + uses: actions/cache@v3 + with: + path: '**/node_modules' + key: node-modules-${{ hashFiles('./yarn.lock') }} + + - name: Uncache Distributables + uses: actions/cache@v3 + with: + path: '**/dist' + key: dist-${{ env.rid }} + + - name: Synchronize Packages + run: yarn + + - name: Build tools and set versions + run: | + yarn workspaces foreach --from '@webex/*-tools' --topological-dev --parallel --verbose run build:src + yarn package-tools version set ${{ inputs.version }} --all + + - name: Build packages locally + run: yarn build:local + + - name: Build Docs + run: yarn run build:docs + + - name: Set Git Identity + run: | + git config user.email "${GIT_AUTHOR_EMAIL}" + git config user.name "${GIT_AUTHOR_NAME}" + + - name: Get existing changelog from documentation Branch + run: | + git fetch origin documentation + git checkout origin/documentation -- docs/changelog/logs + + - name: Get all package names for changelog + id: get-packages + run: | + PACKAGES=$(yarn package-tools list | tr '\n' ' ' | sed 's/ *$//') + echo "packages=${PACKAGES}" >> $GITHUB_OUTPUT + + - name: Update changelog + run: | + PREVIOUS_COMMIT=$(git rev-parse HEAD~1) + yarn package-tools changelog --packages ${{ steps.get-packages.outputs.packages }} --tag latest --commit ${PREVIOUS_COMMIT} + + - name: Update Changelog and Publish Docs Folder + run: | + # Check if there's anything to commit before committing + if [ -n "$(git status --porcelain)" ]; then + git add docs/ + git commit -m "chore(docs): update docs for manual deployment v${{ inputs.version }}" + git push origin HEAD:documentation --force + fi + + publish-tag: + name: Publish - Tags + runs-on: ubuntu-latest + needs: publish-npm + environment: deployer + + outputs: + message: ${{ steps.versionextractor.outputs.message }} + version: ${{ steps.versionextractor.outputs.version }} + commit: ${{ steps.lastcommit.outputs.commit }} + proceed: ${{ steps.skipcondition.outputs.proceed }} + + steps: + - name: Checkout Project + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Setup Node + uses: actions/setup-node@v3.7.0 + with: + node-version-file: '.nvmrc' + registry-url: 'https://registry.npmjs.org' + cache: 'yarn' + + - name: Uncache Dependencies + uses: actions/cache@v3 + with: + path: '**/node_modules' + key: node-modules-${{ hashFiles('./yarn.lock') }} + + - name: Synchronize Packages + run: yarn + + - name: Extract latest version and commit message + id: versionextractor + run: | + echo "message=$(git log -1 --oneline --no-decorate)" >> $GITHUB_OUTPUT + echo "version=v${{ inputs.version }}" >> $GITHUB_OUTPUT + + - name: Conditions to skip tag publish + id: skipcondition + run: | + echo "proceed=true" >> $GITHUB_OUTPUT + if git rev-parse "v${{ inputs.version }}" >/dev/null 2>&1; then + echo "Tag v${{ inputs.version }} already exists. Exiting job." + echo "proceed=false" >> $GITHUB_OUTPUT + else + echo "Creating the tag v${{ inputs.version }}." + fi + + - name: Get the last commit hash + id: lastcommit + run: | + if [ ${{ steps.skipcondition.outputs.proceed }} = false ]; then + echo "Skipping this step." + else + echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT + fi + + - name: Set Git Identity + run: | + if [ ${{ steps.skipcondition.outputs.proceed }} = false ]; then + echo "Skipping this step." + else + git config user.email "${GIT_AUTHOR_EMAIL}" + git config user.name "${GIT_AUTHOR_NAME}" + fi + + - name: Create a tag for the last commit + run: | + if [ ${{ steps.skipcondition.outputs.proceed }} = false ]; then + echo "Skipping this step." + else + git tag -a "${{ steps.versionextractor.outputs.version }}" ${{ steps.lastcommit.outputs.commit }} -m "${{ steps.versionextractor.outputs.message }}" + fi + + - name: Publish the tag to GitHub + run: | + if [ ${{ steps.skipcondition.outputs.proceed }} = false ]; then + echo "Skipping this step." + else + git push origin ${{ steps.versionextractor.outputs.version }} + fi \ No newline at end of file From ffa8a9c29c04d08d5acc9cc3a50438c6ce237f86 Mon Sep 17 00:00:00 2001 From: Kesava Krishnan Madavan Date: Tue, 29 Jul 2025 07:59:55 +0530 Subject: [PATCH 2/3] chore(tooling): remove deployer to see the script first --- .github/workflows/manual-deploy.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/manual-deploy.yml b/.github/workflows/manual-deploy.yml index b7a1ce88693..483dce99d5a 100644 --- a/.github/workflows/manual-deploy.yml +++ b/.github/workflows/manual-deploy.yml @@ -19,8 +19,6 @@ jobs: initialize: name: Initialize Project runs-on: ubuntu-latest - # This sets the environment for the job, which can be used to control secrets, environment protection rules, and auditability in GitHub Actions. - environment: deployer steps: - name: Validate Version Format @@ -57,7 +55,6 @@ jobs: name: Build Packages needs: initialize runs-on: ubuntu-latest - environment: deployer steps: - name: Checkout Project @@ -100,7 +97,6 @@ jobs: name: Publish - NPM needs: build runs-on: ubuntu-latest - environment: deployer steps: - name: Checkout Project @@ -157,7 +153,6 @@ jobs: name: Publish - Documentation needs: publish-npm runs-on: ubuntu-latest - environment: deployer steps: - name: Documentation Deploy Steps @@ -235,7 +230,6 @@ jobs: name: Publish - Tags runs-on: ubuntu-latest needs: publish-npm - environment: deployer outputs: message: ${{ steps.versionextractor.outputs.message }} From 1e64ccb20b7d3c9d887b824dafa58f9725178e2f Mon Sep 17 00:00:00 2001 From: Shreyas Sharma Date: Thu, 4 Dec 2025 11:17:09 +0530 Subject: [PATCH 3/3] feat(tooling): manual publlish --- .github/workflows/manual-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/manual-deploy.yml b/.github/workflows/manual-deploy.yml index 483dce99d5a..653c025ace5 100644 --- a/.github/workflows/manual-deploy.yml +++ b/.github/workflows/manual-deploy.yml @@ -145,7 +145,7 @@ jobs: run: yarn run build:script - name: Deploy Packages - run: yarn workspaces foreach --all --verbose run deploy:npm --access public --tag latest + run: echo"yarn workspaces foreach --all --verbose run deploy:npm --access public --tag latest" env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}