Skip to content

PCBC-1004: Insert ABI version tag into PHP extension namespace #27

PCBC-1004: Insert ABI version tag into PHP extension namespace

PCBC-1004: Insert ABI version tag into PHP extension namespace #27

Workflow file for this run

name: versions
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
source_abi:
runs-on: ubuntu-22.04
outputs:
extension_version: ${{ steps.build_extension.outputs.extension_version }}
abi_version: ${{ steps.build_extension.outputs.abi_version }}
alternate_abi_version: ${{ steps.build_extension.outputs.alternate_abi_version }}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
fetch-tags: true
- uses: hendrikmuhs/[email protected]
with:
max-size: 2G
key: ${{ github.job }}
- name: Build
id: build_extension
run: |
gem install --no-document --user-install nokogiri
export COMMITS_SINCE_LAST_TAG=$(git describe --tags --always --long | awk -F '-' '{print $2}')
EXTENSION_VERSION=$(ruby -e 'print [ARGF.read[/PHP_COUCHBASE_VERSION "(\d+\.\d+\.\d+)"/, 1], ENV["COMMITS_SINCE_LAST_TAG"].to_i > 0 ? ENV["COMMITS_SINCE_LAST_TAG"] : nil].compact.join(".")' src/php_couchbase.hxx)
echo "extension_version=${EXTENSION_VERSION}" >> "$GITHUB_OUTPUT"
ABI_VERSION=$(ruby -e 'print ARGF.read[/PHP_COUCHBASE_VERSION "(\d+\.\d+\.\d+)"/, 1].gsub(".", "_")' src/php_couchbase.hxx)
ALTERNATE_ABI_VERSION=$(ruby -e 'print ARGF.read[/PHP_COUCHBASE_VERSION "(\d+\.\d+\.\d+)"/, 1].gsub(".", "_").succ' src/php_couchbase.hxx)
echo "abi_version=${ABI_VERSION}" >> "$GITHUB_OUTPUT"
echo "alternate_abi_version=${ALTERNATE_ABI_VERSION}" >> "$GITHUB_OUTPUT"
export BUILD_NUMBER="${COMMITS_SINCE_LAST_TAG}"
ruby ./bin/package.rb
- name: PHPDoc
run: |
ruby ./bin/docs.rb
- uses: actions/upload-artifact@v4
with:
name: couchbase-${{ steps.build_extension.outputs.extension_version }}
path: |
couchbase-*.tgz
- uses: actions/upload-artifact@v4
with:
retention-days: 1
name: scripts-${{ steps.build_extension.outputs.extension_version }}
path: |
bin/**/*
90-couchbase.ini
phpcs.xml
- uses: actions/upload-artifact@v4
with:
retention-days: 1
name: tests-${{ steps.build_extension.outputs.extension_version }}
path: |
tests/**/*
- uses: actions/upload-artifact@v4
with:
name: docs-${{ steps.build_extension.outputs.extension_version }}
path: |
build/couchbase-php-client-*/**/*
abi_linux_build:
needs: source_abi
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
version:
- unversioned
- ${{ needs.source_abi.outputs.abi_version }}
- ${{ needs.source_abi.outputs.alternate_abi_version }}
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: json, mbstring, intl
env:
phpts: nts
- uses: actions/download-artifact@v4
with:
name: couchbase-${{ needs.source_abi.outputs.extension_version }}
- uses: actions/download-artifact@v4
with:
name: scripts-${{ needs.source_abi.outputs.extension_version }}
- uses: hendrikmuhs/[email protected]
with:
max-size: 2G
key: ${{ github.job }}-${{ matrix.version }}
- name: Set env variable
run: |
if [ "${{ matrix.version }}" != "unversioned" ]; then
echo "CB_ABI_VERSION=${{ matrix.version }}" >> $GITHUB_ENV
else
echo "Building unversioned extension"
fi
- name: Build
run: |
echo "Building versioned extension: ${CB_ABI_VERSION}"
pecl bundle couchbase-${{ needs.source_abi.outputs.extension_version }}.tgz
(
cd couchbase
phpize
./configure --enable-couchbase
mkdir target
make INSTALL_ROOT="$(realpath target)" install
)
DIST_NAME=couchbase-${{ matrix.version }}-linux-x86_64
mkdir ${DIST_NAME}
cp -av couchbase/LICENSE 90-couchbase.ini couchbase/Couchbase couchbase/GPBMetadata ${DIST_NAME}/
find couchbase/target -name couchbase.so -exec cp -v {} ${DIST_NAME}/ \;
strip --strip-all ${DIST_NAME}/couchbase.so
if [ -n "${CB_ABI_VERSION}" ]; then
echo "Renaming so file to couchbase_${CB_ABI_VERSION}.so"
mv ${DIST_NAME}/couchbase.so ${DIST_NAME}/couchbase_${CB_ABI_VERSION}.so
else
echo "CB_ABI_VERSION not set, keeping couchbase.so"
fi
tar cv ${DIST_NAME}/ | gzip -9 > ${DIST_NAME}.tgz
- uses: actions/upload-artifact@v4
with:
name: couchbase-${{ matrix.version }}-linux-x86_64
path: |
couchbase-*-linux-x86_64.tgz
abi_linux_x86_64_test:
needs:
- source_abi
- abi_linux_build
runs-on: ubuntu-22.04
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: json, mbstring, intl
env:
phpts: nts
- uses: actions/download-artifact@v4
with:
name: couchbase-${{ needs.source_abi.outputs.extension_version }}
- uses: actions/download-artifact@v4
with:
name: scripts-${{ needs.source_abi.outputs.extension_version }}
- uses: actions/download-artifact@v4
with:
path: tests
name: tests-${{ needs.source_abi.outputs.extension_version }}
- uses: actions/download-artifact@v4
with:
name: couchbase-${{ needs.source_abi.outputs.abi_version }}-linux-x86_64
- uses: actions/download-artifact@v4
with:
name: couchbase-${{ needs.source_abi.outputs.alternate_abi_version }}-linux-x86_64
- uses: actions/download-artifact@v4
with:
name: couchbase-unversioned-linux-x86_64
- name: Test
env:
CB_ABI_VERSION: ${{ needs.source_abi.outputs.abi_version }}
run: |
tar xf couchbase-unversioned-linux-x86_64.tgz
tar xf couchbase-${{ needs.source_abi.outputs.abi_version }}-linux-x86_64.tgz
tar xf couchbase-${{ needs.source_abi.outputs.alternate_abi_version }}-linux-x86_64.tgz
TEST_ABI=both ruby ./bin/test.rb -v ${{ needs.source_abi.outputs.abi_version }} -v ${{ needs.source_abi.outputs.alternate_abi_version }} -v unversioned
TEST_ABI=versioned ruby ./bin/test.rb -v ${{ needs.source_abi.outputs.abi_version }}
ruby -e '
file_paths = [
"couchbase-unversioned-linux-x86_64/Couchbase/ExtensionNamespaceResolver.php",
"couchbase-${{ needs.source_abi.outputs.abi_version }}-linux-x86_64/Couchbase/ExtensionNamespaceResolver.php",
"couchbase-${{ needs.source_abi.outputs.alternate_abi_version }}-linux-x86_64/Couchbase/ExtensionNamespaceResolver.php"
]
file_paths.each do |file_name|
text = File.read(file_name)
new_contents = text.gsub("${{ needs.source_abi.outputs.abi_version }}", "${{ needs.source_abi.outputs.alternate_abi_version }}")
File.open(file_name, "w") { |file| file.puts new_contents }
end
'
TEST_ABI=both ruby ./bin/test.rb -v ${{ needs.source_abi.outputs.abi_version }} -v ${{ needs.source_abi.outputs.alternate_abi_version }} -v unversioned
TEST_ABI=versioned ruby ./bin/test.rb -v ${{ needs.source_abi.outputs.alternate_abi_version }}
build_macos_x86_64:
needs: source_abi
runs-on: macos-13
strategy:
fail-fast: false
matrix:
version:
- unversioned
- ${{ needs.source_abi.outputs.abi_version }}
- ${{ needs.source_abi.outputs.alternate_abi_version }}
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
# https://github.com/shivammathur/icu-intl#icu4c-builds
extensions: json, mbstring, intl-74.1
env:
phpts: nts
- uses: actions/download-artifact@v4
with:
name: couchbase-${{ needs.source_abi.outputs.extension_version }}
- uses: actions/download-artifact@v4
with:
name: scripts-${{ needs.source_abi.outputs.extension_version }}
- uses: hendrikmuhs/[email protected]
with:
max-size: 2G
key: ${{ github.job }}-${{ matrix.version }}
- name: Set env variable
run: |
if [ "${{ matrix.version }}" != "unversioned" ]; then
echo "CB_ABI_VERSION=${{ matrix.version }}" >> $GITHUB_ENV
else
echo "Building unversioned extension"
fi
- name: Build
run: |
echo "Building versioned extension: ${CB_ABI_VERSION}"
pecl bundle couchbase-${{ needs.source_abi.outputs.extension_version }}.tgz
(
cd couchbase
phpize
./configure --enable-couchbase
mkdir target
make INSTALL_ROOT="$(realpath target)" install
)
DIST_NAME=couchbase-${{ matrix.version }}-macos-x86_64
mkdir ${DIST_NAME}
cp -av couchbase/LICENSE 90-couchbase.ini couchbase/Couchbase couchbase/GPBMetadata ${DIST_NAME}/
find couchbase/target -name couchbase.so -exec cp -v {} ${DIST_NAME}/ \;
strip ${DIST_NAME}/couchbase.so 2>/dev/null || true
if [ -n "${CB_ABI_VERSION}" ]; then
echo "Renaming so file to couchbase_${CB_ABI_VERSION}.so"
mv ${DIST_NAME}/couchbase.so ${DIST_NAME}/couchbase_${CB_ABI_VERSION}.so
else
echo "CB_ABI_VERSION not set, keeping couchbase.so"
fi
tar cv ${DIST_NAME}/ | gzip -9 > ${DIST_NAME}.tgz
- uses: actions/upload-artifact@v4
with:
name: couchbase-${{ matrix.version }}-macos-x86_64
path: |
couchbase-*-macos-x86_64.tgz
macos_x86_64_test:
needs:
- source_abi
- build_macos_x86_64
runs-on: macos-13
strategy:
fail-fast: false
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
# https://github.com/shivammathur/icu-intl#icu4c-builds
extensions: json, mbstring, intl-74.1
env:
phpts: nts
- uses: actions/download-artifact@v4
with:
name: couchbase-${{ needs.source_abi.outputs.extension_version }}
- uses: actions/download-artifact@v4
with:
name: scripts-${{ needs.source_abi.outputs.extension_version }}
- uses: actions/download-artifact@v4
with:
path: tests
name: tests-${{ needs.source_abi.outputs.extension_version }}
- uses: actions/download-artifact@v4
with:
name: couchbase-${{ needs.source_abi.outputs.abi_version }}-macos-x86_64
- uses: actions/download-artifact@v4
with:
name: couchbase-${{ needs.source_abi.outputs.alternate_abi_version }}-macos-x86_64
- uses: actions/download-artifact@v4
with:
name: couchbase-${{ needs.source_abi.outputs.abi_version }}-macos-x86_64
- uses: actions/download-artifact@v4
with:
name: couchbase-unversioned-macos-x86_64
- name: Test
env:
CB_ABI_VERSION: ${{ needs.source_abi.outputs.abi_version }}
run: |
tar xf couchbase-unversioned-macos-x86_64.tgz
tar xf couchbase-${{ needs.source_abi.outputs.abi_version }}-macos-x86_64.tgz
tar xf couchbase-${{ needs.source_abi.outputs.alternate_abi_version }}-macos-x86_64.tgz
TEST_ABI=both CB_PHP_EXECUTABLE=$(which php) ruby ./bin/test.rb -v ${{ needs.source_abi.outputs.abi_version }} -v ${{ needs.source_abi.outputs.alternate_abi_version }} -v unversioned
TEST_ABI=versioned CB_PHP_EXECUTABLE=$(which php) ruby ./bin/test.rb -v ${{ needs.source_abi.outputs.abi_version }}
ruby -e '
file_paths = [
"couchbase-unversioned-macos-x86_64/Couchbase/ExtensionNamespaceResolver.php",
"couchbase-${{ needs.source_abi.outputs.abi_version }}-macos-x86_64/Couchbase/ExtensionNamespaceResolver.php",
"couchbase-${{ needs.source_abi.outputs.alternate_abi_version }}-macos-x86_64/Couchbase/ExtensionNamespaceResolver.php"
]
file_paths.each do |file_name|
text = File.read(file_name)
new_contents = text.gsub("${{ needs.source_abi.outputs.abi_version }}", "${{ needs.source_abi.outputs.alternate_abi_version }}")
File.open(file_name, "w") { |file| file.puts new_contents }
end
'
TEST_ABI=both CB_PHP_EXECUTABLE=$(which php) ruby ./bin/test.rb -v ${{ needs.source_abi.outputs.abi_version }} -v ${{ needs.source_abi.outputs.alternate_abi_version }} -v unversioned
TEST_ABI=versioned CB_PHP_EXECUTABLE=$(which php) ruby ./bin/test.rb -v ${{ needs.source_abi.outputs.alternate_abi_version }}