Skip to content
Open
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
311 changes: 311 additions & 0 deletions .github/workflows/manual-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,311 @@
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

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

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

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: echo"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

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

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
Loading