瀏覽代碼

Merge branch 'main' of https://github.com/transloadit/uppy

Artur Paikin 2 年之前
父節點
當前提交
b1b935a5f1

+ 30 - 24
.github/workflows/companion-deploy.yml

@@ -1,11 +1,34 @@
-name: Companion Deploy
+# N.B.: This won't run on releases because of
+# https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow.
+# However, we have a companion deploy that's part of the release.yml workflow.
+name: Companion Edge Deploy
 
 
 on:
 on:
   push:
   push:
-    tags:
-      - '@uppy/companion@*'
+    branches: [ 'main' ]
+    paths:
+      - yarn.lock
+      - 'packages/@uppy/companion/**'
+      - '.github/workflows/companion.yml'
 
 
 jobs:
 jobs:
+  npm:
+    name: Generate npm tarball
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout sources
+        uses: actions/checkout@v3
+      - name: Set SHA commit in version
+        run: (cd packages/@uppy/companion && node -e 'const pkg=require("./package.json");pkg.version+="+${{ github.sha }}";fs.writeFileSync("package.json",JSON.stringify(pkg, undefined, 2)+"\n")')
+      - name: Create Companion tarball
+        run: corepack yarn workspace @uppy/companion pack --install-if-needed -o /tmp/companion-${{ github.sha }}.tar.gz
+      - name: Upload artifact
+        if: success()
+        uses: actions/upload-artifact@v3
+        with:
+          name: companion-${{ github.sha }}.tar.gz
+          path: /tmp/companion-${{ github.sha }}.tar.gz
+
   docker:
   docker:
     name: DockerHub
     name: DockerHub
     runs-on: ubuntu-latest
     runs-on: ubuntu-latest
@@ -17,12 +40,12 @@ jobs:
         uses: actions/checkout@v3
         uses: actions/checkout@v3
       - name: Docker meta
       - name: Docker meta
         id: docker_meta
         id: docker_meta
-        uses: crazy-max/ghaction-docker-meta@v1
+        uses: docker/metadata-action@v4
         with:
         with:
           images: transloadit/companion
           images: transloadit/companion
-          tag-sha: true
-          tag-match: |
-            \d{1,3}.\d{1,3}.\d{1,3}
+          tags: |
+            type=edge
+            type=raw,value=latest,enable=false
       - uses: docker/setup-qemu-action@v2
       - uses: docker/setup-qemu-action@v2
       - uses: docker/setup-buildx-action@v2
       - uses: docker/setup-buildx-action@v2
       - name: Log in to DockerHub
       - name: Log in to DockerHub
@@ -39,20 +62,3 @@ jobs:
           file: Dockerfile
           file: Dockerfile
           tags: ${{ steps.docker_meta.outputs.tags }}
           tags: ${{ steps.docker_meta.outputs.tags }}
           labels: ${{ steps.docker_meta.outputs.labels }}
           labels: ${{ steps.docker_meta.outputs.labels }}
-
-  heroku:
-    name: Heroku
-    runs-on: ubuntu-latest
-    steps:
-      - name: Checkout sources
-        uses: actions/checkout@v3
-      - name: Alter dockerfile
-        run: |
-          sed -i 's/^EXPOSE 3020$/EXPOSE $PORT/g' Dockerfile
-      - name: Deploy to heroku
-        uses: akhileshns/heroku-deploy@v3.12.12
-        with:
-          heroku_api_key: ${{secrets.HEROKU_API_KEY}}
-          heroku_app_name: companion-demo
-          heroku_email: ${{secrets.HEROKU_EMAIL}}
-          usedocker: true

+ 63 - 0
.github/workflows/release.yml

@@ -7,6 +7,8 @@ jobs:
   release:
   release:
     name: Publish releases
     name: Publish releases
     if: ${{ github.event.review.state == 'approved' && github.event.sender.login == github.event.pull_request.assignee.login && github.event.pull_request.head.ref == 'release-candidate' }}
     if: ${{ github.event.review.state == 'approved' && github.event.sender.login == github.event.pull_request.assignee.login && github.event.pull_request.head.ref == 'release-candidate' }}
+    outputs:
+      companionWasReleased: ${{ steps.checkIfCompanionWasReleased.outputs.version }}
     runs-on: ubuntu-latest
     runs-on: ubuntu-latest
     steps:
     steps:
       - name: Checkout sources
       - name: Checkout sources
@@ -78,6 +80,9 @@ jobs:
         env:
         env:
           EDGLY_KEY: ${{secrets.EDGLY_KEY}}
           EDGLY_KEY: ${{secrets.EDGLY_KEY}}
           EDGLY_SECRET: ${{secrets.EDGLY_SECRET}}
           EDGLY_SECRET: ${{secrets.EDGLY_SECRET}}
+      - name: Check if Companion was released
+        id: checkIfCompanionWasReleased
+        run: git diff --exit-code --quiet HEAD^ -- packages/@uppy/companion/package.json || echo "::set-output name=version::$(jq .version < packages/@uppy/companion/package.json)"
       - name: Remove release-candidate branch
       - name: Remove release-candidate branch
         run: gh api -X DELETE repos/${{ github.repository }}/git/refs/heads/release-candidate || echo "Already deleted"
         run: gh api -X DELETE repos/${{ github.repository }}/git/refs/heads/release-candidate || echo "Already deleted"
         env:
         env:
@@ -95,3 +100,61 @@ jobs:
         run: gh pr comment ${{ github.event.pull_request.number }} --body "Release job failed, please take action."
         run: gh pr comment ${{ github.event.pull_request.number }} --body "Release job failed, please take action."
         env:
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+
+  # See also companion-deploy.yml
+  docker:
+    name: DockerHub
+    needs: release
+    if: ${{ needs.release.outputs.companionWasReleased }}
+    runs-on: ubuntu-latest
+    env:
+      DOCKER_BUILDKIT: 0
+      COMPOSE_DOCKER_CLI_BUILD: 0
+    steps:
+      - name: Checkout sources
+        uses: actions/checkout@v3
+      - name: Docker meta
+        id: docker_meta
+        uses: docker/metadata-action@v4
+        with:
+          images: transloadit/companion
+          tags: |
+            type=edge
+            type=semver,pattern={{version}},value=${{ needs.release.outputs.companionWasReleased }}
+            # set latest tag for default branch
+            type=raw,value=latest,enable=true
+      - uses: docker/setup-qemu-action@v2
+      - uses: docker/setup-buildx-action@v2
+      - name: Log in to DockerHub
+        uses: docker/login-action@v2
+        with:
+          username: ${{secrets.DOCKER_USERNAME}}
+          password: ${{secrets.DOCKER_PASSWORD}}
+      - name: Build and push
+        uses: docker/build-push-action@v3
+        with:
+          push: true
+          context: .
+          platforms: linux/amd64,linux/arm64
+          file: Dockerfile
+          tags: ${{ steps.docker_meta.outputs.tags }}
+          labels: ${{ steps.docker_meta.outputs.labels }}
+
+  heroku:
+    name: Heroku
+    needs: release
+    if: ${{ needs.release.outputs.companionWasReleased }}
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout sources
+        uses: actions/checkout@v3
+      - name: Alter dockerfile
+        run: |
+          sed -i 's/^EXPOSE 3020$/EXPOSE $PORT/g' Dockerfile
+      - name: Deploy to heroku
+        uses: akhileshns/heroku-deploy@v3.12.12
+        with:
+          heroku_api_key: ${{secrets.HEROKU_API_KEY}}
+          heroku_app_name: companion-demo
+          heroku_email: ${{secrets.HEROKU_EMAIL}}
+          usedocker: true

+ 2 - 0
packages/@uppy/dashboard/src/Dashboard.jsx

@@ -183,6 +183,8 @@ export default class Dashboard extends UIPlugin {
       activePickerPanel,
       activePickerPanel,
       activeOverlayType: 'PickerPanel',
       activeOverlayType: 'PickerPanel',
     })
     })
+
+    this.uppy.emit('dashboard:show-panel', id)
   }
   }
 
 
   canEditFile = (file) => {
   canEditFile = (file) => {

+ 3 - 1
packages/@uppy/dashboard/types/index.d.ts

@@ -88,11 +88,13 @@ export default Dashboard
 
 
 export type DashboardFileEditStartCallback<TMeta extends IndexedObject<any>> = (file?: UppyFile<TMeta>) => void;
 export type DashboardFileEditStartCallback<TMeta extends IndexedObject<any>> = (file?: UppyFile<TMeta>) => void;
 export type DashboardFileEditCompleteCallback<TMeta extends IndexedObject<any>> = (file?: UppyFile<TMeta>) => void;
 export type DashboardFileEditCompleteCallback<TMeta extends IndexedObject<any>> = (file?: UppyFile<TMeta>) => void;
+export type DashboardShowPlanelCallback = (id: string) => void;
 declare module '@uppy/core' {
 declare module '@uppy/core' {
   export interface UppyEventMap<TMeta> {
   export interface UppyEventMap<TMeta> {
     'dashboard:modal-open': GenericEventCallback
     'dashboard:modal-open': GenericEventCallback
     'dashboard:modal-closed': GenericEventCallback
     'dashboard:modal-closed': GenericEventCallback
-    'dashboard:file-edit-state': DashboardFileEditStartCallback<TMeta>
+    'dashboard:show-panel': DashboardShowPlanelCallback
+    'dashboard:file-edit-start': DashboardFileEditStartCallback<TMeta>
     'dashboard:file-edit-complete': DashboardFileEditCompleteCallback<TMeta>
     'dashboard:file-edit-complete': DashboardFileEditCompleteCallback<TMeta>
   }
   }
 }
 }

+ 5 - 1
packages/@uppy/dashboard/types/index.test-d.ts

@@ -52,10 +52,14 @@ import Dashboard from '..'
     onDragLeave: (event) => event.clientX,
     onDragLeave: (event) => event.clientX,
   })
   })
 
 
-  uppy.on('dashboard:file-edit-state', (file) => {
+  uppy.on('dashboard:file-edit-start', (file) => {
     // eslint-disable-next-line @typescript-eslint/no-unused-vars
     // eslint-disable-next-line @typescript-eslint/no-unused-vars
     const fileName = file?.name
     const fileName = file?.name
   })
   })
+  uppy.on('dashboard:show-panel', (id) => {
+    // eslint-disable-next-line @typescript-eslint/no-unused-vars
+    const pluginId = id
+  })
 }
 }
 
 
 {
 {

+ 1 - 1
website/src/_posts/2021-08-2.0.md

@@ -212,7 +212,7 @@ Plugins that add their own events can merge with existing ones in `@uppy/core` w
 
 
 <!-- eslint-disable @typescript-eslint/no-unused-vars -->
 <!-- eslint-disable @typescript-eslint/no-unused-vars -->
 ```ts
 ```ts
-uppy.on('dashboard:file-edit-state', (file) => {
+uppy.on('dashboard:file-edit-start', (file) => {
   const fileName = file.name
   const fileName = file.name
 })
 })
 ```
 ```

+ 8 - 0
website/src/docs/dashboard.md

@@ -508,6 +508,14 @@ uppy.on('dashboard:modal-open', () => {
 
 
 Fired when the Dashboard modal is closed.
 Fired when the Dashboard modal is closed.
 
 
+### `dashboard:show-panel`
+
+**Parameters:**
+
+* `id` — The unique identifier of the plugin that is being shown
+
+Fired when a user clicks on a source plugin, such as Webcam or Google Drive, in the Dashboard.
+
 ### `dashboard:file-edit-start`
 ### `dashboard:file-edit-start`
 
 
 **Parameters:**
 **Parameters:**

+ 1 - 1
website/src/docs/migration-guides.md

@@ -457,7 +457,7 @@ Plugins that add their own events can merge with existing ones in `@uppy/core` w
 <!-- eslint-disable @typescript-eslint/no-unused-vars -->
 <!-- eslint-disable @typescript-eslint/no-unused-vars -->
 
 
 ```ts
 ```ts
-uppy.on('dashboard:file-edit-state', (file) => {
+uppy.on('dashboard:file-edit-start', (file) => {
   const fileName = file.name
   const fileName = file.name
 })
 })
 ```
 ```