Skip to content

Commit

Permalink
PNPM Migration and CI workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
eigenraven committed Oct 11, 2024
1 parent 5598358 commit 63bec69
Show file tree
Hide file tree
Showing 21 changed files with 4,970 additions and 8,479 deletions.
116 changes: 116 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
name: Build & Test
on:
push:
branches: [main]
pull_request:
branches: [main]

permissions:
contents: read
checks: write
statuses: write

jobs:
setup:
name: Setup
runs-on: ubuntu-24.04
steps:
- name: Create the commit status check
shell: bash
env:
GITHUB_TOKEN: ${{ github.token }}
STATUS_REPO: ${{ github.repository }}
STATUS_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
STATUS_STATE: pending
STATUS_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
set -x
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"/repos/${STATUS_REPO}/statuses/${STATUS_SHA}" \
-f "state=${STATUS_STATE}" \
-f "target_url=${STATUS_URL}" \
-f "description=PR Check Workflow" \
-f "context=IMG.LY"
test:
name: Test Node ${{ matrix.node-version }}
needs: [setup]
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
node-version:
- '18.x'
- '20.x'
- '22.x'
env:
CI_NODE_VERSION: ${{ matrix.node-version }}
CI_IS_PR: ${{ github.event_name == 'pull_request' }}
# In PRs, rebuild the changed packages, their dependents and dependencies only, unless the ci:build-all label is applied.
CI_PNPM_FILTER: ${{ (github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'ci:build-all')) && '...[origin/main]...' || '*' }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: true
- name: Install pnpm
uses: pnpm/action-setup@v4
- name: Use Node.js ${{ env.CI_NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.CI_NODE_VERSION }}
cache: 'pnpm'
- name: Install dependencies
run: pnpm recursive install --filter "$CI_PNPM_FILTER" --frozen-lockfile
- name: Build
shell: bash
run: pnpm recursive run --filter "$CI_PNPM_FILTER" build
- name: Run checks
shell: bash
run: pnpm recursive run --filter "$CI_PNPM_FILTER" check:all
- name: Test
shell: bash
run: pnpm recursive run --filter "$CI_PNPM_FILTER" test
- name: Package
if: success() || failure()
shell: bash
run: |
mkdir -p _ci_packs
pnpm recursive --filter "$CI_PNPM_FILTER" exec pnpm pack "--pack-destination=$PWD/_ci_packs"
- name: Upload packages
if: success() || failure()
uses: actions/upload-artifact@v4
with:
name: ${{ github.event.repository.name }}-npm-packages-node${{ env.CI_NODE_VERSION }}.zip
path: '_ci_packs/*.tgz'
if-no-files-found: ignore
overwrite: true

summary:
name: Summary test status
needs: [test]
if: always()
runs-on: ubuntu-24.04
steps:
- name: Update the commit status check
if: always()
shell: bash
env:
GITHUB_TOKEN: ${{ github.token }}
STATUS_REPO: ${{ github.repository }}
STATUS_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
STATUS_STATE: ${{ needs.test.result == 'success' && 'success' || 'failure' }}
STATUS_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
set -x
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"/repos/${STATUS_REPO}/statuses/${STATUS_SHA}" \
-f "state=${STATUS_STATE}" \
-f "target_url=${STATUS_URL}" \
-f "description=PR Check Workflow" \
-f "context=IMG.LY"
94 changes: 94 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Create release
on:
workflow_dispatch:
inputs:
package:
description: Package
required: true
type: choice
options:
- plugin-background-removal-web
- plugin-cutout-library-web
- plugin-remote-asset-source-web
- plugin-vectorizer-web
version:
description: Version number (e.g. 1.0.0)
required: true
type: string
npm_tag:
description: Custom NPM tag to update instead of latest
required: true
type: string
default: latest

permissions: write-all

jobs:
release:
name: Publish ${{ inputs.package }} ${{ inputs.version }}
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-24.04
env:
CI_NODE_VERSION: '20.x'
CI_IS_PR: false
CI_PNPM_FILTER: ${{ inputs.package }}
CI_PNPM_BUILD_FILTER: ${{ format('{0}...', inputs.package) }}
CI_PACKAGE_NAME: ${{ (inputs.package == '.') && github.event.repository.name || inputs.package }}
CI_PACKAGE_DIRECTORY: ${{ (inputs.package == '.') && '.' || format('./packages/{0}', inputs.package) }}
CI_VERSION_NUMBER: ${{ inputs.version }}
CI_TAG_NAME: ${{ (inputs.package == '.') && format('release/{0}', inputs.version) || format('release/{0}/{1}', inputs.package, inputs.version) }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: true
- name: Install pnpm
uses: pnpm/action-setup@v4
- name: Use Node.js ${{ env.CI_NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.CI_NODE_VERSION }}
cache: 'pnpm'
- name: Bump version
shell: bash
working-directory: ${{ env.CI_PACKAGE_DIRECTORY }}
run: |
set -x
git config --global user.name "Intergalactic Igor"
git config --global user.email "malte.baumann+bot@img.ly"
pnpm version "${CI_VERSION_NUMBER}"
git add -A
git commit -m "Release: ${CI_PACKAGE_NAME} ${CI_VERSION_NUMBER}"
git tag "${CI_TAG_NAME}"
- name: Install dependencies
run: pnpm recursive install --filter "$CI_PNPM_FILTER" --frozen-lockfile
- name: Build
shell: bash
run: pnpm recursive run --filter "$CI_PNPM_FILTER" build
- name: Package
if: success() || failure()
shell: bash
run: |
mkdir -p _ci_packs
pnpm recursive --filter "$CI_PNPM_FILTER" exec pnpm pack "--pack-destination=$PWD/_ci_packs"
- name: Upload package artifacts
if: success() || failure()
uses: actions/upload-artifact@v4
with:
name: ${{ github.event.repository.name }}-npm-packages-node${{ env.CI_NODE_VERSION }}.zip
path: '_ci_packs/*.tgz'
if-no-files-found: ignore
overwrite: true
- name: Push git tag
shell: bash
run: |
git push origin "${CI_TAG_NAME}"
- name: NPM publish
shell: bash
env:
NPM_TOKEN: ${{ secrets.IMGLY_NPM_AUTOMATION_TOKEN }}
CI_NPM_TAG: ${{ inputs.npm_tag }}
working-directory: ${{ env.CI_PACKAGE_DIRECTORY }}
run: |
npm config set "//registry.npmjs.org/:_authToken" "${NPM_TOKEN}"
pnpm publish --no-git-checks --tag "$CI_NPM_TAG"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ packages/*/dist
examples/*/dist
.env.local
.nvmrc
*.tgz

.DS_Store
yarn-error.log

.turbo
_ci_*
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ Plugins enhance the capabilities of [CreativeEditor SDK (CE.SDK)](https://img.ly
- Customization: Tailor the functionality of CE.SDK to meet specific needs.
- Compatibility: Designed to work seamlessly with the latest version of CE.SDK.

> [!WARNING]
> The plugin APIs are still in development and thus marked as unstable in CE.SDK. While it is perfectly safe to use the plugins for the specified CE.SDK versions, the APIs might change in the future. Please be aware, if you write your own plugin based on the code in this repository.
# Currently Available Plugins

For more information about the particular plugins, please visit the according packages in this repository.

- [Background Removal](packages/plugin-background-removal-web/)
- [Cutouts](packages/plugin-cutout-library-web/)
- [Remote Asset Source](packages/plugin-remote-asset-source-web/)
- [Vectorizer](packages/plugin-vectorizer-web/)
2 changes: 1 addition & 1 deletion esbuild/plugin-dts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const dtsPlugin = {
dtsStdio = undefined;
dtsResolved = false;
log('Generating types...');
exec('yarn types:create', (error, stdio) => {
exec('pnpm run types:create', (error, stdio) => {
if (error) {
dtsError = error;
dtsStdio = stdio;
Expand Down
8 changes: 4 additions & 4 deletions examples/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
"version": "0.0.0",
"type": "module",
"scripts": {
"build": "tsc && vite build --force",
"build": "tsc && vite build",
"clean": "npx rimraf dist",
"purge": "npx rimraf node_modules",
"dev": "vite --clearScreen=false --force",
"check:types": "tsc --noEmit"
},
"dependencies": {
"@imgly/plugin-background-removal-web": "*",
"@imgly/plugin-cutout-library-web": "*",
"@imgly/plugin-remote-asset-source-web": "*",
"@imgly/plugin-background-removal-web": "workspace:*",
"@imgly/plugin-cutout-library-web": "workspace:*",
"@imgly/plugin-remote-asset-source-web": "workspace:*",
"@cesdk/cesdk-js": "^1.32.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down
Loading

0 comments on commit 63bec69

Please sign in to comment.