
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.ymlstages:
- 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.ymlstages:
- 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:
- Build all the assets
- Pass them to the second job
- Run the release process as described previously
