Skip to content

Commit d5ca58c

Browse files
authored
ci: publish version.json on GitHub Pages and rebuild on release (#1248)
Expose the latest CLI version as version.json from the config schema Pages site, and redeploy whenever a release is published so consumers can resolve the current version without scraping GitHub.
1 parent ed4a8c6 commit d5ca58c

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

.github/workflows/schema-pages.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ on:
77
- 'internal/shop/config_schema.json'
88
- 'internal/extension/config_schema.json'
99
- '.github/workflows/schema-pages.yml'
10+
release:
11+
types: [published]
1012
workflow_dispatch:
1113

1214
permissions:
@@ -34,11 +36,27 @@ jobs:
3436
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # ratchet:actions/checkout@v7.0.0
3537

3638
- name: Assemble Pages site
39+
env:
40+
GH_TOKEN: ${{ github.token }}
3741
run: |
3842
mkdir -p _site
3943
cp internal/shop/config_schema.json _site/shopware-project-schema.json
4044
cp internal/extension/config_schema.json _site/shopware-extension-schema.json
41-
cat > _site/index.html <<'EOF'
45+
46+
# Prefer the release that triggered this run; otherwise use the latest non-prerelease.
47+
if [ "${{ github.event_name }}" = "release" ] && [ "${{ github.event.release.prerelease }}" != "true" ]; then
48+
VERSION="${{ github.event.release.tag_name }}"
49+
else
50+
VERSION=$(gh api "repos/${{ github.repository }}/releases/latest" --jq .tag_name 2>/dev/null || true)
51+
fi
52+
VERSION="${VERSION#v}"
53+
if [ -z "$VERSION" ]; then
54+
VERSION="dev"
55+
fi
56+
57+
jq -n --arg version "$VERSION" '{version: $version}' > _site/version.json
58+
59+
cat > _site/index.html <<EOF
4260
<!DOCTYPE html>
4361
<html lang="en">
4462
<head>
@@ -47,7 +65,9 @@ jobs:
4765
</head>
4866
<body>
4967
<h1>shopware-cli config schemas</h1>
68+
<p>Latest release: <code>${VERSION}</code></p>
5069
<ul>
70+
<li><a href="version.json">version.json</a> &mdash; latest CLI version</li>
5171
<li><a href="shopware-project-schema.json">shopware-project-schema.json</a> &mdash; schema for <code>.shopware-project.yml</code></li>
5272
<li><a href="shopware-extension-schema.json">shopware-extension-schema.json</a> &mdash; schema for <code>.shopware-extension.yml</code></li>
5373
</ul>

0 commit comments

Comments
 (0)