From e96809549a3f13c93d56e7858aeff4d7c44f129a Mon Sep 17 00:00:00 2001 From: Cristian Arrieta Date: Wed, 7 Jan 2026 11:32:34 -0500 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=94=A7=20[PB-1278]=20Implement=20auto?= =?UTF-8?q?mated=20deployment=20with=20developer-controlled=20versioning?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Change trigger from manual to automatic (push to main when package.json changes) - Add Docker-based version validation using semver package - Remove version bumping steps (developer controls version in PR) - Auto-detect pre-release tags from version format - Add registry-url for OIDC publishing - Update README with new deployment process --- .github/workflows/deploy.yml | 112 +++++++++++++++++++---------------- README.md | 54 ++++++++++------- 2 files changed, 95 insertions(+), 71 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 258b91a..2d83632 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,21 +1,11 @@ name: Deploy on: - workflow_dispatch: - inputs: - version_type: - description: 'Version bump type' - required: true - default: 'patch' - type: choice - options: - - patch - - minor - - major - tag: - description: 'Tag for pre-release (e.g., beta, alpha)' - required: false - type: string + push: + branches: + - main + paths: + - 'package.json' permissions: id-token: write @@ -34,8 +24,55 @@ jobs: - name: Checkout code uses: actions/checkout@v4 with: - fetch-depth: 0 - token: ${{ secrets.GITHUB_TOKEN }} + fetch-depth: 2 + + - name: Validate version increment + id: version_check + uses: docker://node:22-alpine + with: + entrypoint: /bin/sh + args: -c " + apk add --no-cache git && + CURRENT_VERSION=$(node -p \"require('./package.json').version\") && + git checkout HEAD~1 -- package.json 2>/dev/null && + PREVIOUS_VERSION=$(node -p \"require('./package.json').version\") || PREVIOUS_VERSION=\"0.0.0\" && + git checkout HEAD -- package.json && + echo \"current=$CURRENT_VERSION\" >> $GITHUB_OUTPUT && + echo \"previous=$PREVIOUS_VERSION\" >> $GITHUB_OUTPUT && + if [ \"$CURRENT_VERSION\" = \"$PREVIOUS_VERSION\" ]; then + echo \"❌ Version not changed (still $CURRENT_VERSION)\" && + exit 1 + fi && + npx --yes semver $CURRENT_VERSION -r \">$PREVIOUS_VERSION\" && + echo \"✅ Valid version increment: $PREVIOUS_VERSION → $CURRENT_VERSION\" + " + + - name: Parse version and determine tag + id: version + run: | + VERSION="${{ steps.version_check.outputs.current }}" + + # Extract pre-release tag if present + if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + # Stable version (e.g., "1.0.0") + TAG="latest" + IS_PRERELEASE="false" + elif [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+-([a-zA-Z]+) ]]; then + # Pre-release version (e.g., "1.0.0-beta.1") + TAG="${BASH_REMATCH[1]}" + IS_PRERELEASE="true" + else + echo "❌ Invalid version format: $VERSION" + exit 1 + fi + + echo "version=v$VERSION" >> $GITHUB_OUTPUT + echo "version_number=$VERSION" >> $GITHUB_OUTPUT + echo "tag=$TAG" >> $GITHUB_OUTPUT + echo "prerelease=$IS_PRERELEASE" >> $GITHUB_OUTPUT + + echo "📦 Version: $VERSION" + echo "🏷️ NPM Tag: $TAG" - name: Setup pnpm uses: pnpm/action-setup@v4 @@ -47,6 +84,7 @@ jobs: with: node-version: 22 cache: 'pnpm' + registry-url: 'https://registry.npmjs.org' - name: Install dependencies run: pnpm install --frozen-lockfile @@ -61,34 +99,6 @@ jobs: - name: Build library run: pnpm run build - - name: Configure Git - run: | - git config --local user.email "action@github.com" - git config --local user.name "GitHub Action" - - - name: Bump version - id: version - run: | - if [ -n "${{ inputs.tag }}" ]; then - # Pre-release version - NEW_VERSION=$(npm version pre${{ inputs.version_type }} --preid=${{ inputs.tag }} --no-git-tag-version) - echo "tag=${{ inputs.tag }}" >> $GITHUB_OUTPUT - else - # Regular version - NEW_VERSION=$(npm version ${{ inputs.version_type }} --no-git-tag-version) - echo "tag=latest" >> $GITHUB_OUTPUT - fi - echo "version=${NEW_VERSION}" >> $GITHUB_OUTPUT - echo "New version: ${NEW_VERSION}" - - - name: Commit version bump - run: | - git add package.json - git commit -m "chore: bump version to ${{ steps.version.outputs.version }}" - git tag ${{ steps.version.outputs.version }} - git push origin main - git push origin ${{ steps.version.outputs.version }} - - name: Publish to NPM run: npm publish --access public --tag ${{ steps.version.outputs.tag }} --provenance env: @@ -105,20 +115,20 @@ jobs: ## 📦 Installation ```bash - npm install @ubidots/react-html-canvas@${{ steps.version.outputs.version }} + npm install @ubidots/react-html-canvas@${{ steps.version.outputs.version_number }} # or - pnpm add @ubidots/react-html-canvas@${{ steps.version.outputs.version }} + pnpm add @ubidots/react-html-canvas@${{ steps.version.outputs.version_number }} ``` ## 🔗 Links - - [NPM Package](https://www.npmjs.com/package/@ubidots/react-html-canvas) + - [NPM Package](https://www.npmjs.com/package/@ubidots/react-html-canvas/v/${{ steps.version.outputs.version_number }}) - [Documentation](https://github.com/ubidots/react-html-canvas#readme) draft: false - prerelease: ${{ inputs.tag != '' }} + prerelease: ${{ steps.version.outputs.prerelease }} token: ${{ secrets.GITHUB_TOKEN }} - name: Deployment Summary run: | echo "✅ Successfully deployed ${{ steps.version.outputs.version }} to NPM" - echo "📦 Package: https://www.npmjs.com/package/@ubidots/react-html-canvas" - echo "🏷️ Tag: ${{ steps.version.outputs.tag }}" + echo "📦 Package: https://www.npmjs.com/package/@ubidots/react-html-canvas/v/${{ steps.version.outputs.version_number }}" + echo "🏷️ Tag: ${{ steps.version.outputs.tag }}" diff --git a/README.md b/README.md index 5dfd7f3..a5ae687 100644 --- a/README.md +++ b/README.md @@ -184,34 +184,48 @@ Runs on every PR and push to main/develop branches: #### Deployment Pipeline (`.github/workflows/deploy.yml`) -Manual deployment workflow with the following features: - -- **Manual Trigger**: Only runs when manually triggered from GitHub Actions -- **Version Selection**: Choose patch, minor, or major version bump -- **Pre-release Support**: Optional tag for beta/alpha releases -- **Quality Checks**: Full linting, testing, and build verification -- **Automated Versioning**: Bumps version and creates git tags -- **NPM Publishing**: Publishes to NPM with appropriate tags +Automated deployment workflow triggered when version changes are merged to main: + +- **Automatic Trigger**: Runs when package.json changes are pushed to main +- **Version Validation**: Docker-based validation ensures semantic version increments +- **Pre-release Detection**: Auto-detects pre-release tags from version format +- **Quality Checks**: Full linting, testing, and build verification before publish +- **NPM Publishing**: Uses OIDC trusted publishing with provenance attestation - **GitHub Release**: Creates release with installation instructions ### How to Deploy To deploy a new version: -1. Go to the **Actions** tab in GitHub -2. Select the **Deploy** workflow -3. Click **Run workflow** -4. Choose the version bump type (patch/minor/major) -5. Optionally add a pre-release tag (e.g., "beta") -6. Click **Run workflow** +1. **Update version in your PR**: + ```bash + # For stable releases + npm version patch # or minor, major + + # For pre-releases + npm version prerelease --preid=beta + ``` + +2. **Commit and create PR**: + ```bash + git add package.json + git commit -m "chore: bump version to vX.Y.Z" + git push + ``` + +3. **Merge to main**: + - Ensure all PR checks pass + - Merge the PR + +4. **Automatic deployment**: + - Workflow automatically publishes to npm + - GitHub release created automatically -The deployment will: +#### Version Formats -- Run all quality checks -- Bump the version in package.json -- Create a git tag -- Publish to NPM -- Create a GitHub release +- `1.0.0` → npm tag: `latest` +- `1.0.0-beta.1` → npm tag: `beta` +- `1.0.0-alpha.1` → npm tag: `alpha` ## License From d4cb2c5a3b1509c5e634ea93dd820016301d5d42 Mon Sep 17 00:00:00 2001 From: Cristian Arrieta Date: Wed, 7 Jan 2026 11:44:02 -0500 Subject: [PATCH 2/3] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Simplify=20deployment?= =?UTF-8?q?=20workflow=20-=20remove=20Docker=20validation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 32 ++++---------------------------- README.md | 1 - 2 files changed, 4 insertions(+), 29 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2d83632..fb1823f 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -24,41 +24,17 @@ jobs: - name: Checkout code uses: actions/checkout@v4 with: - fetch-depth: 2 + fetch-depth: 0 - - name: Validate version increment - id: version_check - uses: docker://node:22-alpine - with: - entrypoint: /bin/sh - args: -c " - apk add --no-cache git && - CURRENT_VERSION=$(node -p \"require('./package.json').version\") && - git checkout HEAD~1 -- package.json 2>/dev/null && - PREVIOUS_VERSION=$(node -p \"require('./package.json').version\") || PREVIOUS_VERSION=\"0.0.0\" && - git checkout HEAD -- package.json && - echo \"current=$CURRENT_VERSION\" >> $GITHUB_OUTPUT && - echo \"previous=$PREVIOUS_VERSION\" >> $GITHUB_OUTPUT && - if [ \"$CURRENT_VERSION\" = \"$PREVIOUS_VERSION\" ]; then - echo \"❌ Version not changed (still $CURRENT_VERSION)\" && - exit 1 - fi && - npx --yes semver $CURRENT_VERSION -r \">$PREVIOUS_VERSION\" && - echo \"✅ Valid version increment: $PREVIOUS_VERSION → $CURRENT_VERSION\" - " - - - name: Parse version and determine tag + - name: Extract version and determine tag id: version run: | - VERSION="${{ steps.version_check.outputs.current }}" + VERSION=$(node -p "require('./package.json').version") - # Extract pre-release tag if present if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - # Stable version (e.g., "1.0.0") TAG="latest" IS_PRERELEASE="false" elif [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+-([a-zA-Z]+) ]]; then - # Pre-release version (e.g., "1.0.0-beta.1") TAG="${BASH_REMATCH[1]}" IS_PRERELEASE="true" else @@ -72,7 +48,7 @@ jobs: echo "prerelease=$IS_PRERELEASE" >> $GITHUB_OUTPUT echo "📦 Version: $VERSION" - echo "🏷️ NPM Tag: $TAG" + echo "🏷️ NPM Tag: $TAG" - name: Setup pnpm uses: pnpm/action-setup@v4 diff --git a/README.md b/README.md index a5ae687..3869644 100644 --- a/README.md +++ b/README.md @@ -187,7 +187,6 @@ Runs on every PR and push to main/develop branches: Automated deployment workflow triggered when version changes are merged to main: - **Automatic Trigger**: Runs when package.json changes are pushed to main -- **Version Validation**: Docker-based validation ensures semantic version increments - **Pre-release Detection**: Auto-detects pre-release tags from version format - **Quality Checks**: Full linting, testing, and build verification before publish - **NPM Publishing**: Uses OIDC trusted publishing with provenance attestation From a074b05ec69290e8c0344b3b5b4714c8bf1528b6 Mon Sep 17 00:00:00 2001 From: Cristian Arrieta Date: Wed, 7 Jan 2026 11:45:25 -0500 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=92=84=20Fix=20prettier=20formatting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 3869644..425fc35 100644 --- a/README.md +++ b/README.md @@ -197,6 +197,7 @@ Automated deployment workflow triggered when version changes are merged to main: To deploy a new version: 1. **Update version in your PR**: + ```bash # For stable releases npm version patch # or minor, major @@ -206,6 +207,7 @@ To deploy a new version: ``` 2. **Commit and create PR**: + ```bash git add package.json git commit -m "chore: bump version to vX.Y.Z"