From 5a66153dfc63ee70c7a082cf569d07f6db59a304 Mon Sep 17 00:00:00 2001 From: Dan Ditomaso Date: Thu, 7 Aug 2025 11:31:14 -0400 Subject: [PATCH] add new packages github action. Bump package.json version (#762) --- .github/workflows/nightly.yml | 2 +- .github/workflows/release-packages.yml | 83 ++++++++ .github/workflows/release-web.yml | 79 ++++++++ .github/workflows/release.yml | 182 ------------------ packages/transport-http/jsr.json | 2 +- packages/transport-http/package.json | 2 +- packages/transport-web-bluetooth/jsr.json | 2 +- packages/transport-web-bluetooth/package.json | 2 +- packages/transport-web-serial/jsr.json | 2 +- packages/transport-web-serial/package.json | 2 +- 10 files changed, 169 insertions(+), 189 deletions(-) create mode 100644 .github/workflows/release-packages.yml create mode 100644 .github/workflows/release-web.yml delete mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 12c71c5b..a86a5718 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -73,7 +73,7 @@ jobs: uses: redhat-actions/buildah-build@v2 with: containerfiles: | - ./infra/Containerfile + ./packages/web/infra/Containerfile image: ${{ github.event.repository.full_name }} tags: nightly-${{ steps.get_release.outputs.tag }}-${{ github.sha }} diff --git a/.github/workflows/release-packages.yml b/.github/workflows/release-packages.yml new file mode 100644 index 00000000..eaeaeadd --- /dev/null +++ b/.github/workflows/release-packages.yml @@ -0,0 +1,83 @@ +name: Release Packages + +on: + workflow_dispatch: + inputs: + tag: + description: 'Release version (e.g. v1.2.3)' + required: true + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + # --- Setup Bun --- + - name: Setup Bun + uses: oven-sh/setup-bun@v2 + with: + bun-version: latest + + # --- Setup Deno --- + - name: Setup Deno + uses: denoland/setup-deno@v2 + with: + deno-version: v2.x + + # --- Cache Bun Dependencies --- + - name: Cache Bun Dependencies + uses: actions/cache@v4 + with: + path: | + ~/.bun/install/cache + packages/web/node_modules + key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }} + restore-keys: | + ${{ runner.os }}-bun- + + # --- Cache Deno Dependencies --- + - name: Cache Deno Dependencies + uses: actions/cache@v4 + with: + path: ~/.cache/deno + key: ${{ runner.os }}-deno-${{ hashFiles('**/deno.lock') }} + restore-keys: | + ${{ runner.os }}-deno- + + - name: Setup Node for npm publish + uses: actions/setup-node@v4 + with: + node-version: 22 + registry-url: 'https://registry.npmjs.org/' + + - name: Configure npm auth + run: npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} + + - name: Publish packages to npm and JSR + run: | + for dir in packages/*; do + echo "Processing $dir" + + cd $dir + + # Publish to npm if package.json exists + if [ -f "package.json" ]; then + echo "Publishing $dir to npm..." + npm publish --access public || echo "npm publish failed for $dir" + fi + + # Publish to JSR if jsr.json exists + if [ -f "jsr.json" ]; then + echo "Publishing $dir to jsr..." + deno publish || echo "JSR publish failed for $dir" + fi + + cd - > /dev/null + done + + - name: Tag release + run: | + git tag ${{ github.event.inputs.tag }} + git push origin ${{ github.event.inputs.tag }} diff --git a/.github/workflows/release-web.yml b/.github/workflows/release-web.yml new file mode 100644 index 00000000..b33a124d --- /dev/null +++ b/.github/workflows/release-web.yml @@ -0,0 +1,79 @@ +name: Release Web + +on: + release: + types: [released, prereleased] + +permissions: + contents: write + +jobs: + release-web: + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Bun + uses: oven-sh/setup-bun@v2 + with: + bun-version: latest + + - name: Cache Bun Dependencies + uses: actions/cache@v4 + with: + path: | + ~/.bun/install/cache + packages/web/node_modules + key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }} + restore-keys: | + ${{ runner.os }}-bun- + + - name: Run Web App Tests + working-directory: packages/web + run: bun run test + + - name: Create Web App Release Archive + working-directory: packages/web + run: bun run package + + - name: Upload Web App Archive + uses: actions/upload-artifact@v4 + with: + name: web-build + if-no-files-found: error + path: packages/web/dist/build.tar + + - name: Attach Web Archive to GitHub Release + run: gh release upload ${{ github.event.release.tag_name }} packages/web/dist/build.tar + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Build Container Image + id: build-container + uses: redhat-actions/buildah-build@v2 + with: + containerfiles: | + ./infra/Containerfile + image: ghcr.io/${{ github.repository }} + tags: latest, ${{ github.event.release.tag_name }} + oci: true + platforms: linux/amd64, linux/arm64 + + - name: Push Container to GHCR + id: push-to-registry + uses: redhat-actions/push-to-registry@v2 + with: + image: ${{ steps.build-container.outputs.image }} + tags: ${{ steps.build-container.outputs.tags }} + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Output Image URL + run: echo "🖼️ Image pushed to ${{ steps.push-to-registry.outputs.registry-paths }}" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 2a4a8730..00000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,182 +0,0 @@ -name: Release - -on: - release: - types: [released, prereleased] - -permissions: - id-token: write - contents: write - packages: write - -jobs: - build-and-publish: - runs-on: ubuntu-latest - steps: - # --- Checkout Code --- - - name: Checkout Code - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - # --- Setup Bun --- - - name: Setup Bun - uses: oven-sh/setup-bun@v2 - with: - bun-version: latest - - # --- Setup Deno --- - - name: Setup Deno - uses: denoland/setup-deno@v2 - with: - deno-version: v2.x - - # --- Cache Bun Dependencies --- - - name: Cache Bun Dependencies - uses: actions/cache@v4 - with: - path: | - ~/.bun/install/cache - packages/web/node_modules - key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }} - restore-keys: | - ${{ runner.os }}-bun- - - # --- Cache Deno Dependencies --- - - name: Cache Deno Dependencies - uses: actions/cache@v4 - with: - path: ~/.cache/deno - key: ${{ runner.os }}-deno-${{ hashFiles('**/deno.lock') }} - restore-keys: | - ${{ runner.os }}-deno- - - # --- Determine Changed Packages --- - - name: Get Changed Package Directories - id: changed_packages - uses: tj-actions/changed-files@v46 - with: - dir_names: true - files: packages/** - files_ignore: "packages/web/**,packages/transport-deno/npm/**" - - # --- Setup Node for NPM Publishing --- - - name: Setup Node.js - if: steps.changed_packages.outputs.all_changed_and_modified_files != '' - uses: actions/setup-node@v4 - with: - node-version: 22 - registry-url: "https://registry.npmjs.org" - - - name: Verify NPM Authentication - if: steps.changed_packages.outputs.all_changed_and_modified_files != '' - run: npm whoami - env: - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - - # --- Build and Publish Changed Packages --- - - name: Build and Publish Changed Packages - if: steps.changed_packages.outputs.all_changed_and_modified_files != '' - run: | - set -euo pipefail - - excluded=("packages/web" "packages/transport-deno" "packages/transport-node") - - for pkg_dir in ${{ steps.changed_packages.outputs.all_changed_and_modified_files }}; do - echo "🔍 Inspecting $pkg_dir" - - if printf '%s\n' "${excluded[@]}" | grep -q "^$pkg_dir$"; then - echo "⏭️ Skipping excluded package: $pkg_dir" - continue - fi - - if [[ -f "$pkg_dir/jsr.json" ]]; then - echo "🦕 Publishing to NPM: $pkg_dir" - bun run build:npm $pkg_dir - echo "📦 Publishing to JSR" - (cd "$pkg_dir" && deno publish --allow-dirty) - elif [[ -f "$pkg_dir/bun.lock" ]]; then - echo "🥖 Building with Bun: $pkg_dir" - (cd "$pkg_dir" && bun install && bun run build) - else - echo "❓ No recognizable build config in $pkg_dir — skipping" - continue - fi - - if [[ -d "$pkg_dir/npm" ]]; then - echo "📤 Publishing to NPM: $pkg_dir" - npm publish "$pkg_dir/npm" --access public - fi - done - env: - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - - - name: No Packages Changed - if: steps.changed_packages.outputs.all_changed_and_modified_files == '' - run: echo "✅ No changed packages detected. Skipping publish." - - # --- Web Package Specific Tasks --- - - name: Check for Web Package Changes - id: web_changes - run: | - if [[ "${{ steps.changed_packages.outputs.all_changed_and_modified_files }}" == *"packages/web"* ]]; then - echo "web_changed=true" >> $GITHUB_OUTPUT - else - echo "web_changed=false" >> $GITHUB_OUTPUT - fi - - - name: Run Web App Tests - if: steps.web_changes.outputs.web_changed == 'true' - working-directory: packages/web - run: bun run test - - - name: Create Web App Release Archive - if: steps.web_changes.outputs.web_changed == 'true' - working-directory: packages/web - run: bun run package - - - name: Upload Web App Archive - if: steps.web_changes.outputs.web_changed == 'true' - uses: actions/upload-artifact@v4 - with: - name: web-build - if-no-files-found: error - path: packages/web/dist/build.tar - - - name: Attach Web Archive to GitHub Release - if: steps.web_changes.outputs.web_changed == 'true' - run: gh release upload ${{ github.event.release.tag_name }} packages/web/dist/build.tar - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - # --- Build & Push Container Image --- - - name: Set up QEMU - if: steps.web_changes.outputs.web_changed == 'true' - uses: docker/setup-qemu-action@v3 - - - name: Build Container Image - if: steps.web_changes.outputs.web_changed == 'true' - id: build-container - uses: redhat-actions/buildah-build@v2 - with: - containerfiles: | - ./infra/Containerfile - image: ghcr.io/${{ github.repository }} - tags: latest, ${{ github.event.release.tag_name }} - oci: true - platforms: linux/amd64, linux/arm64 - - - name: Push Container to GHCR - if: steps.web_changes.outputs.web_changed == 'true' - id: push-to-registry - uses: redhat-actions/push-to-registry@v2 - with: - image: ${{ steps.build-container.outputs.image }} - tags: ${{ steps.build-container.outputs.tags }} - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Output Image URL - if: steps.web_changes.outputs.web_changed == 'true' - run: echo "🖼️ Image pushed to ${{ steps.push-to-registry.outputs.registry-paths }}" diff --git a/packages/transport-http/jsr.json b/packages/transport-http/jsr.json index b590bbae..20a03829 100644 --- a/packages/transport-http/jsr.json +++ b/packages/transport-http/jsr.json @@ -1,5 +1,5 @@ { "name": "@meshtastic/transport-http", - "version": "0.2.2", + "version": "0.2.3", "exports": "./mod.ts" } \ No newline at end of file diff --git a/packages/transport-http/package.json b/packages/transport-http/package.json index cc7d76f4..bd5c7818 100644 --- a/packages/transport-http/package.json +++ b/packages/transport-http/package.json @@ -1,6 +1,6 @@ { "name": "@meshtastic/transport-http", - "version": "0.2.2", + "version": "0.2.3", "description": "A transport layer for Meshtastic applications using HTTP.", "exports": {".": "./mod.ts"}, "tasks": { diff --git a/packages/transport-web-bluetooth/jsr.json b/packages/transport-web-bluetooth/jsr.json index de6aa307..2572dac0 100644 --- a/packages/transport-web-bluetooth/jsr.json +++ b/packages/transport-web-bluetooth/jsr.json @@ -1,5 +1,5 @@ { "name": "@meshtastic/transport-web-bluetooth", - "version": "0.1.3", + "version": "0.1.4", "exports": "./mod.ts" } \ No newline at end of file diff --git a/packages/transport-web-bluetooth/package.json b/packages/transport-web-bluetooth/package.json index c301f583..67544783 100644 --- a/packages/transport-web-bluetooth/package.json +++ b/packages/transport-web-bluetooth/package.json @@ -1,6 +1,6 @@ { "name": "@meshtastic/transport-web-bluetooth", - "version": "0.1.3", + "version": "0.1.4", "description": "A transport layer for Meshtastic applications using Web Bluetooth.", "exports": { ".": "./mod.ts" diff --git a/packages/transport-web-serial/jsr.json b/packages/transport-web-serial/jsr.json index f5cb5459..7e959330 100644 --- a/packages/transport-web-serial/jsr.json +++ b/packages/transport-web-serial/jsr.json @@ -1,5 +1,5 @@ { "name": "@meshtastic/transport-web-serial", - "version": "0.2.2", + "version": "0.2.3", "exports": "./mod.ts" } \ No newline at end of file diff --git a/packages/transport-web-serial/package.json b/packages/transport-web-serial/package.json index 2e000b31..db73d3d6 100644 --- a/packages/transport-web-serial/package.json +++ b/packages/transport-web-serial/package.json @@ -1,6 +1,6 @@ { "name": "@meshtastic/transport-web-serial", - "version": "0.2.2", + "version": "0.2.3", "description": "A transport layer for Meshtastic applications using Web Serial API.", "exports": { ".": "./mod.ts"