Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions .distignore
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions .github/workflows/lint-php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 7 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 }}
Expand All @@ -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: |
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
44 changes: 44 additions & 0 deletions tests/package.sh
Original file line number Diff line number Diff line change
@@ -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("<p>Hello <strong>world</strong>.</p>") !== "Hello **world**.") {
exit(1);
}
' "$package"
done

echo "Both archives exclude development files and retain working dependencies."
Loading