Update build.yml #98
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build NGINX Unit with PHP Support | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
timeout-minutes: 120 # Increase this as needed | |
strategy: | |
matrix: | |
php_version: ['7.4', '8.0', '8.1', '8.2', '8.3'] # Add other PHP versions here if needed . | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | |
- uses: sonarsource/sonarqube-scan-action@master | |
env: | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} | |
- name: Install dependencies | |
run: | | |
sudo apt update -qq | |
sudo apt install -y software-properties-common git build-essential libssl-dev libpcre2-dev ca-certificates apt-transport-https debian-archive-keyring | |
sudo add-apt-repository -y ppa:ondrej/php | |
sudo apt-get update -qq | |
sudo apt-get install -y libphp${{ matrix.php_version }}-embed php${{ matrix.php_version }}-dev php${{ matrix.php_version }} | |
- name: Set UNITTMP environment variable | |
run: echo "UNITTMP=${{ github.workspace }}/unit_temp" >> $GITHUB_ENV | |
- name: Create a staging directory for the package | |
run: mkdir -p $UNITTMP/unit-php${{ matrix.php_version }}/DEBIAN | |
- name: Create DEBIAN/control file | |
run: | | |
cat <<EOL > $UNITTMP/unit-php${{ matrix.php_version }}/DEBIAN/control | |
Package: unit-php${{ matrix.php_version }} | |
Version: 1.32.1~jammy | |
Architecture: amd64 | |
Depends: unit (>= 1.32.1~jammy), php${{ matrix.php_version }}, libphp${{ matrix.php_version }}-embed | |
Maintainer: Viorel-Cosmin Miron <cosmin@uhl-services.ch> | |
Description: Custom PHP ${{ matrix.php_version }} language module for NGINX Unit 1.32.1 | |
EOL | |
- name: Build NGINX Unit with PHP ${{ matrix.php_version }} support | |
run: | | |
git clone https://github.com/nginx/unit.git | |
cd unit | |
git checkout tags/1.32.1 -b 1.32.1 | |
./configure --prefix=/usr --statedir=/var/lib/unit --control=unix:/var/run/control.unit.sock --pid=/var/run/unit.pid --log=/var/log/unit.log --tmpdir=/var/tmp --user=unit --group=unit --tests --openssl --modulesdir=/usr/lib/unit/modules --libdir=/usr/lib/x86_64-linux-gnu --cc-opt='-g -O2 -fdebug-prefix-map=/data/builder/debuild/unit-1.31.1-1/pkg/deb/debuild/unit-1.31.1-1=. -specs=/usr/share/dpkg/no-pie-compile.specs -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fPIC' | |
./configure php --module=php${{ matrix.php_version }} --config=php-config${{ matrix.php_version }} | |
make php${{ matrix.php_version }} | |
mkdir -p $UNITTMP/unit-php${{ matrix.php_version }}/usr/lib/unit/modules | |
mv build/lib/unit/modules/php${{ matrix.php_version }}.unit.so $UNITTMP/unit-php${{ matrix.php_version }}/usr/lib/unit/modules | |
- name: Build and install DEBIAN package | |
run: | | |
dpkg-deb -b $UNITTMP/unit-php${{ matrix.php_version }} $UNITTMP/unit-php${{ matrix.php_version }}.deb | |
sudo dpkg -i $UNITTMP/unit-php${{ matrix.php_version }}.deb | |
- name: Verify the installed packages | |
run: dpkg -l | grep unit-php${{ matrix.php_version }} | |
# - name: Sign Debian package | |
# run: | | |
# echo "default-cache-ttl 3600" > gpg-agent-temp.conf | |
# echo "max-cache-ttl 3600" >> gpg-agent-temp.conf | |
# echo "allow-loopback-pinentry" >> gpg-agent-temp.conf | |
# gpg-connect-agent --homedir ~/.gnupg killagent /bye | |
# gpg-agent --homedir ~/.gnupg --daemon --options ./gpg-agent-temp.conf | |
# echo "${{ secrets.GPG_PASSPHRASE }}" | /usr/lib/gnupg/gpg-preset-passphrase --preset 7AF9239FDD2E5D99D6D5EBFE5C4318AC748EB021 | |
# dpkg-sig -k D3C4291DC95EBA3BF3C1B3D4ECD0B250E07D922B --sign builder $UNITTMP/unit-php${{ matrix.php_version }}.deb | |
# rm gpg-agent-temp.conf | |
# env: | |
# UNITTMP: ${{ github.workspace }}/unit_temp | |
- name: Create Release | |
run: | | |
timestamp=$(date +%s) | |
tag_name="v${{ matrix.php_version }}-${timestamp}" | |
response=$(curl -s -H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" -X POST \ | |
-d '{ | |
"tag_name": "'"${tag_name}"'", | |
"name": "Release unit-php${{ matrix.php_version }}", | |
"draft": false, | |
"prerelease": false | |
}' \ | |
https://api.github.com/repos/uhlhosting/Unit-PHP/releases) | |
echo "API response: ${response}" | |
upload_url=$(echo "${response}" | jq -r '.upload_url' | cut -d'{' -f1) | |
echo "upload_url=${upload_url}" >> $GITHUB_ENV | |
env: | |
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} | |
- name: Upload Package | |
run: | | |
echo "Uploading to URL: ${upload_url}" | |
curl -s -H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" -H "Content-Type: application/octet-stream" \ | |
--data-binary "$UNITTMP/unit-php${{ matrix.php_version }}.deb" \ | |
"${upload_url}?name=unit-php${{ matrix.php_version }}.deb" | |
env: | |
UNITTMP: ${{ github.workspace }}/unit_temp | |
upload_url: ${{ env.upload_url }} | |
- name: Send a stream message | |
uses: zulip/github-actions-zulip@v0.1.0 | |
with: | |
username: ${{ secrets.ZULIP_USERNAME }} # Zulip username | |
api-key: ${{ secrets.ZULIP_API_KEY }} # Zulip API key | |
organization-url: 'https://chat.uhlhosting.ch' # Your Zulip organization URL | |
to: 'Reports' | |
type: 'stream' | |
topic: 'GitHub Actions' | |
content: 'Build completed for PHP ${{ matrix.php_version }}. Check the [releases page](https://github.com/uhlhosting/Unit-PHP/releases) for the package.' |