diff --git a/.github/actions/setup-and-build/action.yml b/.github/actions/setup-and-build/action.yml deleted file mode 100644 index 5ee56c5982f..00000000000 --- a/.github/actions/setup-and-build/action.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: 'Setup Environment and Build Project' -description: 'Sets up Node.js with pnpm, installs dependencies, (optional) enables Turborepo caching, and (optional) builds the project.' - -inputs: - node-version: - description: 'Node.js version to use.' - required: false - default: '22.x' - enable-caching: - description: 'Flag to enable/disable all caching.' - required: false - default: 'true' - cache-suffix: - description: 'Suffix to add to the cache key.' - required: false - default: 'base:build' - skip-build: - description: 'Skip the build step, useful when restoring cached artifacts.' - required: false - default: 'false' - cache-paths: - description: 'Paths to cache. Defaults to dist folders.' - required: false - default: './packages/**/dist' - -runs: - using: 'composite' - steps: - - name: Setup pnpm CLI - uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 - with: - run_install: false - - - name: Setup Node.js - uses: useblacksmith/setup-node@65c6ca86fdeb0ab3d85e78f57e4f6a7e4780b391 # v5.0.4 - with: - node-version: ${{ inputs.node-version }} - cache: pnpm - - - name: Install dependencies - run: pnpm install --frozen-lockfile - shell: bash - - - name: Configure Turborepo Cache - if: inputs.enable-caching == 'true' - uses: useblacksmith/caching-for-turbo@v1 - - - name: Build packages - if: inputs.skip-build == 'false' - run: pnpm build - shell: bash - - - name: Cache artifacts - if: inputs.enable-caching == 'true' && inputs.skip-build == 'false' - uses: useblacksmith/cache@c5fe29eb0efdf1cf4186b9f7fcbbcbc0cf025662 # v5.0.2 - with: - path: ${{ inputs.cache-paths }} - key: ${{ github.sha }}-${{ inputs.cache-suffix }} diff --git a/.github/actions/setup-nodejs-github/action.yml b/.github/actions/setup-nodejs-github/action.yml new file mode 100644 index 00000000000..89a0b82aaf8 --- /dev/null +++ b/.github/actions/setup-nodejs-github/action.yml @@ -0,0 +1,33 @@ +name: 'GitHub Node.js Build Setup for Github Hosted Runners' +description: 'Configures Node.js with pnpm, installs dependencies, enables Turborepo caching, and builds the project or an optional command.' + +inputs: + node-version: + description: 'Node.js version to use. Uses latest 22.x by default.' + required: false + default: '22.x' + build-command: + description: 'Command to execute for building the project or an optional command. Leave empty to skip build step.' + required: false + default: 'pnpm build' + type: string + +runs: + using: 'composite' + steps: + - name: Setup Node.js + uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 + with: + node-version: ${{ inputs.node-version }} + + - name: Setup pnpm and Install Dependencies + uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 + with: + run_install: true + + - name: Configure Turborepo Cache + uses: rharkor/caching-for-turbo@2b4b5b14a8d16b8556a58993a8ac331d56d8906d # v2.3.2 + + - name: Build Project + run: ${{ inputs.build-command }} + shell: bash diff --git a/.github/workflows/ci-master.yml b/.github/workflows/ci-master.yml index bee87a74d98..f1055fadb0a 100644 --- a/.github/workflows/ci-master.yml +++ b/.github/workflows/ci-master.yml @@ -8,6 +8,15 @@ on: - packages/@n8n/task-runner-python/** jobs: + build-github: + name: Build for Github Cache + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Setup and Build + uses: ./.github/actions/setup-nodejs-github + unit-test: name: Unit tests uses: ./.github/workflows/units-tests-reusable.yml @@ -30,7 +39,7 @@ jobs: notify-on-failure: name: Notify Slack on failure runs-on: ubuntu-latest - needs: [unit-test, lint] + needs: [unit-test, lint, build-github] steps: - name: Notify Slack on failure uses: act10ns/slack@44541246747a30eb3102d87f7a4cc5471b0ffb7d # v2.1.0 diff --git a/.github/workflows/release-publish.yml b/.github/workflows/release-publish.yml index b7749817f28..da71addfa7f 100644 --- a/.github/workflows/release-publish.yml +++ b/.github/workflows/release-publish.yml @@ -8,29 +8,9 @@ on: - 'release/*' env: - BUILD_DIST_NAME: build-dist-${{ github.sha }} + BUILD_DIST_NAME: ${{ github.sha }}-release:build + jobs: - build-amd64: - runs-on: blacksmith-4vcpu-ubuntu-2204 - if: github.event.pull_request.merged == true - - steps: - - name: Checkout - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - fetch-depth: 0 - - - name: Setup Environment - uses: ./.github/actions/setup-nodejs-blacksmith - - - name: Upload build artifacts - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 - with: - name: ${{ env.BUILD_DIST_NAME }} - path: ./packages/**/dist - if-no-files-found: error - retention-days: 7 - build-arm64: runs-on: blacksmith-4vcpu-ubuntu-2204-arm if: github.event.pull_request.merged == true @@ -38,16 +18,14 @@ jobs: steps: - name: Checkout uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - fetch-depth: 0 + - name: Setup and Build ARM64 uses: ./.github/actions/setup-nodejs-blacksmith publish-to-npm: name: Publish to NPM - needs: build-amd64 runs-on: ubuntu-latest - timeout-minutes: 15 + timeout-minutes: 20 permissions: id-token: write env: @@ -56,29 +34,20 @@ jobs: release: ${{ steps.set-release.outputs.release }} steps: - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - with: - fetch-depth: 0 - - - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 - with: - node-version: 22.x - - - name: Setup corepack and pnpm - run: | - npm i -g corepack@0.33 - corepack enable - - - run: pnpm install --frozen-lockfile + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Set release version in env run: echo "RELEASE=$(node -e 'console.log(require("./package.json").version)')" >> "$GITHUB_ENV" - - name: Download build artifacts - uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 + - name: Setup and Build + uses: ./.github/actions/setup-nodejs-github + + - name: Upload build artifacts + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: name: ${{ env.BUILD_DIST_NAME }} - path: . + path: ./packages/**/dist + retention-days: 7 - name: Dry-run publishing run: | @@ -151,7 +120,7 @@ jobs: SENTRY_ORG: ${{ secrets.SENTRY_ORG }} steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Download build artifacts uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 diff --git a/.github/workflows/release-standalone-package.yml b/.github/workflows/release-standalone-package.yml index 13e7218bc70..feae4419f56 100644 --- a/.github/workflows/release-standalone-package.yml +++ b/.github/workflows/release-standalone-package.yml @@ -16,58 +16,12 @@ concurrency: group: release-package-${{ github.event.inputs.package }} cancel-in-progress: false +env: + CACHE_KEY: ${{ github.sha }}-${{ github.event.inputs.package }}-build + jobs: - validate: - runs-on: ubuntu-latest - steps: - - name: Validate branch - run: | - if [[ "${{ github.ref }}" != "refs/heads/master" ]]; then - echo "❌ This workflow can only be run from the master branch" - echo "Current branch: ${{ github.ref }}" - exit 1 - fi - echo "✅ Running from master branch" - - build: - needs: validate - runs-on: blacksmith-4vcpu-ubuntu-2204 - timeout-minutes: 15 - outputs: - artifact-name: ${{ steps.sanitize.outputs.result }} - - steps: - - name: Create sanitized artifact name - id: sanitize - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 - with: - result-encoding: string - script: | - const packageName = '${{ github.event.inputs.package }}'; - const sanitizedName = packageName.replace(/[/:@"]/g, '-'); - return `${{ github.sha }}-${sanitizedName}-build`; - - - name: Checkout - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - fetch-depth: 0 - - - name: Setup Environment - uses: ./.github/actions/setup-nodejs-blacksmith - with: - build-command: 'pnpm --filter "...${{ github.event.inputs.package }}" run --if-present build' - - - name: Upload build artifacts - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 - with: - name: ${{ steps.sanitize.outputs.result }} - path: ./packages/**/dist - if-no-files-found: error - retention-days: 7 - - publish: + publish-to-npm: name: Publish to NPM - needs: build runs-on: ubuntu-latest timeout-minutes: 15 permissions: @@ -76,29 +30,19 @@ jobs: NPM_CONFIG_PROVENANCE: true steps: + - name: Check branch + if: github.ref != 'refs/heads/master' + run: | + echo "::error::This workflow can only be run from the master branch" + exit 1 + - name: Checkout uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Setup and Build + uses: ./.github/actions/setup-nodejs-github with: - fetch-depth: 0 - - - name: Setup Node.js - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 - with: - node-version: 22.x - - - name: Setup corepack and pnpm - run: | - npm i -g corepack@0.33 - corepack enable - - - name: Install dependencies - run: pnpm install --frozen-lockfile - - - name: Download build artifacts - uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 - with: - name: ${{ needs.build.outputs.artifact-name }} - path: . + build-command: 'pnpm turbo build --filter "...${{ github.event.inputs.package }}"' - name: Pre publishing changes run: |