Skip to content

Commit f93c65b

Browse files
mnoconadriendupuis
andauthored
Allowed building dev version of the API references from Github Actions (#3173)
* Allowed building dev version of the API references from Github Actions * Added GitHub token to the workflow * Added Readme * Update .github/workflows/api_refs.yaml Co-authored-by: Adrien Dupuis <61695653+adriendupuis@users.noreply.github.com> * Apply suggestion from @adriendupuis --------- Co-authored-by: Adrien Dupuis <61695653+adriendupuis@users.noreply.github.com>
1 parent 8fed03a commit f93c65b

3 files changed

Lines changed: 68 additions & 9 deletions

File tree

.github/workflows/api_refs.yaml

Lines changed: 51 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 x-dev branch (default: false)'
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
@@ -39,13 +67,30 @@ jobs:
3967
- name: Install Redocly CLI
4068
run: npm install -g @redocly/cli@latest
4169

70+
- name: Generate token
71+
id: generate_token
72+
if: inputs.use_dev_version == true
73+
uses: actions/create-github-app-token@v2
74+
with:
75+
app-id: ${{ secrets.AUTOMATION_CLIENT_ID }}
76+
private-key: ${{ secrets.AUTOMATION_CLIENT_SECRET }}
77+
owner: ibexa
78+
4279
- name: Build API Refs
4380
env:
4481
SATIS_NETWORK_KEY: ${{ secrets.SATIS_NETWORK_KEY }}
4582
SATIS_NETWORK_TOKEN: ${{ secrets.SATIS_NETWORK_TOKEN }}
83+
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
4684
BASE_BRANCH: ${{ steps.version_and_branches.outputs.base_branch }}
85+
DXP_VERSION: ${{ steps.version_and_branches.outputs.dxp_version }}
86+
BASE_DXP_BRANCH: ${{ steps.version_and_branches.outputs.base_dxp_branch }}
87+
VIRTUAL_DXP_VERSION: ${{ steps.version_and_branches.outputs.virtual_dxp_version }}
4788
run: |
89+
if [ -n "$GITHUB_TOKEN" ]; then
90+
composer config --global github-oauth.github.com "$GITHUB_TOKEN"
91+
fi
4892
composer config --global http-basic.updates.ibexa.co $SATIS_NETWORK_KEY $SATIS_NETWORK_TOKEN
93+
4994
if [[ '4.6' != $BASE_BRANCH ]]; then
5095
tools/api_refs/api_refs.sh
5196
# Fix escape character:

tools/api_refs/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,20 @@ nano phpdoc.dev.xml # Edit and make your changes. For example, target only your
6464
tools/api_refs/api_refs.sh ~/.composer/auth.json ./docs/api/php_api/php_api_reference-TMP
6565
```
6666

67+
### Creating a build of dev version
68+
69+
To build the reference for an unreleased version, set the following variables:
70+
71+
- `DXP_VERSION`
72+
- `BASE_DXP_BRANCH`
73+
- `VIRTUAL_DXP_VERSION`
74+
75+
For example, to build the API Reference based on the development version of the DXP before the 5.0.10 release, run:
76+
77+
``` bash
78+
DXP_VERSION=v5.0.x-dev BASE_DXP_BRANCH=5.0 VIRTUAL_DXP_VERSION=5.0.10 tools/api_refs/api_refs.sh ~/my/path/to/auth.json
79+
```
80+
6781
### Test a branch
6882

6983
To load a package on a development branch instead of a released version,

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 mcp); # 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)