|
| 1 | +name: 'dispatch-all-php-intl' |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + inputs: |
| 5 | + icu: |
| 6 | + description: ICU version |
| 7 | + required: true |
| 8 | +jobs: |
| 9 | + php-intl: |
| 10 | + container: ubuntu:bionic |
| 11 | + runs-on: ubuntu-latest |
| 12 | + strategy: |
| 13 | + fail-fast: false |
| 14 | + php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0'] |
| 15 | + name: php-intl |
| 16 | + steps: |
| 17 | + - name: ${{github.event.inputs.php}} |
| 18 | + id: print_details |
| 19 | + run: | |
| 20 | + echo sender=${{github.event.sender.login}} |
| 21 | + echo ICU=${{github.event.inputs.icu}} |
| 22 | + - name: Checkout |
| 23 | + uses: actions/checkout@v2 |
| 24 | + - name: Update intl |
| 25 | + env: |
| 26 | + ICU: ${{github.event.inputs.icu}} |
| 27 | + BINTRAY_KEY: ${{ secrets.bintray_key }} |
| 28 | + BINTRAY_REPO: icu4c |
| 29 | + BINTRAY_USER: ${{ github.repository_owner }} |
| 30 | + VERSION: ${{matrix.php}} |
| 31 | + run: | |
| 32 | + apt-get -y update |
| 33 | + apt-get install -y sudo curl |
| 34 | + existing_version=$(curl --user "$BINTRAY_USER":"$BINTRAY_KEY" -s https://api.bintray.com/packages/"$BINTRAY_USER"/"$BINTRAY_REPO"/php-intl | grep -Po "$VERSION-$ICU" | head -n 1) |
| 35 | + if [ "$VERSION-$ICU" != "$existing_version" ]; then |
| 36 | + sudo apt-get install -y gnupg make automake zstd software-properties-common pkg-config |
| 37 | + LC_ALL=C.UTF-8 sudo DEBIAN_FRONTEND=noninteractive apt-add-repository ppa:ondrej/php -y |
| 38 | + sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php$VERSION php$VERSION-xml php$VERSION-dev |
| 39 | + ext_dir=$(php -i | grep "extension_dir => /" | sed -e "s|.*=> s*||") |
| 40 | + scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||") |
| 41 | + ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g") |
| 42 | + pecl_file="$scan_dir"/99-pecl.ini |
| 43 | + get_tag() { |
| 44 | + echo "php-$(php -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-')" |
| 45 | + } |
| 46 | + get_php() { |
| 47 | + curl -sL "https://github.com/php/php-src/archive/$tag.tar.gz" | tar xzf - -C "/tmp" |
| 48 | + } |
| 49 | + check_extension() { |
| 50 | + extension=$1 |
| 51 | + if [ "$extension" != "mysql" ]; then |
| 52 | + php -m | grep -i -q -w "$extension" |
| 53 | + else |
| 54 | + php -m | grep -i -q "$extension" |
| 55 | + fi |
| 56 | + } |
| 57 | + enable_extension() { |
| 58 | + if ! check_extension "$1" && [ -e "$ext_dir/$1.so" ]; then |
| 59 | + echo "$2=$1.so" >>"$pecl_file" |
| 60 | + fi |
| 61 | + } |
| 62 | + install_icu() { |
| 63 | + sudo curl -o /tmp/icu.tar.zst -sL https://dl.bintray.com/shivammathur/icu4c/icu4c-$ICU.tar.zst |
| 64 | + sudo tar -I zstd -xf /tmp/icu.tar.zst -C /usr/local |
| 65 | + sudo cp -r /usr/local/icu/* /usr/ |
| 66 | + sudo cp -r /usr/local/icu/lib/* /usr/lib/x86_64-linux-gnu/ |
| 67 | + } |
| 68 | + install_intl() { |
| 69 | + tag=$(get_tag) |
| 70 | + get_php |
| 71 | + ( |
| 72 | + cd "/tmp/php-src-$tag/ext/intl" || exit 1 |
| 73 | + phpize && sudo ./configure --with-php-config="$(command -v php-config)" --enable-intl |
| 74 | + echo "#define FALSE 0" >> config.h |
| 75 | + echo "#define TRUE 1" >> config.h |
| 76 | + sudo make CXXFLAGS="-O2 -std=c++11 -DU_USING_ICU_NAMESPACE=1 -DTRUE=1 -DFALSE=0 $CXXFLAGS" |
| 77 | + sudo cp ./modules/* "$ext_dir/" |
| 78 | + enable_extension intl extension |
| 79 | + ) |
| 80 | + } |
| 81 | + install_icu |
| 82 | + install_intl |
| 83 | + icu_version=$(php -i | grep "ICU version =>" | sed -e "s|.*=> s*||") |
| 84 | + [ "$icu_version" != "$ICU" ] && exit 1 |
| 85 | + cd "$ext_dir" || exit 1 |
| 86 | + curl --user "$BINTRAY_USER":"$BINTRAY_KEY" -X DELETE https://api.bintray.com/content/"$BINTRAY_USER"/"$BINTRAY_REPO"/php"$VERSION"-intl-"$ICU".so || true |
| 87 | + curl --user "$BINTRAY_USER":"$BINTRAY_KEY" -T intl.so https://api.bintray.com/content/"$BINTRAY_USER"/"$BINTRAY_REPO"/php-intl/"$VERSION-$ICU"/php"$VERSION"-intl-"$ICU".so || true |
| 88 | + curl --user "$BINTRAY_USER":"$BINTRAY_KEY" -X POST https://api.bintray.com/content/"$BINTRAY_USER"/"$BINTRAY_REPO"/php-intl/"$VERSION-$ICU"/publish || true |
| 89 | + else |
| 90 | + echo "intl $VERSION-$ICU build exists" |
| 91 | + fi |
0 commit comments