Skip to content
Open
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
193 changes: 193 additions & 0 deletions .github/actions/php/post-merge/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

name: php-post-merge
description: PHP post-merge GitHub release publishing with pre-built PIE extension archives

inputs:
version:
description: "Version for publishing"
required: true
tag:
description: "Git tag that identifies this PHP SDK release"
required: true
commit:
description: "Commit SHA being published"
required: true
dry_run:
description: "Dry run mode"
required: false
default: "false"
packages_artifact:
description: "Name of the artifact containing PHP extension archives"
required: false
default: "php-extensions-all"
packages_path:
description: "Path where PHP packages should be downloaded"
required: false
default: "dist"

runs:
using: "composite"
steps:
- name: Validate version format
run: |
VERSION="${{ inputs.version }}"

if ! echo "$VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$'; then
echo "Invalid PHP SDK version format: $VERSION"
echo "Expected Composer/Cargo-compatible SemVer: X.Y.Z[-prerelease][+build]"
exit 1
fi

echo "Version format valid: $VERSION"
shell: bash

- name: Download pre-built PHP packages
uses: actions/download-artifact@v8
with:
name: ${{ inputs.packages_artifact }}
path: ${{ inputs.packages_path }}

- name: Validate downloaded PHP packages
run: |
set -euo pipefail

PACKAGES_PATH="${{ inputs.packages_path }}"
VERSION="${{ inputs.version }}"

if [ ! -d "$PACKAGES_PATH" ]; then
echo "PHP packages directory not found: $PACKAGES_PATH"
exit 1
fi

expected=(
"php_iggy_php-${VERSION}_php8.3-x86_64-linux-glibc-nts.zip"
"php_iggy_php-${VERSION}_php8.4-x86_64-linux-glibc-nts.zip"
"php_iggy_php-${VERSION}_php8.3-arm64-linux-glibc-nts.zip"
"php_iggy_php-${VERSION}_php8.4-arm64-linux-glibc-nts.zip"
"php_iggy_php-${VERSION}_php8.3-x86_64-linux-musl-nts.zip"
"php_iggy_php-${VERSION}_php8.4-x86_64-linux-musl-nts.zip"
"php_iggy_php-${VERSION}_php8.3-arm64-linux-musl-nts.zip"
"php_iggy_php-${VERSION}_php8.4-arm64-linux-musl-nts.zip"
"php_iggy_php-${VERSION}_php8.3-x86_64-darwin-bsdlibc-nts.zip"
"php_iggy_php-${VERSION}_php8.4-x86_64-darwin-bsdlibc-nts.zip"
"php_iggy_php-${VERSION}_php8.3-arm64-darwin-bsdlibc-nts.zip"
"php_iggy_php-${VERSION}_php8.4-arm64-darwin-bsdlibc-nts.zip"
"apache-iggy-php-${VERSION}-source.tar.gz"
)

missing=0
for filename in "${expected[@]}"; do
if [ ! -f "$PACKAGES_PATH/$filename" ]; then
echo "Missing expected package: $filename"
missing=1
fi
done
if [ "$missing" -ne 0 ]; then
exit 1
fi

echo "Validating PHP extension archive contents:"
for archive in "$PACKAGES_PATH"/*.zip; do
filename="$(basename "$archive")"
echo " - $filename"
members="$(unzip -Z1 "$archive")"
for member in iggy_php.so LICENSE NOTICE LICENSE-binary; do
if ! grep -qx "$member" <<< "$members"; then
echo "Archive $filename is missing $member"
exit 1
fi
done
done

echo ""
echo "Packages ready for publishing:"
find "$PACKAGES_PATH" -maxdepth 1 -type f -print | sort | while IFS= read -r file; do
size="$(du -h "$file" | cut -f1)"
echo " - $(basename "$file") ($size)"
done
shell: bash

- name: Display publishing information (dry run)
if: inputs.dry_run == 'true'
run: |
PACKAGES_PATH="${{ inputs.packages_path }}"
VERSION="${{ inputs.version }}"
TAG="${{ inputs.tag }}"

echo "DRY RUN - Would publish PHP SDK:"
echo ""
echo "Package: apache/iggy-php"
echo "Version: $VERSION"
echo "Tag: $TAG"
echo "Registry: GitHub Releases"
echo ""
echo "Release assets that would be uploaded:"
find "$PACKAGES_PATH" -maxdepth 1 -type f -print | sort | sed 's|.*/| - |'
echo ""
echo "Packagist publishing requires a split repository with composer.json at the repository root."
shell: bash

- name: Publish GitHub release assets
if: inputs.dry_run == 'false'
run: |
set -euo pipefail

PACKAGES_PATH="${{ inputs.packages_path }}"
VERSION="${{ inputs.version }}"
TAG="${{ inputs.tag }}"
COMMIT="${{ inputs.commit }}"

if [ -z "$TAG" ]; then
echo "PHP release tag input is empty"
exit 1
fi
if ! git ls-remote --tags --exit-code origin "refs/tags/${TAG}" >/dev/null 2>&1; then
echo "PHP release tag $TAG does not exist on origin"
echo "Create the annotated PHP SDK tag before publishing GitHub release assets."
exit 1
fi

release_notes="$(mktemp)"
Comment thread
countradooku marked this conversation as resolved.
trap 'rm -f "$release_notes"' EXIT
{
echo "Apache Iggy PHP SDK ${VERSION}"
echo ""
echo "This GitHub release contains downstream convenience binaries for the PHP extension."
echo "The canonical Apache source release remains the ASF release artifact."
} > "$release_notes"

prerelease_flag=()
if [ "$(scripts/extract-version.sh sdk-php --is-pre-release)" = "true" ]; then
prerelease_flag=(--prerelease)
fi

if gh release view "$TAG" >/dev/null 2>&1; then
echo "GitHub release $TAG exists, uploading assets with clobber"
gh release upload "$TAG" "$PACKAGES_PATH"/* --clobber
else
echo "Creating GitHub release $TAG"
gh release create "$TAG" "$PACKAGES_PATH"/* \
--target "$COMMIT" \
--title "$TAG" \
--notes-file "$release_notes" \
"${prerelease_flag[@]}"
fi
shell: bash
env:
GH_TOKEN: ${{ github.token }}
100 changes: 100 additions & 0 deletions .github/actions/php/setup-release-tools/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

name: php-setup-release-tools
description: Install release helpers and resolve the PHP SDK version

inputs:
version:
description: "Explicit PHP SDK version. When empty, the version is read from publish config."
required: false
default: ""

outputs:
version:
description: "Resolved PHP SDK version"
value: ${{ steps.version.outputs.version }}

runs:
using: "composite"
steps:
- name: Setup yq
shell: bash
run: |
set -euo pipefail

if command -v yq >/dev/null 2>&1; then
yq --version
exit 0
fi

YQ_VERSION="v4.47.1"
case "$(uname -s)-$(uname -m)" in
Linux-x86_64)
YQ_BINARY="yq_linux_amd64"
YQ_CHECKSUM="0fb28c6680193c41b364193d0c0fc4a03177aecde51cfc04d506b1517158c2fb"
;;
Linux-aarch64)
YQ_BINARY="yq_linux_arm64"
YQ_CHECKSUM="b7f7c991abe262b0c6f96bbcb362f8b35429cefd59c8b4c2daa4811f1e9df599"
;;
Darwin-x86_64)
YQ_BINARY="yq_darwin_amd64"
YQ_CHECKSUM="a9b5ca36f7750576c6ace3cc7193349cd676b3a6bf30193fb2773ff45f5af5c2"
;;
Darwin-arm64)
YQ_BINARY="yq_darwin_arm64"
YQ_CHECKSUM="99aae3a7c9ddfe76bb339f0e7acd8224324b6527436fb6a5d890079bf5fcc590"
;;
*)
echo "Unsupported yq platform: $(uname -s)-$(uname -m)"
exit 1
;;
esac

yq_tmp="$(mktemp -d)"
trap 'rm -rf "$yq_tmp"' EXIT
curl -sSL -o "${yq_tmp}/${YQ_BINARY}" "https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/${YQ_BINARY}"
if command -v sha256sum >/dev/null 2>&1; then
echo "${YQ_CHECKSUM} ${yq_tmp}/${YQ_BINARY}" | sha256sum -c -
else
echo "${YQ_CHECKSUM} ${yq_tmp}/${YQ_BINARY}" | shasum -a 256 -c -
fi

mkdir -p "${RUNNER_TEMP}/yq-bin"
chmod +x "${yq_tmp}/${YQ_BINARY}"
mv "${yq_tmp}/${YQ_BINARY}" "${RUNNER_TEMP}/yq-bin/yq"
echo "${RUNNER_TEMP}/yq-bin" >> "$GITHUB_PATH"

- name: Resolve version
id: version
shell: bash
run: |
set -euo pipefail

if [ -d "${RUNNER_TEMP}/yq-bin" ]; then
export PATH="${RUNNER_TEMP}/yq-bin:${PATH}"
fi

if [ -n "${{ inputs.version }}" ]; then
version="${{ inputs.version }}"
else
chmod +x scripts/extract-version.sh
version="$(scripts/extract-version.sh sdk-php)"
fi

echo "version=${version}" >> "$GITHUB_OUTPUT"
6 changes: 6 additions & 0 deletions .github/config/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ components:
version_file: "foreign/python/pyproject.toml"
version_regex: '(?m)^\s*version\s*=\s*"([^"]+)"'

sdk-php:
tag_pattern: "^php-sdk-([0-9]+\\.[0-9]+\\.[0-9]+(?:-[0-9A-Za-z.-]+)?(?:\\+[0-9A-Za-z.-]+)?)$"
Comment thread
countradooku marked this conversation as resolved.
registry: github-release
version_file: "foreign/php/Cargo.toml"
version_regex: '(?m)^\s*version\s*=\s*"([^"]+)"'

sdk-node:
tag_pattern: "^node-sdk-([0-9]+\\.[0-9]+\\.[0-9]+(?:-[0-9A-Za-z.-]+)?(?:\\+[0-9A-Za-z.-]+)?)$"
registry: npm
Expand Down
Loading
Loading