Test, build and release a Shopware 6 Plugin with GitLab CI - Part 2 - build

Insider Blog

In my previous post I described how to distribute a Shopware 6 plugin over GitLab Package registry.

When building our project using shopware-cli, the tool will look over all plugins and check if they need to be built and do so if needed. This is an unnecessary step.

Building manually

Building a plugin is as simple as running:

shopware-cli extension build .

In the plugin root directory.

There are some tweaks you can make, like:

  • constrain a shopware version
  • specify extra bundles
  • use esbuild

Please refer to the official documentation for detailed configuration.

The build process will create the following directories containing the compiled files:

  • src/Resources/app/storefront/dist/
  • src/Resources/public/static/

Build pipeline

We use the official shopware-cli docker image. To speed up the process, we take advantage of the CI caching system.

<plugin-root>/.gitlab-ci.yml
stages:
  - build

build:
  image:
    name: ghcr.io/shopware/shopware-cli:latest-php-8.2
    entrypoint: [""]
  stage: build
  variables:
    COMPOSER_CACHE_DIR: ${CI_PROJECT_DIR}/.composer
    npm_config_cache: ${CI_PROJECT_DIR}/.npm
  script:
    - shopware-cli extension build .
  cache:
    - key: $CI_JOB_NAME
      paths:
        - $COMPOSER_CACHE_DIR
        - $npm_config_cache
  rules:
    - if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
      when: never
    - if: $CI_COMMIT_BRANCH

Let's combine it with our release pipeline from the previous post.

It's important to pass the built artifacts over to the next job.

<plugin-root>/.gitlab-ci.yml
stages:
  - release
  - build

build:
  image:
    name: ghcr.io/shopware/shopware-cli:latest-php-8.2
    entrypoint: [""]
  stage: build
  variables:
    COMPOSER_CACHE_DIR: ${CI_PROJECT_DIR}/.composer
    npm_config_cache: ${CI_PROJECT_DIR}/.npm
  script:
    - shopware-cli extension build .
  cache:
    - key: $CI_JOB_NAME
      paths:
        - $COMPOSER_CACHE_DIR
        - $npm_config_cache
  artifacts:
    paths:
      - src/Resources/
  rules:
    - if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
      when: never
    - if: $CI_COMMIT_BRANCH

release:
  stage: release
  image:
    name: ghcr.io/voxpupuli/semantic-release:latest
    entrypoint: [""]
  interruptible: true
  script:
    - /docker-entrypoint.sh
  rules:
    - if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
      when: never
    - if: $CI_COMMIT_BRANCH

That's it!

This will:

  1. Build all the assets
  2. Pass them to the second job
  3. Run the release process as described previously

Author

Robert Juzak , B.Sc.

Characteristics

released:

March 26, 2026

categories:

What moves us, DevOps

Tags:

DevOps, Open Source, Shopware
previous article