move creator-hub to packages/@dcl #71
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Creator Hub CI/CD | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| inspector-package-url: | |
| description: "Uploaded inspector package url" | |
| required: true | |
| type: string | |
| push: | |
| branches: | |
| - main | |
| - experimental | |
| pull_request: | |
| release: | |
| types: | |
| - created | |
| concurrency: | |
| group: creator-hub-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| WORKING_DIRECTORY: packages/@dcl/creator-hub | |
| jobs: | |
| # ============================================================================ | |
| # Code Quality Jobs | |
| # ============================================================================ | |
| lint: | |
| name: Lint & Code Style | |
| runs-on: ubuntu-latest | |
| if: github.event_name != 'workflow_dispatch' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| cache: 'npm' | |
| cache-dependency-path: ${{ env.WORKING_DIRECTORY }}/package-lock.json | |
| - name: Install dependencies | |
| run: npm ci | |
| working-directory: ${{ env.WORKING_DIRECTORY }} | |
| env: | |
| PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1 | |
| - name: Run ESLint | |
| run: npm run lint --if-present | |
| working-directory: ${{ env.WORKING_DIRECTORY }} | |
| - name: Check code style with Prettier | |
| run: | | |
| npm i prettier | |
| npx prettier --check "**/*.{js,mjs,cjs,jsx,ts,mts,cts,tsx,vue}" | |
| working-directory: ${{ env.WORKING_DIRECTORY }} | |
| typechecking: | |
| name: TypeScript Type Checking | |
| runs-on: ubuntu-latest | |
| if: github.event_name != 'workflow_dispatch' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| cache: 'npm' | |
| cache-dependency-path: ${{ env.WORKING_DIRECTORY }}/package-lock.json | |
| - name: Install dependencies | |
| run: npm ci | |
| working-directory: ${{ env.WORKING_DIRECTORY }} | |
| env: | |
| PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1 | |
| - name: Run TypeScript type checking | |
| run: npm run typecheck --if-present | |
| working-directory: ${{ env.WORKING_DIRECTORY }} | |
| # ============================================================================ | |
| # Testing Jobs | |
| # ============================================================================ | |
| tests: | |
| name: Run Tests | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ macos-latest, windows-latest ] | |
| runs-on: ${{ matrix.os }} | |
| if: github.event_name != 'workflow_dispatch' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| cache: 'npm' | |
| cache-dependency-path: ${{ env.WORKING_DIRECTORY }}/package-lock.json | |
| - name: Install dependencies | |
| run: npm ci | |
| working-directory: ${{ env.WORKING_DIRECTORY }} | |
| env: | |
| PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1 | |
| - name: Run main tests | |
| run: npm run test:main --if-present | |
| working-directory: ${{ env.WORKING_DIRECTORY }} | |
| - name: Run preload tests | |
| run: npm run test:preload --if-present | |
| working-directory: ${{ env.WORKING_DIRECTORY }} | |
| - name: Run renderer tests | |
| run: npm run test:renderer --if-present | |
| working-directory: ${{ env.WORKING_DIRECTORY }} | |
| - name: Run E2E tests | |
| if: env.ENABLE_E2E_TESTS == 'true' | |
| run: npm run build && npx vitest run | |
| working-directory: ${{ env.WORKING_DIRECTORY }} | |
| env: | |
| NODE_OPTIONS: "--max-old-space-size=8192" | |
| ENABLE_E2E_TESTS: true | |
| # ============================================================================ | |
| # PR Preview Jobs (Only run on pull requests) | |
| # ============================================================================ | |
| pr-preview: | |
| name: Creator Hub Build | |
| strategy: | |
| fail-fast: true | |
| matrix: | |
| os: [ macos-latest, windows-latest ] | |
| runs-on: ${{ matrix.os }} | |
| if: github.event_name == 'workflow_dispatch' | |
| env: | |
| WORKING_DIRECTORY: packages/@dcl/creator-hub | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: 'npm' | |
| - name: Install @dcl/inspector@branch package | |
| run: npm install "${{ secrets.SDK_TEAM_S3_BASE_URL }}/${{ github.event.inputs.inspector-package-url }}" | |
| working-directory: ${{ env.WORKING_DIRECTORY }} | |
| env: | |
| PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1 | |
| - name: 'Install dependencies' | |
| run: npm ci | |
| working-directory: ${{ env.WORKING_DIRECTORY }} | |
| env: | |
| PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1 | |
| - name: 'Build' | |
| run: echo MODE=$MODE && npm run build | |
| working-directory: ${{ env.WORKING_DIRECTORY }} | |
| env: | |
| NODE_OPTIONS: "--max-old-space-size=8192" | |
| MODE: ${{ !github.event.pull_request.number && 'production' || 'development' }} | |
| VITE_SEGMENT_CREATORS_HUB_API_KEY: ${{ secrets.VITE_SEGMENT_CREATORS_HUB_API_KEY }} | |
| VITE_SEGMENT_INSPECTOR_API_KEY: ${{ secrets.VITE_SEGMENT_INSPECTOR_API_KEY }} | |
| VITE_ALLOWED_EXTERNAL_ORIGINS: ${{ secrets.VITE_ALLOWED_EXTERNAL_ORIGINS }} | |
| # Sentry AUTH Token | |
| SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
| VITE_SENTRY_DSN: ${{ secrets.SENTRY_DSN }} | |
| - name: Get latest Creator Hub release version (or fallback to last version before migration to monorepo) | |
| id: latest_version | |
| shell: bash | |
| run: | | |
| TAG=$(gh release list --limit 100 | grep '^creator-hub-v' | head -n 1 | awk '{print $1}' || true) | |
| if [[ -z "$TAG" ]]; then | |
| echo "No previous creator-hub release found. Defaulting to 0.21.1" | |
| VERSION="0.21.1" | |
| else | |
| VERSION=${TAG#"creator-hub-v"} | |
| fi | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Bump latest release version (patch) | |
| id: new_version | |
| shell: bash | |
| run: | | |
| VERSION=${{ steps.latest_version.outputs.version }} | |
| IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION" | |
| PATCH=$((PATCH + 1)) | |
| NEW_VERSION="$MAJOR.$MINOR.$PATCH" | |
| echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT | |
| - name: Create custom tag before build | |
| if: github.ref == 'refs/heads/main' && !github.event.pull_request | |
| shell: bash | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git tag creator-hub-v${{ steps.new_version.outputs.new_version }} | |
| git push origin creator-hub-v${{ steps.new_version.outputs.new_version }} | |
| # Download 'SSLcom/esigner-codesign' to a folder called 'esigner-codesign' inside creator-hub package | |
| - name: Checkout esigner-codesign repository (Windows) | |
| if: ${{github.ref == 'refs/heads/main' && matrix.os == 'windows-latest' && !github.event.pull_request.number}} | |
| uses: actions/checkout@v3 | |
| with: | |
| repository: 'SSLcom/esigner-codesign' | |
| path: ${{ env.WORKING_DIRECTORY }}/esigner-codesign | |
| - name: Compile artifacts ${{ github.event.pull_request.number && ' ' || 'and upload them to github release' }} | |
| # I use this action because it is capable of retrying multiple times if there are any issues with the distribution server | |
| uses: nick-fields/retry@v3 | |
| with: | |
| timeout_minutes: 60 | |
| max_attempts: 6 | |
| retry_wait_seconds: 15 | |
| retry_on: error | |
| shell: 'bash' | |
| command: npx electron-builder --project ${{ env.WORKING_DIRECTORY }} --config electron-builder.cjs --config.extraMetadata.version=${{ steps.new_version.outputs.new_version }} ${{ matrix.os == 'macos-latest' && format('--config.mac.notarize={0}', true) || '' }} --publish ${{ github.event.pull_request.number && 'never' || 'always' }} | |
| env: | |
| # Disable hard links to avoid issues with npm | |
| USE_HARD_LINKS: false | |
| # Code Signing params | |
| # See https://www.electron.build/code-signing | |
| CSC_LINK: ${{ secrets.MACOS_CSC_LINK }} | |
| CSC_KEY_PASSWORD: ${{ secrets.MACOS_CSC_KEY_PASSWORD }} | |
| # Notarization params | |
| # See https://www.electron.build/configuration/mac#NotarizeNotaryOptions | |
| APPLE_ID: ${{ secrets.MACOS_NOTARIZATION_APPLE_ID }} | |
| APPLE_TEAM_ID: ${{ secrets.MACOS_NOTARIZATION_TEAM_ID }} | |
| APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.MACOS_NOTARIZATION_PWD }} | |
| # Publishing artifacts | |
| GH_TOKEN: ${{ secrets.github_token }} # GitHub token, automatically provided (No need to define this secret in the repo settings) | |
| EP_PRE_RELEASE: true # Publish as pre-release | |
| # The following are the parameters required by the esigner-codesign action to work, we must explicitly pass in even the optional ones since we're not using the action directly, but from the checked out repo | |
| CODE_SIGN_SCRIPT_PATH: ${{ matrix.os == 'windows-latest' && format('{0}\\esigner-codesign\\dist\\index.js', github.workspace) || '' }} | |
| INPUT_COMMAND: "sign" | |
| INPUT_FILE_PATH: "${{ github.workspace }}\\dist\\Decentraland Creator Hub-${{ steps.new_version.outputs.new_version }}-win-x64.exe" | |
| INPUT_OVERRIDE: "true" | |
| INPUT_MALWARE_BLOCK: "false" | |
| INPUT_CLEAN_LOGS: "false" | |
| INPUT_JVM_MAX_MEMORY: "1024M" | |
| INPUT_ENVIRONMENT_NAME: "PROD" | |
| INPUT_USERNAME: ${{ secrets.ES_USERNAME }} | |
| INPUT_PASSWORD: ${{ secrets.ES_PASSWORD }} | |
| INPUT_TOTP_SECRET: ${{ secrets.ES_TOTP_SECRET }} | |
| INPUT_CREDENTIAL_ID: ${{ secrets.WINDOWS_CREDENTIAL_ID_SIGNER }} | |
| - name: Move artifacts to upload folder | |
| if: ${{ github.event.pull_request.number }} | |
| working-directory: ${{ env.WORKING_DIRECTORY }} | |
| run: sh -c 'mkdir dist/upload && cp dist/*.dmg dist/*.exe dist/upload 2> /dev/null || :' | |
| - name: Upload to S3 | |
| if: ${{ github.event.pull_request.number }} | |
| id: upload | |
| working-directory: ${{ env.WORKING_DIRECTORY }} | |
| env: | |
| AWS_ACCESS_KEY_ID: ${{ secrets.SDK_TEAM_AWS_ID }} | |
| AWS_SECRET_ACCESS_KEY: ${{ secrets.SDK_TEAM_AWS_SECRET }} | |
| run: | | |
| npx @dcl/cdn-uploader@next --bucket ${{ secrets.SDK_TEAM_S3_BUCKET }} --local-folder dist/upload --bucket-folder creator-hub/branch/${{ github.head_ref }} | |
| - name: Set specific windows instructions | |
| if: ${{ github.event.pull_request.number && matrix.os == 'windows-latest' }} | |
| id: windows-instructions | |
| shell: bash | |
| run: | | |
| echo "list<<EOF" >> $GITHUB_ENV | |
| echo "[win-x64](${{ secrets.SDK_TEAM_S3_BASE_URL }}/creator-hub/branch/${{ github.head_ref }}/Decentraland%20Creator%20Hub-${{ steps.new_version.outputs.new_version }}-win-x64.exe)" >> $GITHUB_ENV | |
| echo "EOF" >> $GITHUB_ENV | |
| - name: Set specific macos instructions | |
| if: ${{ github.event.pull_request.number && matrix.os == 'macos-latest' }} | |
| id: macos-instructions | |
| run: | | |
| echo "list<<EOF" >> $GITHUB_ENV | |
| echo "[mac-x64](${{ secrets.SDK_TEAM_S3_BASE_URL }}/creator-hub/branch/${{ github.head_ref }}/Decentraland%20Creator%20Hub-${{ steps.new_version.outputs.new_version }}-mac-x64.dmg)" >> $GITHUB_ENV | |
| echo "[mac-arm64](${{ secrets.SDK_TEAM_S3_BASE_URL }}/creator-hub/branch/${{ github.head_ref }}/Decentraland%20Creator%20Hub-${{ steps.new_version.outputs.new_version }}-mac-arm64.dmg)" >> $GITHUB_ENV | |
| echo "EOF" >> $GITHUB_ENV | |
| content=$(cat ./.github/workflows/creator-hub-macos-instructions.md) | |
| echo "macos-instructions<<EOF" >> $GITHUB_ENV | |
| echo "$content" >> $GITHUB_ENV | |
| echo "EOF" >> $GITHUB_ENV | |
| - name: Find Comment | |
| if: ${{ github.event.pull_request.number }} | |
| uses: peter-evans/find-comment@v1 | |
| id: fc | |
| with: | |
| issue-number: ${{ github.event.pull_request.number }} | |
| comment-author: 'github-actions[bot]' | |
| body-includes: Test this pull request on ${{ matrix.os }} | |
| - name: Create or update comment | |
| if: ${{ github.event.pull_request.number }} | |
| uses: peter-evans/create-or-update-comment@v1 | |
| with: | |
| comment-id: ${{ steps.fc.outputs.comment-id }} | |
| issue-number: ${{ github.event.pull_request.number }} | |
| body: | | |
| # Test this pull request on ${{ matrix.os }} | |
| #### Download the correct version for your architecture: | |
| ${{ env.list }} | |
| ${{ env.macos-instructions }} | |
| edit-mode: replace |