From b565e1b627ded0fb8e162cbab59693ac507b5f25 Mon Sep 17 00:00:00 2001 From: Sharon Natan Date: Mon, 26 Jan 2026 11:44:56 +0200 Subject: [PATCH 01/13] Update the publish sdk on merge with updates deprecated actions --- .github/workflows/publish-on-merge.yml | 110 ++++++++++++++++--------- 1 file changed, 73 insertions(+), 37 deletions(-) diff --git a/.github/workflows/publish-on-merge.yml b/.github/workflows/publish-on-merge.yml index 38708045..0560121a 100644 --- a/.github/workflows/publish-on-merge.yml +++ b/.github/workflows/publish-on-merge.yml @@ -11,17 +11,21 @@ on: default: false type: boolean +permissions: + contents: write + jobs: publish: - permissions: - contents: write - pull-requests: write runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + + - name: Initiate DevOps Utilities + uses: de-id/github-actions-devops-utilities@v1 + + - name: Checkout agents-sdk repository + uses: actions/checkout@v6 with: fetch-depth: 0 - token: ${{ secrets.PAT_TOKEN }} - name: Setup Node.js uses: actions/setup-node@v4 @@ -42,21 +46,33 @@ jobs: if [ "${{ github.ref_name }}" = "main" ]; then # For main branch - staging versions with run number BASE_VERSION=$(jq -r '.version' package.json) + delogger -l info -m "Base version: $BASE_VERSION" + if [ "$BASE_VERSION" = "null" ]; then - echo "Error: Could not read version from package.json" - exit 1 + delogger -l error -m "Error: Could not read version from package.json" fi + CLEAN_VERSION=$(echo "$BASE_VERSION" | sed 's/-.*$//') STAGING_VERSION="${CLEAN_VERSION}-staging.${{ github.run_number }}" + + delogger -l debug -m "Clean version: $CLEAN_VERSION" + delogger -l info -m "Staging version: $STAGING_VERSION" + echo "version=$STAGING_VERSION" >> $GITHUB_OUTPUT echo "tag=staging" >> $GITHUB_OUTPUT echo "description=Staging release from main branch" >> $GITHUB_OUTPUT echo "should_sync=false" >> $GITHUB_OUTPUT else # For prod branch - production versions + delogger -l info -m "Determining production version" + # Use npm version command (official npm way to bump versions) NEW_VERSION=$(npm version patch --no-git-tag-version --silent) + delogger -l info -m "New version: $NEW_VERSION" + NEW_VERSION=${NEW_VERSION#v} # Remove 'v' prefix if present + delogger -l info -m "New version without 'v' prefix: $NEW_VERSION" + echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT echo "tag=latest" >> $GITHUB_OUTPUT echo "description=Production release" >> $GITHUB_OUTPUT @@ -65,90 +81,103 @@ jobs: - name: Update package.json version run: | + delogger -l info -m "Updating package.json version" jq --arg version "${{ steps.version.outputs.version }}" '.version = $version' package.json > package.json.tmp if ! jq empty package.json.tmp 4>/dev/null; then - echo "Error: Generated invalid JSON" rm -f package.json.tmp - exit 1 + delogger -l error -m "Error: Generated invalid JSON" fi mv package.json.tmp package.json - - echo "Updated package.json version to: $(jq -r '.version' package.json)" + delogger -l info -m "Updated package.json version to: ${{ steps.version.outputs.version }}" - name: Publish to NPM env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} run: | if [ "${{ github.event.inputs.dry_run }}" = "true" ]; then - echo "🔍 DRY RUN MODE: Would publish version ${{ steps.version.outputs.version }} with tag ${{ steps.version.outputs.tag }}" - echo "📦 Package would be published to: https://www.npmjs.com/package/@d-id/client-sdk/v/${{ steps.version.outputs.version }}" - echo "🏷️ NPM tag would be: ${{ steps.version.outputs.tag }}" - echo "✅ Dry run completed successfully - no actual publishing occurred" + delogger -l info -m "🔍 DRY RUN MODE: Would publish version ${{ steps.version.outputs.version }} with tag ${{ steps.version.outputs.tag }}" + delogger -l info -m "📦 Package would be published to: https://www.npmjs.com/package/@d-id/client-sdk/v/${{ steps.version.outputs.version }}" + delogger -l info -m "🏷️ NPM tag would be: ${{ steps.version.outputs.tag }}" + delogger -l info -m "✅ Dry run completed successfully - no actual publishing occurred" else - echo "🚀 Publishing version ${{ steps.version.outputs.version }} with tag ${{ steps.version.outputs.tag }}" + delogger -l info -m "🚀 Publishing version ${{ steps.version.outputs.version }} with tag ${{ steps.version.outputs.tag }}" npm publish --access public --tag ${{ steps.version.outputs.tag }} - echo "✅ Successfully published to NPM" + delogger -l info -m "✅ Successfully published to NPM" fi - name: Create Git tag for production if: github.ref_name == 'prod' && github.event.inputs.dry_run != 'true' run: | + delogger -l info -m "Creating Git tag for production" + + delogger -l info -m "Configuring Git user" git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" + + delogger -l info -m "Creating Git tag" git tag "v${{ steps.version.outputs.version }}" - git push https://x-access-token:${{ secrets.PAT_TOKEN }}@github.com/${{ github.repository }}.git "v${{ steps.version.outputs.version }}" + + delogger -l info -m "Pushing Git tag to origin" + git push origin "v${{ steps.version.outputs.version }}" - name: Commit version bump (prod only) if: github.ref_name == 'prod' && github.event.inputs.dry_run != 'true' - env: - GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }} run: | + delogger -l info -m "Committing version bump" + + delogger -l info -m "Configuring Git user" git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" + git add package.json - git commit -m "chore: bump version to ${{ steps.version.outputs.version }} [skip ci]" || echo "No changes to commit" - git push https://x-access-token:${{ secrets.PAT_TOKEN }}@github.com/${{ github.repository }}.git prod + + delogger -l info -m "Committing version bump without triggering the CICD pipeline" + git commit -m "chore: bump version to ${{ steps.version.outputs.version }} [skip ci]" || delogger -l info -m "No changes to commit" + git push origin prod - name: Sync version back to main (prod only) if: github.ref_name == 'prod' && github.event.inputs.dry_run != 'true' - env: - GH_TOKEN: ${{ secrets.DEVOPS_TOKEN }} run: | - # Fetch latest main + delogger -l info -m "Fetching latest main" git fetch origin main git checkout main git pull origin main + delogger -l info -m "Updating package.json version" jq --arg version "${{ steps.version.outputs.version }}" '.version = $version' package.json > package.json.tmp if ! jq empty package.json.tmp 4>/dev/null; then - echo "Error: Generated invalid JSON" rm -f package.json.tmp - exit 1 + delogger -l error -m "Error: Generated invalid JSON" fi mv package.json.tmp package.json if git diff --quiet package.json; then - echo "No version changes needed" + delogger -l info -m "No version changes needed" else + delogger -l info -m "Configuring Git user" git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" + + delogger -l info -m "Adding and committing package.json to main branch without triggering the CICD pipeline" git add package.json git commit -m "chore: sync version ${{ steps.version.outputs.version }} from prod [skip ci]" + + delogger -l info -m "Pushing package.json to main branch" git push origin main fi - name: Create GitHub Release (prod only) if: github.ref_name == 'prod' && github.event.inputs.dry_run != 'true' - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: softprops/action-gh-release@v2 with: + name: Release v${{ steps.version.outputs.version }} tag_name: v${{ steps.version.outputs.version }} - release_name: Release v${{ steps.version.outputs.version }} + draft: false + prerelease: false body: | ## Release v${{ steps.version.outputs.version }} @@ -160,12 +189,10 @@ jobs: ``` ${{ steps.version.outputs.description }} - draft: false - prerelease: false - name: Checkout agents-ui repository if: github.ref_name == 'prod' && github.event.inputs.dry_run != 'true' - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: repository: de-id/agents-ui token: ${{ secrets.DEVOPS_TOKEN }} @@ -173,26 +200,35 @@ jobs: - name: Update SDK version and create PR if: github.ref_name == 'prod' && github.event.inputs.dry_run != 'true' + working-directory: agents-ui env: GH_TOKEN: ${{ secrets.DEVOPS_TOKEN }} run: | - cd agents-ui + delogger -l info -m "Updating SDK version in agents-ui" jq --arg version "${{ steps.version.outputs.version }}" '.dependencies."@d-id/client-sdk" = $version' package.json > package.json.tmp mv package.json.tmp package.json if git diff --quiet package.json; then - echo "No version changes needed in agents-ui" + delogger -l info -m "No version changes needed in agents-ui" exit 0 fi + delogger -l info -m "Creating new branch" git checkout -b "chore/bump-sdk-version-${{ steps.version.outputs.version }}" + + delogger -l info -m "Configuring Git user" git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" + + delogger -l info -m "Adding and committing package.json" git add package.json git commit -m "chore: bump @d-id/client-sdk to v${{ steps.version.outputs.version }}" + + delogger -l info -m "Publishing branch to origin" git push origin "chore/bump-sdk-version-${{ steps.version.outputs.version }}" + delogger -l info -m "Creating PR on agents-ui repository" gh pr create \ --repo de-id/agents-ui \ --title "chore: bump @d-id/client-sdk to v${{ steps.version.outputs.version }}" \ From 8481027a19604bcbc7cbe56573f98cafdf567653 Mon Sep 17 00:00:00 2001 From: Sharon Natan Date: Mon, 26 Jan 2026 11:49:22 +0200 Subject: [PATCH 02/13] Simualte prod --- .github/workflows/publish-on-merge.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/publish-on-merge.yml b/.github/workflows/publish-on-merge.yml index 0560121a..4f5b3860 100644 --- a/.github/workflows/publish-on-merge.yml +++ b/.github/workflows/publish-on-merge.yml @@ -26,6 +26,7 @@ jobs: uses: actions/checkout@v6 with: fetch-depth: 0 + ref: prod - name: Setup Node.js uses: actions/setup-node@v4 From 22ebd0991cbd1954290b4463726a1be5b6c2273b Mon Sep 17 00:00:00 2001 From: Sharon Natan Date: Mon, 26 Jan 2026 11:50:53 +0200 Subject: [PATCH 03/13] Disable pushing NPM for testing --- .github/workflows/publish-on-merge.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish-on-merge.yml b/.github/workflows/publish-on-merge.yml index 4f5b3860..c166fca5 100644 --- a/.github/workflows/publish-on-merge.yml +++ b/.github/workflows/publish-on-merge.yml @@ -94,6 +94,7 @@ jobs: delogger -l info -m "Updated package.json version to: ${{ steps.version.outputs.version }}" - name: Publish to NPM + if: ${{ false }} # Disable publishing to NPM for testing purposes env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} run: | @@ -109,7 +110,7 @@ jobs: fi - name: Create Git tag for production - if: github.ref_name == 'prod' && github.event.inputs.dry_run != 'true' + #if: github.ref_name == 'prod' && github.event.inputs.dry_run != 'true' run: | delogger -l info -m "Creating Git tag for production" From 589d1c43ffbb16128db48abeed24ffae7fbfd35c Mon Sep 17 00:00:00 2001 From: Sharon Natan Date: Mon, 26 Jan 2026 12:06:09 +0200 Subject: [PATCH 04/13] Apply logger as part of the workflow because this is public repo --- .github/workflows/publish-on-merge.yml | 90 ++++++++++++++------------ 1 file changed, 50 insertions(+), 40 deletions(-) diff --git a/.github/workflows/publish-on-merge.yml b/.github/workflows/publish-on-merge.yml index c166fca5..cdc96128 100644 --- a/.github/workflows/publish-on-merge.yml +++ b/.github/workflows/publish-on-merge.yml @@ -14,13 +14,23 @@ on: permissions: contents: write +env: + INFO_COLOR: "\033[0;32m" # Green + ERROR_COLOR: "\033[0;31m" # Red + RESET_COLOR: "\033[0m" # Reset to default + jobs: publish: runs-on: ubuntu-latest steps: - - name: Initiate DevOps Utilities - uses: de-id/github-actions-devops-utilities@v1 + - name: Setup logging functions + run: | + cat >> ~/.bashrc << 'EOF' + log_info() { echo "${INFO_COLOR}INFO:${RESET_COLOR} $1"; } + log_error() { echo "${ERROR_COLOR}ERROR:${RESET_COLOR} $1"; exit 1; } + EOF + echo "BASH_ENV=~/.bashrc" >> $GITHUB_ENV - name: Checkout agents-sdk repository uses: actions/checkout@v6 @@ -47,17 +57,17 @@ jobs: if [ "${{ github.ref_name }}" = "main" ]; then # For main branch - staging versions with run number BASE_VERSION=$(jq -r '.version' package.json) - delogger -l info -m "Base version: $BASE_VERSION" + log_info "Base version: $BASE_VERSION" if [ "$BASE_VERSION" = "null" ]; then - delogger -l error -m "Error: Could not read version from package.json" + log_error "Could not read version from package.json" fi CLEAN_VERSION=$(echo "$BASE_VERSION" | sed 's/-.*$//') STAGING_VERSION="${CLEAN_VERSION}-staging.${{ github.run_number }}" - delogger -l debug -m "Clean version: $CLEAN_VERSION" - delogger -l info -m "Staging version: $STAGING_VERSION" + log_info "Clean version: $CLEAN_VERSION" + log_info "Staging version: $STAGING_VERSION" echo "version=$STAGING_VERSION" >> $GITHUB_OUTPUT echo "tag=staging" >> $GITHUB_OUTPUT @@ -65,14 +75,14 @@ jobs: echo "should_sync=false" >> $GITHUB_OUTPUT else # For prod branch - production versions - delogger -l info -m "Determining production version" + log_info "Determining production version" # Use npm version command (official npm way to bump versions) NEW_VERSION=$(npm version patch --no-git-tag-version --silent) - delogger -l info -m "New version: $NEW_VERSION" + log_info "New version: $NEW_VERSION" NEW_VERSION=${NEW_VERSION#v} # Remove 'v' prefix if present - delogger -l info -m "New version without 'v' prefix: $NEW_VERSION" + log_info "New version without 'v' prefix: $NEW_VERSION" echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT echo "tag=latest" >> $GITHUB_OUTPUT @@ -82,16 +92,16 @@ jobs: - name: Update package.json version run: | - delogger -l info -m "Updating package.json version" + log_info "Updating package.json version" jq --arg version "${{ steps.version.outputs.version }}" '.version = $version' package.json > package.json.tmp if ! jq empty package.json.tmp 4>/dev/null; then rm -f package.json.tmp - delogger -l error -m "Error: Generated invalid JSON" + log_error "Generated invalid JSON" fi mv package.json.tmp package.json - delogger -l info -m "Updated package.json version to: ${{ steps.version.outputs.version }}" + log_info "Updated package.json version to: ${{ steps.version.outputs.version }}" - name: Publish to NPM if: ${{ false }} # Disable publishing to NPM for testing purposes @@ -99,76 +109,76 @@ jobs: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} run: | if [ "${{ github.event.inputs.dry_run }}" = "true" ]; then - delogger -l info -m "🔍 DRY RUN MODE: Would publish version ${{ steps.version.outputs.version }} with tag ${{ steps.version.outputs.tag }}" - delogger -l info -m "📦 Package would be published to: https://www.npmjs.com/package/@d-id/client-sdk/v/${{ steps.version.outputs.version }}" - delogger -l info -m "🏷️ NPM tag would be: ${{ steps.version.outputs.tag }}" - delogger -l info -m "✅ Dry run completed successfully - no actual publishing occurred" + log_info "🔍 DRY RUN MODE: Would publish version ${{ steps.version.outputs.version }} with tag ${{ steps.version.outputs.tag }}" + log_info "📦 Package would be published to: https://www.npmjs.com/package/@d-id/client-sdk/v/${{ steps.version.outputs.version }}" + log_info "🏷️ NPM tag would be: ${{ steps.version.outputs.tag }}" + log_info "✅ Dry run completed successfully - no actual publishing occurred" else - delogger -l info -m "🚀 Publishing version ${{ steps.version.outputs.version }} with tag ${{ steps.version.outputs.tag }}" + log_info "🚀 Publishing version ${{ steps.version.outputs.version }} with tag ${{ steps.version.outputs.tag }}" npm publish --access public --tag ${{ steps.version.outputs.tag }} - delogger -l info -m "✅ Successfully published to NPM" + log_info "✅ Successfully published to NPM" fi - name: Create Git tag for production #if: github.ref_name == 'prod' && github.event.inputs.dry_run != 'true' run: | - delogger -l info -m "Creating Git tag for production" + log_info "Creating Git tag for production" - delogger -l info -m "Configuring Git user" + log_info "Configuring Git user" git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" - delogger -l info -m "Creating Git tag" + log_info "Creating Git tag" git tag "v${{ steps.version.outputs.version }}" - delogger -l info -m "Pushing Git tag to origin" + log_info "Pushing Git tag to origin" git push origin "v${{ steps.version.outputs.version }}" - name: Commit version bump (prod only) if: github.ref_name == 'prod' && github.event.inputs.dry_run != 'true' run: | - delogger -l info -m "Committing version bump" + log_info "Committing version bump" - delogger -l info -m "Configuring Git user" + log_info "Configuring Git user" git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" git add package.json - delogger -l info -m "Committing version bump without triggering the CICD pipeline" - git commit -m "chore: bump version to ${{ steps.version.outputs.version }} [skip ci]" || delogger -l info -m "No changes to commit" + log_info "Committing version bump without triggering the CICD pipeline" + git commit -m "chore: bump version to ${{ steps.version.outputs.version }} [skip ci]" || log_info "No changes to commit" git push origin prod - name: Sync version back to main (prod only) if: github.ref_name == 'prod' && github.event.inputs.dry_run != 'true' run: | - delogger -l info -m "Fetching latest main" + log_info "Fetching latest main" git fetch origin main git checkout main git pull origin main - delogger -l info -m "Updating package.json version" + log_info "Updating package.json version" jq --arg version "${{ steps.version.outputs.version }}" '.version = $version' package.json > package.json.tmp if ! jq empty package.json.tmp 4>/dev/null; then rm -f package.json.tmp - delogger -l error -m "Error: Generated invalid JSON" + log_error "Generated invalid JSON" fi mv package.json.tmp package.json if git diff --quiet package.json; then - delogger -l info -m "No version changes needed" + log_info "No version changes needed" else - delogger -l info -m "Configuring Git user" + log_info "Configuring Git user" git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" - delogger -l info -m "Adding and committing package.json to main branch without triggering the CICD pipeline" + log_info "Adding and committing package.json to main branch without triggering the CICD pipeline" git add package.json git commit -m "chore: sync version ${{ steps.version.outputs.version }} from prod [skip ci]" - delogger -l info -m "Pushing package.json to main branch" + log_info "Pushing package.json to main branch" git push origin main fi @@ -206,31 +216,31 @@ jobs: env: GH_TOKEN: ${{ secrets.DEVOPS_TOKEN }} run: | - delogger -l info -m "Updating SDK version in agents-ui" + log_info "Updating SDK version in agents-ui" jq --arg version "${{ steps.version.outputs.version }}" '.dependencies."@d-id/client-sdk" = $version' package.json > package.json.tmp mv package.json.tmp package.json if git diff --quiet package.json; then - delogger -l info -m "No version changes needed in agents-ui" + log_info "No version changes needed in agents-ui" exit 0 fi - delogger -l info -m "Creating new branch" + log_info "Creating new branch" git checkout -b "chore/bump-sdk-version-${{ steps.version.outputs.version }}" - delogger -l info -m "Configuring Git user" + log_info "Configuring Git user" git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" - delogger -l info -m "Adding and committing package.json" + log_info "Adding and committing package.json" git add package.json git commit -m "chore: bump @d-id/client-sdk to v${{ steps.version.outputs.version }}" - delogger -l info -m "Publishing branch to origin" + log_info "Publishing branch to origin" git push origin "chore/bump-sdk-version-${{ steps.version.outputs.version }}" - delogger -l info -m "Creating PR on agents-ui repository" + log_info "Creating PR on agents-ui repository" gh pr create \ --repo de-id/agents-ui \ --title "chore: bump @d-id/client-sdk to v${{ steps.version.outputs.version }}" \ From 6276ef418c1c5f96857840d0881239ecd09c6a98 Mon Sep 17 00:00:00 2001 From: Sharon Natan Date: Mon, 26 Jan 2026 12:15:51 +0200 Subject: [PATCH 05/13] Add local logger for github actions --- .github/scripts/logger.sh | 77 +++++++++++++++++++++ .github/workflows/publish-on-merge.yml | 94 ++++++++++++-------------- 2 files changed, 120 insertions(+), 51 deletions(-) create mode 100644 .github/scripts/logger.sh diff --git a/.github/scripts/logger.sh b/.github/scripts/logger.sh new file mode 100644 index 00000000..aa727080 --- /dev/null +++ b/.github/scripts/logger.sh @@ -0,0 +1,77 @@ +#!/bin/bash + +# GitHub Actions Logger Script for Public Repositories +# Usage: logger -l -m +# Levels: info, warn, error, debug + +# Color codes with bold +GREEN='\033[1;32m' +YELLOW='\033[1;33m' +RED='\033[1;31m' +NC='\033[0m' # No Color + +# Default values +LOG_LEVEL="" +MESSAGE="" + +# Parse command line arguments +while getopts "l:m:" opt; do + case $opt in + l) + LOG_LEVEL="$OPTARG" + ;; + m) + MESSAGE="$OPTARG" + ;; + \?) + echo "Invalid option: -$OPTARG" >&2 + exit 1 + ;; + :) + echo "Option -$OPTARG requires an argument." >&2 + exit 1 + ;; + esac +done + +# Validate inputs +if [ -z "$LOG_LEVEL" ]; then + echo "Error: Log level (-l) is required" >&2 + echo "Usage: logger -l -m " >&2 + echo "Levels: info, warn, error, debug" >&2 + exit 1 +fi + +if [ -z "$MESSAGE" ]; then + echo "Error: Message (-m) is required" >&2 + echo "Usage: logger -l -m " >&2 + exit 1 +fi + +# Convert log level to uppercase for display +LOG_LEVEL_UPPER=$(echo "$LOG_LEVEL" | tr '[:lower:]' '[:upper:]') + +# Process based on log level +case "$LOG_LEVEL" in + info|INFO) + echo -e "${GREEN}INFO:${NC} $MESSAGE" + ;; + warn|WARN) + echo -e "${YELLOW}WARN:${NC} $MESSAGE" + ;; + error|ERROR) + echo -e "${RED}ERROR:${NC} $MESSAGE" + exit 1 + ;; + debug|DEBUG) + # Only print debug messages when GitHub Actions is in debug mode + if [[ "$RUNNER_DEBUG" == "1" || "$ACTIONS_STEP_DEBUG" == "true" || "$ACTIONS_RUNNER_DEBUG" == "true" ]]; then + echo -e "${YELLOW}DEBUG:${NC} $MESSAGE" + fi + ;; + *) + echo "Error: Invalid log level '$LOG_LEVEL'" >&2 + echo "Valid levels: info, warn, error, debug" >&2 + exit 1 + ;; +esac \ No newline at end of file diff --git a/.github/workflows/publish-on-merge.yml b/.github/workflows/publish-on-merge.yml index cdc96128..f2d8c00f 100644 --- a/.github/workflows/publish-on-merge.yml +++ b/.github/workflows/publish-on-merge.yml @@ -14,30 +14,22 @@ on: permissions: contents: write -env: - INFO_COLOR: "\033[0;32m" # Green - ERROR_COLOR: "\033[0;31m" # Red - RESET_COLOR: "\033[0m" # Reset to default - jobs: publish: runs-on: ubuntu-latest steps: - - name: Setup logging functions - run: | - cat >> ~/.bashrc << 'EOF' - log_info() { echo "${INFO_COLOR}INFO:${RESET_COLOR} $1"; } - log_error() { echo "${ERROR_COLOR}ERROR:${RESET_COLOR} $1"; exit 1; } - EOF - echo "BASH_ENV=~/.bashrc" >> $GITHUB_ENV - - name: Checkout agents-sdk repository uses: actions/checkout@v6 with: fetch-depth: 0 ref: prod + - name: Setup logger + run: | + sudo cp .github/scripts/logger.sh /usr/local/bin/logger + sudo chmod +x /usr/local/bin/logger + - name: Setup Node.js uses: actions/setup-node@v4 with: @@ -57,17 +49,17 @@ jobs: if [ "${{ github.ref_name }}" = "main" ]; then # For main branch - staging versions with run number BASE_VERSION=$(jq -r '.version' package.json) - log_info "Base version: $BASE_VERSION" + logger -l info -m "Base version: $BASE_VERSION" if [ "$BASE_VERSION" = "null" ]; then - log_error "Could not read version from package.json" + logger -l error -m "Could not read version from package.json" fi CLEAN_VERSION=$(echo "$BASE_VERSION" | sed 's/-.*$//') STAGING_VERSION="${CLEAN_VERSION}-staging.${{ github.run_number }}" - log_info "Clean version: $CLEAN_VERSION" - log_info "Staging version: $STAGING_VERSION" + logger -l info -m "Clean version: $CLEAN_VERSION" + logger -l info -m "Staging version: $STAGING_VERSION" echo "version=$STAGING_VERSION" >> $GITHUB_OUTPUT echo "tag=staging" >> $GITHUB_OUTPUT @@ -75,14 +67,14 @@ jobs: echo "should_sync=false" >> $GITHUB_OUTPUT else # For prod branch - production versions - log_info "Determining production version" + logger -l info -m "Determining production version" # Use npm version command (official npm way to bump versions) NEW_VERSION=$(npm version patch --no-git-tag-version --silent) - log_info "New version: $NEW_VERSION" + logger -l info -m "New version: $NEW_VERSION" NEW_VERSION=${NEW_VERSION#v} # Remove 'v' prefix if present - log_info "New version without 'v' prefix: $NEW_VERSION" + logger -l info -m "New version without 'v' prefix: $NEW_VERSION" echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT echo "tag=latest" >> $GITHUB_OUTPUT @@ -92,16 +84,16 @@ jobs: - name: Update package.json version run: | - log_info "Updating package.json version" + logger -l info -m "Updating package.json version" jq --arg version "${{ steps.version.outputs.version }}" '.version = $version' package.json > package.json.tmp if ! jq empty package.json.tmp 4>/dev/null; then rm -f package.json.tmp - log_error "Generated invalid JSON" + logger -l error -m "Generated invalid JSON" fi mv package.json.tmp package.json - log_info "Updated package.json version to: ${{ steps.version.outputs.version }}" + logger -l info -m "Updated package.json version to: ${{ steps.version.outputs.version }}" - name: Publish to NPM if: ${{ false }} # Disable publishing to NPM for testing purposes @@ -109,76 +101,76 @@ jobs: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} run: | if [ "${{ github.event.inputs.dry_run }}" = "true" ]; then - log_info "🔍 DRY RUN MODE: Would publish version ${{ steps.version.outputs.version }} with tag ${{ steps.version.outputs.tag }}" - log_info "📦 Package would be published to: https://www.npmjs.com/package/@d-id/client-sdk/v/${{ steps.version.outputs.version }}" - log_info "🏷️ NPM tag would be: ${{ steps.version.outputs.tag }}" - log_info "✅ Dry run completed successfully - no actual publishing occurred" + logger -l info -m "🔍 DRY RUN MODE: Would publish version ${{ steps.version.outputs.version }} with tag ${{ steps.version.outputs.tag }}" + logger -l info -m "📦 Package would be published to: https://www.npmjs.com/package/@d-id/client-sdk/v/${{ steps.version.outputs.version }}" + logger -l info -m "🏷️ NPM tag would be: ${{ steps.version.outputs.tag }}" + logger -l info -m "✅ Dry run completed successfully - no actual publishing occurred" else - log_info "🚀 Publishing version ${{ steps.version.outputs.version }} with tag ${{ steps.version.outputs.tag }}" + logger -l info -m "🚀 Publishing version ${{ steps.version.outputs.version }} with tag ${{ steps.version.outputs.tag }}" npm publish --access public --tag ${{ steps.version.outputs.tag }} - log_info "✅ Successfully published to NPM" + logger -l info -m "✅ Successfully published to NPM" fi - name: Create Git tag for production #if: github.ref_name == 'prod' && github.event.inputs.dry_run != 'true' run: | - log_info "Creating Git tag for production" + logger -l info -m "Creating Git tag for production" - log_info "Configuring Git user" + logger -l info -m "Configuring Git user" git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" - log_info "Creating Git tag" + logger -l info -m "Creating Git tag" git tag "v${{ steps.version.outputs.version }}" - log_info "Pushing Git tag to origin" + logger -l info -m "Pushing Git tag to origin" git push origin "v${{ steps.version.outputs.version }}" - name: Commit version bump (prod only) if: github.ref_name == 'prod' && github.event.inputs.dry_run != 'true' run: | - log_info "Committing version bump" + logger -l info -m "Committing version bump" - log_info "Configuring Git user" + logger -l info -m "Configuring Git user" git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" git add package.json - log_info "Committing version bump without triggering the CICD pipeline" - git commit -m "chore: bump version to ${{ steps.version.outputs.version }} [skip ci]" || log_info "No changes to commit" + logger -l info -m "Committing version bump without triggering the CICD pipeline" + git commit -m "chore: bump version to ${{ steps.version.outputs.version }} [skip ci]" || logger -l info -m "No changes to commit" git push origin prod - name: Sync version back to main (prod only) if: github.ref_name == 'prod' && github.event.inputs.dry_run != 'true' run: | - log_info "Fetching latest main" + logger -l info -m "Fetching latest main" git fetch origin main git checkout main git pull origin main - log_info "Updating package.json version" + logger -l info -m "Updating package.json version" jq --arg version "${{ steps.version.outputs.version }}" '.version = $version' package.json > package.json.tmp if ! jq empty package.json.tmp 4>/dev/null; then rm -f package.json.tmp - log_error "Generated invalid JSON" + logger -l error -m "Generated invalid JSON" fi mv package.json.tmp package.json if git diff --quiet package.json; then - log_info "No version changes needed" + logger -l info -m "No version changes needed" else - log_info "Configuring Git user" + logger -l info -m "Configuring Git user" git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" - log_info "Adding and committing package.json to main branch without triggering the CICD pipeline" + logger -l info -m "Adding and committing package.json to main branch without triggering the CICD pipeline" git add package.json git commit -m "chore: sync version ${{ steps.version.outputs.version }} from prod [skip ci]" - log_info "Pushing package.json to main branch" + logger -l info -m "Pushing package.json to main branch" git push origin main fi @@ -216,31 +208,31 @@ jobs: env: GH_TOKEN: ${{ secrets.DEVOPS_TOKEN }} run: | - log_info "Updating SDK version in agents-ui" + logger -l info -m "Updating SDK version in agents-ui" jq --arg version "${{ steps.version.outputs.version }}" '.dependencies."@d-id/client-sdk" = $version' package.json > package.json.tmp mv package.json.tmp package.json if git diff --quiet package.json; then - log_info "No version changes needed in agents-ui" + logger -l info -m "No version changes needed in agents-ui" exit 0 fi - log_info "Creating new branch" + logger -l info -m "Creating new branch" git checkout -b "chore/bump-sdk-version-${{ steps.version.outputs.version }}" - log_info "Configuring Git user" + logger -l info -m "Configuring Git user" git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" - log_info "Adding and committing package.json" + logger -l info -m "Adding and committing package.json" git add package.json git commit -m "chore: bump @d-id/client-sdk to v${{ steps.version.outputs.version }}" - log_info "Publishing branch to origin" + logger -l info -m "Publishing branch to origin" git push origin "chore/bump-sdk-version-${{ steps.version.outputs.version }}" - log_info "Creating PR on agents-ui repository" + logger -l info -m "Creating PR on agents-ui repository" gh pr create \ --repo de-id/agents-ui \ --title "chore: bump @d-id/client-sdk to v${{ steps.version.outputs.version }}" \ From 2262b4b70b05700f6d55572d3a3b223b67709ed3 Mon Sep 17 00:00:00 2001 From: Sharon Natan Date: Mon, 26 Jan 2026 12:16:13 +0200 Subject: [PATCH 06/13] Removed prod --- .github/workflows/publish-on-merge.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-on-merge.yml b/.github/workflows/publish-on-merge.yml index f2d8c00f..ca24eace 100644 --- a/.github/workflows/publish-on-merge.yml +++ b/.github/workflows/publish-on-merge.yml @@ -23,7 +23,7 @@ jobs: uses: actions/checkout@v6 with: fetch-depth: 0 - ref: prod + # ref: prod - name: Setup logger run: | From 5e640766c02b17ea3921f80f4f85bb98fc2ae612 Mon Sep 17 00:00:00 2001 From: Sharon Natan Date: Mon, 26 Jan 2026 12:19:08 +0200 Subject: [PATCH 07/13] Testing full flow and added error handling --- .github/workflows/publish-on-merge.yml | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/.github/workflows/publish-on-merge.yml b/.github/workflows/publish-on-merge.yml index ca24eace..f4e66d56 100644 --- a/.github/workflows/publish-on-merge.yml +++ b/.github/workflows/publish-on-merge.yml @@ -38,10 +38,16 @@ jobs: cache: 'yarn' - name: Install dependencies - run: yarn install --frozen-lockfile + run: | + logger -l info -m "Installing dependencies" + yarn install --frozen-lockfile \ + || logger -l error -m "Failed to install dependencies" - name: Build package - run: yarn build + run: | + logger -l info -m "Building package" + yarn build \ + || logger -l error -m "Failed to build package" - name: Determine version and tag id: version @@ -127,7 +133,7 @@ jobs: git push origin "v${{ steps.version.outputs.version }}" - name: Commit version bump (prod only) - if: github.ref_name == 'prod' && github.event.inputs.dry_run != 'true' + #if: github.ref_name == 'prod' && github.event.inputs.dry_run != 'true' run: | logger -l info -m "Committing version bump" @@ -142,7 +148,7 @@ jobs: git push origin prod - name: Sync version back to main (prod only) - if: github.ref_name == 'prod' && github.event.inputs.dry_run != 'true' + # if: github.ref_name == 'prod' && github.event.inputs.dry_run != 'true' run: | logger -l info -m "Fetching latest main" git fetch origin main @@ -175,7 +181,7 @@ jobs: fi - name: Create GitHub Release (prod only) - if: github.ref_name == 'prod' && github.event.inputs.dry_run != 'true' + # if: github.ref_name == 'prod' && github.event.inputs.dry_run != 'true' uses: softprops/action-gh-release@v2 with: name: Release v${{ steps.version.outputs.version }} @@ -195,7 +201,7 @@ jobs: ${{ steps.version.outputs.description }} - name: Checkout agents-ui repository - if: github.ref_name == 'prod' && github.event.inputs.dry_run != 'true' + # if: github.ref_name == 'prod' && github.event.inputs.dry_run != 'true' uses: actions/checkout@v6 with: repository: de-id/agents-ui @@ -203,7 +209,7 @@ jobs: path: agents-ui - name: Update SDK version and create PR - if: github.ref_name == 'prod' && github.event.inputs.dry_run != 'true' + # if: github.ref_name == 'prod' && github.event.inputs.dry_run != 'true' working-directory: agents-ui env: GH_TOKEN: ${{ secrets.DEVOPS_TOKEN }} From 853f9918461dc468d94a4ae61671ff04adfb2506 Mon Sep 17 00:00:00 2001 From: Sharon Natan Date: Mon, 26 Jan 2026 12:22:32 +0200 Subject: [PATCH 08/13] Testing full flow --- .github/workflows/publish-on-merge.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/publish-on-merge.yml b/.github/workflows/publish-on-merge.yml index f4e66d56..7b16aec5 100644 --- a/.github/workflows/publish-on-merge.yml +++ b/.github/workflows/publish-on-merge.yml @@ -141,6 +141,12 @@ jobs: git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" + #### fetch prod and checkout to prod branch + git fetch origin prod + git checkout prod + git pull origin prod + #### + git add package.json logger -l info -m "Committing version bump without triggering the CICD pipeline" From 7d4166dc4a503b546b78186dc1192aa90ca066a7 Mon Sep 17 00:00:00 2001 From: Sharon Natan Date: Mon, 26 Jan 2026 12:23:26 +0200 Subject: [PATCH 09/13] Simualte prod --- .github/workflows/publish-on-merge.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/publish-on-merge.yml b/.github/workflows/publish-on-merge.yml index 7b16aec5..240105e7 100644 --- a/.github/workflows/publish-on-merge.yml +++ b/.github/workflows/publish-on-merge.yml @@ -90,6 +90,12 @@ jobs: - name: Update package.json version run: | + #### fetch prod and checkout to prod branch + git fetch origin prod + git checkout prod + git pull origin prod + #### + logger -l info -m "Updating package.json version" jq --arg version "${{ steps.version.outputs.version }}" '.version = $version' package.json > package.json.tmp @@ -141,12 +147,6 @@ jobs: git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" - #### fetch prod and checkout to prod branch - git fetch origin prod - git checkout prod - git pull origin prod - #### - git add package.json logger -l info -m "Committing version bump without triggering the CICD pipeline" From 3f7584cd3d293da983d52762bf5c2c60df785d5f Mon Sep 17 00:00:00 2001 From: Sharon Natan Date: Mon, 26 Jan 2026 12:26:21 +0200 Subject: [PATCH 10/13] tesing full flow without updates prod and main --- .github/workflows/publish-on-merge.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/publish-on-merge.yml b/.github/workflows/publish-on-merge.yml index 240105e7..c3e438ae 100644 --- a/.github/workflows/publish-on-merge.yml +++ b/.github/workflows/publish-on-merge.yml @@ -90,12 +90,6 @@ jobs: - name: Update package.json version run: | - #### fetch prod and checkout to prod branch - git fetch origin prod - git checkout prod - git pull origin prod - #### - logger -l info -m "Updating package.json version" jq --arg version "${{ steps.version.outputs.version }}" '.version = $version' package.json > package.json.tmp @@ -140,6 +134,7 @@ jobs: - name: Commit version bump (prod only) #if: github.ref_name == 'prod' && github.event.inputs.dry_run != 'true' + if: ${{ false }} run: | logger -l info -m "Committing version bump" @@ -155,6 +150,7 @@ jobs: - name: Sync version back to main (prod only) # if: github.ref_name == 'prod' && github.event.inputs.dry_run != 'true' + if: ${{ false }} run: | logger -l info -m "Fetching latest main" git fetch origin main From 4aac442443d0c5c5584dcd88d40415833eb09ff0 Mon Sep 17 00:00:00 2001 From: Sharon Natan Date: Mon, 26 Jan 2026 12:28:41 +0200 Subject: [PATCH 11/13] Cleanup --- .github/workflows/publish-on-merge.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/publish-on-merge.yml b/.github/workflows/publish-on-merge.yml index c3e438ae..fc5785d0 100644 --- a/.github/workflows/publish-on-merge.yml +++ b/.github/workflows/publish-on-merge.yml @@ -23,7 +23,6 @@ jobs: uses: actions/checkout@v6 with: fetch-depth: 0 - # ref: prod - name: Setup logger run: | @@ -102,7 +101,6 @@ jobs: logger -l info -m "Updated package.json version to: ${{ steps.version.outputs.version }}" - name: Publish to NPM - if: ${{ false }} # Disable publishing to NPM for testing purposes env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} run: | @@ -118,7 +116,7 @@ jobs: fi - name: Create Git tag for production - #if: github.ref_name == 'prod' && github.event.inputs.dry_run != 'true' + if: github.ref_name == 'prod' && github.event.inputs.dry_run != 'true' run: | logger -l info -m "Creating Git tag for production" @@ -133,7 +131,7 @@ jobs: git push origin "v${{ steps.version.outputs.version }}" - name: Commit version bump (prod only) - #if: github.ref_name == 'prod' && github.event.inputs.dry_run != 'true' + if: github.ref_name == 'prod' && github.event.inputs.dry_run != 'true' if: ${{ false }} run: | logger -l info -m "Committing version bump" @@ -149,7 +147,7 @@ jobs: git push origin prod - name: Sync version back to main (prod only) - # if: github.ref_name == 'prod' && github.event.inputs.dry_run != 'true' + if: github.ref_name == 'prod' && github.event.inputs.dry_run != 'true' if: ${{ false }} run: | logger -l info -m "Fetching latest main" @@ -183,7 +181,7 @@ jobs: fi - name: Create GitHub Release (prod only) - # if: github.ref_name == 'prod' && github.event.inputs.dry_run != 'true' + if: github.ref_name == 'prod' && github.event.inputs.dry_run != 'true' uses: softprops/action-gh-release@v2 with: name: Release v${{ steps.version.outputs.version }} @@ -203,7 +201,7 @@ jobs: ${{ steps.version.outputs.description }} - name: Checkout agents-ui repository - # if: github.ref_name == 'prod' && github.event.inputs.dry_run != 'true' + if: github.ref_name == 'prod' && github.event.inputs.dry_run != 'true' uses: actions/checkout@v6 with: repository: de-id/agents-ui @@ -211,7 +209,7 @@ jobs: path: agents-ui - name: Update SDK version and create PR - # if: github.ref_name == 'prod' && github.event.inputs.dry_run != 'true' + if: github.ref_name == 'prod' && github.event.inputs.dry_run != 'true' working-directory: agents-ui env: GH_TOKEN: ${{ secrets.DEVOPS_TOKEN }} From 1679768264eea0a1ee5e2785ab4929c9b0071c7b Mon Sep 17 00:00:00 2001 From: sharon-d-id Date: Mon, 26 Jan 2026 12:31:52 +0200 Subject: [PATCH 12/13] cleanups --- .github/workflows/publish-on-merge.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/publish-on-merge.yml b/.github/workflows/publish-on-merge.yml index fc5785d0..83833acb 100644 --- a/.github/workflows/publish-on-merge.yml +++ b/.github/workflows/publish-on-merge.yml @@ -132,7 +132,6 @@ jobs: - name: Commit version bump (prod only) if: github.ref_name == 'prod' && github.event.inputs.dry_run != 'true' - if: ${{ false }} run: | logger -l info -m "Committing version bump" @@ -148,7 +147,6 @@ jobs: - name: Sync version back to main (prod only) if: github.ref_name == 'prod' && github.event.inputs.dry_run != 'true' - if: ${{ false }} run: | logger -l info -m "Fetching latest main" git fetch origin main From 0df78e035aa386b8d2d3a8da1adf91b5c7884a5b Mon Sep 17 00:00:00 2001 From: Ofek Simhi Date: Mon, 26 Jan 2026 12:42:48 +0200 Subject: [PATCH 13/13] bump version 1.1.35 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6409435e..7673d168 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@d-id/client-sdk", "private": false, - "version": "1.1.34", + "version": "1.1.35", "type": "module", "description": "d-id client sdk", "repository": {