diff --git a/.distignore b/.distignore index 7854fc1..3246257 100644 --- a/.distignore +++ b/.distignore @@ -1,18 +1,22 @@ -# Files left out of the release ZIP built by .github/workflows/release.yml. -# Patterns start with a slash so they only match at the plugin root and leave -# vendor/ exactly as committed. This list does not affect GitHub's own source -# archives of a tag. +# Files excluded from the release ZIP; keep in sync with .gitattributes. +# Composer runtime metadata, licenses and translations remain included. .DS_Store +/.git /.claude /.distignore /.env /.env.example -/.git -/.github +/.gitattributes /.gitignore +/.github /.planning /bin /logs +/tests +/composer.json +/composer.lock /phpstan-baseline.neon /phpstan.neon.dist -/tests +/vendor/**/.github +/vendor/**/composer.json +/vendor/**/phpstan.neon.dist diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..fe20788 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,20 @@ +# Keep GitHub source archives (used by automatic updates) installable and clean. +# Keep exclusions in sync with .distignore for the attached release ZIP. +/.claude export-ignore +/.distignore export-ignore +/.env export-ignore +/.env.example export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore +/.github export-ignore +/.planning export-ignore +/bin export-ignore +/logs export-ignore +/tests export-ignore +/composer.json export-ignore +/composer.lock export-ignore +/phpstan-baseline.neon export-ignore +/phpstan.neon.dist export-ignore +/vendor/**/.github export-ignore +/vendor/**/composer.json export-ignore +/vendor/**/phpstan.neon.dist export-ignore diff --git a/.github/workflows/lint-php.yml b/.github/workflows/lint-php.yml index 9598b31..dafd8d7 100644 --- a/.github/workflows/lint-php.yml +++ b/.github/workflows/lint-php.yml @@ -36,3 +36,7 @@ jobs: - name: Test rendering hooks run: php tests/run.php + + - name: Test distributable archives + if: matrix.php == '8.3' + run: bash tests/package.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8f470d5..7c4c132 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -61,7 +61,7 @@ jobs: grep -q '^\* ' "$RUNNER_TEMP/release-notes.md" echo "VERSION=$VERSION" >> "$GITHUB_ENV" - # vendor/ is committed and shipped as it is; it must hold no dev packages. + # vendor/ is committed; runtime files must hold no dev packages. - name: Check committed vendor has no dev packages run: .github/scripts/check-vendor.sh @@ -83,8 +83,8 @@ jobs: echo "$RUNNER_TEMP/bin" >> "$GITHUB_PATH" # Scan the packaged files, so the SBOM describes what the ZIP contains. - # Syft reads vendor/composer/installed.json and the production packages in - # composer.lock; at this version it leaves out the lock's packages-dev. + # Syft reads vendor/composer/installed.json; development manifests are + # excluded from the package. Keep installed.json for dependency metadata. - name: Generate SBOM env: RELEASE_TAG: ${{ github.ref_name }} @@ -93,7 +93,11 @@ jobs: cd "$RUNNER_TEMP/package" syft "dir:markdown-alternate" \ --source-name markdown-alternate --source-version "$VERSION" \ + --select-catalogers +php-composer-installed-cataloger \ -o "cyclonedx-json=$RUNNER_TEMP/dist/sbom-$RELEASE_TAG.json" + jq -r '.packages[] | [.name, .version] | @tsv' markdown-alternate/vendor/composer/installed.json | sort > "$RUNNER_TEMP/expected-packages.tsv" + jq -r '.components[] | select((.purl // "") | startswith("pkg:composer/")) | [.name, .version] | @tsv' "$RUNNER_TEMP/dist/sbom-$RELEASE_TAG.json" | sort > "$RUNNER_TEMP/sbom-packages.tsv" + diff -u "$RUNNER_TEMP/expected-packages.tsv" "$RUNNER_TEMP/sbom-packages.tsv" - name: Write checksums run: | diff --git a/README.md b/README.md index 716174a..0de01b0 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,15 @@ cd markdown-alternate composer install ``` +### Release packaging + +Automatic updates use GitHub's source archive, which applies `.gitattributes` +`export-ignore` rules. The attached release ZIP uses `.distignore`. Keep these +exclusion lists in sync: development files, Composer manifests, and dependency +GitHub configuration are omitted from both downloads. Runtime PHP, Composer's +generated autoloader and installed-package metadata, licenses, and translations +remain included. The release SBOM reads `vendor/composer/installed.json`. + ## Usage ### 1. Use `.md` URLs diff --git a/readme.txt b/readme.txt index d8e72f6..956e9e2 100644 --- a/readme.txt +++ b/readme.txt @@ -118,6 +118,8 @@ Yes, as an opt-in. With `add_filter( 'markdown_alternate_skip_noindexed', '__ret * Moved Markdown response handlers after default-priority access checks and canonical redirects * Added cache-isolation, response-header, and routing-order regression tests +* Excluded development files from GitHub source archives and release ZIPs while retaining runtime dependencies, licenses, and translations. + = 1.2.0 = * Added WooCommerce product metadata, formatted prices, short descriptions, visible attributes, and variations * Bypassed shared and HTTP caching for customer-dependent product output diff --git a/tests/package.sh b/tests/package.sh new file mode 100644 index 0000000..236ed19 --- /dev/null +++ b/tests/package.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash +# Verify both distribution paths contain the same installable plugin files. +# Run from a committed checkout with PHP, Git, rsync, unzip and diff available. +set -euo pipefail + +package_test_dir="$(mktemp -d)" +trap 'rm -rf "$package_test_dir"' EXIT +mkdir -p "$package_test_dir/archive" "$package_test_dir/release" +git archive --format=zip HEAD > "$package_test_dir/source.zip" +unzip -q "$package_test_dir/source.zip" -d "$package_test_dir/archive" +rsync -a --exclude-from=.distignore ./ "$package_test_dir/release/" +diff -r "$package_test_dir/archive" "$package_test_dir/release" + +for package in "$package_test_dir/archive" "$package_test_dir/release"; do + for excluded in .claude .distignore .env.example .git .gitattributes .github .gitignore .planning bin logs tests composer.json composer.lock phpstan-baseline.neon phpstan.neon.dist vendor/league/html-to-markdown/.github vendor/league/html-to-markdown/composer.json vendor/league/html-to-markdown/phpstan.neon.dist vendor/yahnis-elsts/plugin-update-checker/composer.json; do + if [[ -e "$package/$excluded" ]]; then + echo "Unexpected development file: $excluded" >&2 + exit 1 + fi + done + for required in markdown-alternate.php readme.txt LICENSE languages/markdown-alternate.pot vendor/composer/installed.json vendor/composer/installed.php vendor/composer/LICENSE vendor/league/html-to-markdown/LICENSE vendor/yahnis-elsts/plugin-update-checker/license.txt vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-nl_NL.mo; do + test -f "$package/$required" + done + php -r ' + require $argv[1] . "/vendor/autoload.php"; + foreach (array( + "MarkdownAlternate\\Plugin", + "MarkdownAlternate\\Output\\ContentRenderer", + "League\\HTMLToMarkdown\\HtmlConverter", + "YahnisElsts\\PluginUpdateChecker\\v5\\PucFactory", + ) as $class) { + if (!class_exists($class)) { + fwrite(STDERR, "Missing runtime class: " . $class . PHP_EOL); + exit(1); + } + } + $converter = new League\HTMLToMarkdown\HtmlConverter(); + if ($converter->convert("
Hello world.
") !== "Hello **world**.") { + exit(1); + } + ' "$package" +done + +echo "Both archives exclude development files and retain working dependencies."