Skip to content

Commit 9a97d19

Browse files
committed
Allowed building dev version of the API references from Github Actions
1 parent 3bceac2 commit 9a97d19

2 files changed

Lines changed: 40 additions & 9 deletions

File tree

.github/workflows/api_refs.yaml

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,19 @@ on:
44
workflow_dispatch:
55
inputs:
66
version:
7-
description: 'Released version tag (for example: v4.6.21 or v5.0.0)'
7+
# The version to build the API Reference for.
8+
# Use a released tag (e.g. v5.0.9) or a plain number (e.g. 5.0.9).
9+
description: 'Version (e.g. v5.0.9 or 5.0.9)'
810
required: true
911
type: string
12+
use_dev_version:
13+
# When checked, Composer installs from the x-dev branch instead of a released tag.
14+
# Useful for building a reference before the final release is tagged.
15+
# Example: version=5.0.9 + use_dev_version=true → DXP_VERSION=v5.0.x-dev, BASE_DXP_BRANCH=5.0, VIRTUAL_DXP_VERSION=5.0.9
16+
description: 'Use dev version (install from x-dev branch, e.g. v5.0.x-dev)'
17+
required: false
18+
type: boolean
19+
default: false
1020

1121
jobs:
1222
open_php_api_ref_pr:
@@ -17,12 +27,30 @@ jobs:
1727
- name: Set version and branches
1828
id: version_and_branches
1929
run: |
30+
# Strip leading 'v' to get a plain version number (e.g. 5.0.9)
2031
version="${{ inputs.version }}"
21-
base_branch="$(echo $version | sed 's/v\(.*\..*\)\..*/\1/')"
22-
work_branch="api_refs_$version"
23-
echo "version=$version" >> "$GITHUB_OUTPUT"
24-
echo "base_branch=$base_branch" >> "$GITHUB_OUTPUT"
25-
echo "work_branch=$work_branch" >> "$GITHUB_OUTPUT"
32+
version="${version#v}"
33+
base_branch="$(echo $version | sed 's/\(.*\..*\)\..*/\1/')"
34+
work_branch="api_refs_v${version}"
35+
36+
if [[ "${{ inputs.use_dev_version }}" == "true" ]]; then
37+
# Dev build: install from the x-dev branch and label output with the target version
38+
dxp_version="v${base_branch}.x-dev"
39+
base_dxp_branch="${base_branch}"
40+
virtual_dxp_version="${version}"
41+
else
42+
# Stable build: install from the released tag
43+
dxp_version="v${version}"
44+
base_dxp_branch=""
45+
virtual_dxp_version=""
46+
fi
47+
48+
echo "version=v${version}" >> "$GITHUB_OUTPUT"
49+
echo "base_branch=${base_branch}" >> "$GITHUB_OUTPUT"
50+
echo "work_branch=${work_branch}" >> "$GITHUB_OUTPUT"
51+
echo "dxp_version=${dxp_version}" >> "$GITHUB_OUTPUT"
52+
echo "base_dxp_branch=${base_dxp_branch}" >> "$GITHUB_OUTPUT"
53+
echo "virtual_dxp_version=${virtual_dxp_version}" >> "$GITHUB_OUTPUT"
2654
2755
- name: Checkout documentation
2856
uses: actions/checkout@v4
@@ -44,6 +72,9 @@ jobs:
4472
SATIS_NETWORK_KEY: ${{ secrets.SATIS_NETWORK_KEY }}
4573
SATIS_NETWORK_TOKEN: ${{ secrets.SATIS_NETWORK_TOKEN }}
4674
BASE_BRANCH: ${{ steps.version_and_branches.outputs.base_branch }}
75+
DXP_VERSION: ${{ steps.version_and_branches.outputs.dxp_version }}
76+
BASE_DXP_BRANCH: ${{ steps.version_and_branches.outputs.base_dxp_branch }}
77+
VIRTUAL_DXP_VERSION: ${{ steps.version_and_branches.outputs.virtual_dxp_version }}
4778
run: |
4879
composer config --global http-basic.updates.ibexa.co $SATIS_NETWORK_KEY $SATIS_NETWORK_TOKEN
4980
if [[ '4.6' != $BASE_BRANCH ]]; then

tools/api_refs/api_refs.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ REST_API_OPENAPI_FILE_YAML=${4:-./docs/api/rest_api/rest_api_reference/openapi.y
99
REST_API_OPENAPI_FILE_JSON=${5:-./docs/api/rest_api/rest_api_reference/openapi.json}; # Path to the REST API OpenAPI spec file
1010

1111
DXP_EDITION='commerce'; # Edition from and for which the Reference is built
12-
DXP_VERSION='5.0.*'; # Version from and for which the Reference is built
12+
DXP_VERSION="${DXP_VERSION:-5.0.*}"; # Version from and for which the Reference is built; can be overridden by the DXP_VERSION env var (e.g. v5.0.x-dev for a dev build)
1313
DXP_ADD_ONS=(automated-translation rector integrated-help fieldtype-richtext-rte connector-anthropic connector-gemini shopping-list cdp connector-raptor connector-quable); # Packages not included in $DXP_EDITION but added to the Reference, listed without their vendor "ibexa"
1414
DXP_EDITIONS=(oss headless experience commerce); # Available editions ordered by ascending capabilities
1515
SF_VERSION='7.4'; # Symfony version used by Ibexa DXP
@@ -26,8 +26,8 @@ OPENAPI_FIX="$(pwd)/tools/api_refs/openapi.php"; # A script editing and fixing f
2626
PHP_BINARY="php -d error_reporting=`php -r 'echo E_ALL & ~E_DEPRECATED;'`"; # Avoid depreciation messages from phpDocumentor/Reflection/issues/529 when using PHP 8.2 or higher
2727
TMP_DXP_DIR=/tmp/ibexa-dxp-phpdoc; # Absolute path of the temporary directory in which Ibexa DXP will be installed and the PHP API Reference built
2828
FORCE_DXP_INSTALL=1; # If 1, empty the temporary directory, install DXP from scratch, build, remove temporary directory; if 0, potentially reuse the DXP already installed in temporary directory, keep temporary directory for future uses.
29-
BASE_DXP_BRANCH=''; # Branch from and for which the Reference is built when using a dev branch as version
30-
VIRTUAL_DXP_VERSION=''; # Version for which the reference is supposedly built when using dev branch as version
29+
BASE_DXP_BRANCH="${BASE_DXP_BRANCH:-}"; # Branch from and for which the Reference is built when using a dev branch as version; can be overridden by the BASE_DXP_BRANCH env var
30+
VIRTUAL_DXP_VERSION="${VIRTUAL_DXP_VERSION:-}"; # Version for which the reference is supposedly built when using dev branch as version; can be overridden by the VIRTUAL_DXP_VERSION env var
3131

3232
if [ ! -d $PHP_API_OUTPUT_DIR ]; then
3333
echo -n "Creating ${PHP_API_OUTPUT_DIR}";

0 commit comments

Comments
 (0)