fix(release): repack zip root-level for the Composer registry #14
No files matched your search
@@ -98,19 +98,19 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
path: plugin-src
|
||||
# The cache key follows the Shopware version: a new 6.6.x release changes the key, so the old
|
||||
# project + database are never reused. Bump -v1 to force a refresh by hand.
|
||||
- name: Resolve the latest Shopware 6.6 version
|
||||
# The cache key follows the Shopware version: a new release inside the plugin's supported range changes
|
||||
# the key, so the old project + database are never reused. Bump -v1 to force a refresh by hand.
|
||||
- name: Resolve the latest Shopware Version
|
||||
id: sw
|
||||
run: |
|
||||
VERSION=$(php -r '
|
||||
$all = json_decode(file_get_contents("https://repo.packagist.org/p2/shopware/production.json"), true)["packages"]["shopware/production"];
|
||||
$v = [];
|
||||
foreach ($all as $p) { if (preg_match("/^6\.6\.\d+(\.\d+)*$/", $p["version"])) { $v[] = $p["version"]; } }
|
||||
usort($v, "version_compare");
|
||||
echo end($v);')
|
||||
test -n "$VERSION" || { echo "::error::could not resolve the Shopware 6.6 version"; exit 1; }
|
||||
echo "Shopware ${VERSION}"
|
||||
set -e
|
||||
# The plugin's own constraint (require.shopware/core, e.g. ~6.6.0) decides which versions are acceptable;
|
||||
# Composer lists the matching ones newest first, the first stable one is the latest.
|
||||
CONSTRAINT=$(php -r 'echo json_decode(file_get_contents("plugin-src/composer.json"), true)["require"]["shopware/core"];')
|
||||
VERSION=$(composer show shopware/core "$CONSTRAINT" --all --format=json --no-interaction 2>/dev/null \
|
||||
| php -r '$d = json_decode(stream_get_contents(STDIN), true); foreach ($d["versions"] as $v) { if (preg_match("/^v?\d+(\.\d+)+$/", $v)) { echo ltrim($v, "v"); exit; } }')
|
||||
test -n "$VERSION" || { echo "::error::could not resolve a Shopware version for ${CONSTRAINT}"; exit 1; }
|
||||
echo "Shopware ${VERSION} (constraint ${CONSTRAINT})"
|
||||
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
||||
# Project (vendor/, phpunit, config) and the installed database as a SQL dump. Neither depends on the plugin.
|
||||
- name: Restore Shopware project and database
|
||||
|
||||
@@ -126,7 +126,8 @@ jobs:
|
||||
fi
|
||||
test -f "$ROOT/composer.json" || { echo "::error::no composer.json found in the packaged zip"; exit 1; }
|
||||
OUT="$PWD/.build/composer-${{ steps.meta.outputs.zip }}"
|
||||
(cd "$ROOT" && zip -qr "$OUT" .)
|
||||
# explicit file list with the leading "./" stripped, so entries are stored as "composer.json", "src/..."
|
||||
(cd "$ROOT" && find . -mindepth 1 | sed 's|^\./||' | zip -q "$OUT" -@)
|
||||
unzip -l "$OUT" | grep -E ' composer\.json$' > /dev/null || { echo "::error::repacked zip has no root-level composer.json"; exit 1; }
|
||||
echo "repacked: $OUT"
|
||||
|
||||
|
||||
@@ -53,10 +53,10 @@ activates this plugin inside a real Shopware kernel for the test run (`KERNEL_CL
|
||||
`Shopware\Core\Kernel` in `phpunit.xml`). This means tests require a working Shopware installation/DB
|
||||
to bootstrap against — they are not runnable as an isolated PHP package.
|
||||
|
||||
In CI (`phpunit` job) the latest Shopware 6.6 version is resolved from Packagist and the prepared project
|
||||
(`composer create-project` + phpunit, then `system:install` into `shopware_test` on a MariaDB 10.11 service)
|
||||
plus a SQL dump of the installed database are cached under a key that contains that version, so a new
|
||||
Shopware release invalidates the cache. On a hit the dump is restored instead of reinstalling; the plugin
|
||||
In CI (`phpunit` job) the latest Shopware version allowed by the plugin's `require.shopware/core` constraint
|
||||
is resolved with Composer. The prepared project (`composer create-project` + phpunit, then `system:install`
|
||||
into `shopware_test` on a MariaDB 10.11 service) plus a SQL dump of the installed database are cached under
|
||||
a key that contains that version, so a new Shopware release invalidates the cache. On a hit the dump is restored instead of reinstalling; the plugin
|
||||
is then copied into `custom/plugins` and the bootstrapper only activates it.
|
||||
|
||||
```bash
|
||||
|
||||
Reference in new issue
Block a user