ncc/.github/workflows/ci.yml

136 lines
3.4 KiB
YAML
Raw Permalink Normal View History

2024-09-20 18:58:40 -04:00
name: CI Pipeline
on:
push:
branches:
2024-09-20 19:00:38 -04:00
- '**'
2024-09-20 18:58:40 -04:00
pull_request:
branches:
2024-09-20 19:00:38 -04:00
- '**'
2024-09-20 19:26:18 -04:00
release:
types:
- created
2024-09-20 18:58:40 -04:00
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: mbstring, ctype, common, zip
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y git libpq-dev libzip-dev zip make wget gnupg
- name: Install Phive
run: |
wget -O phive.phar https://phar.io/releases/phive.phar
wget -O phive.phar.asc https://phar.io/releases/phive.phar.asc
gpg --keyserver hkps://keys.openpgp.org --recv-keys 0x9D8A98B29B2D5D79
gpg --verify phive.phar.asc phive.phar
chmod +x phive.phar
sudo mv phive.phar /usr/local/bin/phive
- name: Install PHPAB
2024-09-20 19:05:39 -04:00
run: sudo phive install phpab --global --trust-gpg-keys 0x2A8299CE842DD38C
2024-09-20 18:58:40 -04:00
- name: Build project
run: make redist
- name: Find NCC build directory
id: find-ncc-dir
run: echo "NCC_DIR=$(find build/ -type d -name 'ncc_*' | head -n 1)" >> $GITHUB_ENV
2024-09-20 19:49:39 -04:00
- name: Upload NCC build directory
uses: actions/upload-artifact@v3
with:
name: ncc-build
path: ${{ env.NCC_DIR }}
2024-09-20 19:26:18 -04:00
- name: Create redist.zip
run: zip -r redist.zip ${{ env.NCC_DIR }}
2024-09-20 19:47:30 -04:00
- name: Upload redist.zip
2024-09-20 18:58:40 -04:00
uses: actions/upload-artifact@v3
with:
2024-09-20 19:47:30 -04:00
name: redist-zip
2024-09-20 19:26:18 -04:00
path: redist.zip
2024-09-20 18:58:40 -04:00
- name: Build Debian package
run: make deb
- name: Find Debian package
id: find-deb
run: echo "DEB_FILE=$(find build/ -type f -name '*.deb' | head -n 1)" >> $GITHUB_ENV
- name: Upload Debian package
uses: actions/upload-artifact@v3
with:
name: ncc-deb
path: ${{ env.DEB_FILE }}
2024-09-20 19:29:48 -04:00
test-install:
2024-09-20 18:58:40 -04:00
runs-on: ubuntu-latest
needs: build
steps:
- name: Download NCC build directory
uses: actions/download-artifact@v3
with:
name: ncc-build
path: build
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: mbstring, ctype, common, zip
- name: Test NCC installation
run: |
2024-09-20 19:37:53 -04:00
ls -l build
2024-09-20 19:26:18 -04:00
sudo php build/INSTALL --auto
2024-09-20 19:29:48 -04:00
upload-release:
2024-09-20 19:26:18 -04:00
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'release' && github.event.action == 'created'
2024-09-20 19:57:18 -04:00
permissions: write-all
2024-09-20 19:26:18 -04:00
steps:
2024-09-20 19:47:30 -04:00
- name: Download redist.zip
2024-09-20 19:26:18 -04:00
uses: actions/download-artifact@v3
with:
2024-09-20 19:47:30 -04:00
name: redist-zip
path: .
2024-09-20 19:26:18 -04:00
- name: Download Debian package
uses: actions/download-artifact@v3
with:
name: ncc-deb
2024-09-20 19:47:30 -04:00
path: .
2024-09-20 19:26:18 -04:00
2024-09-20 20:01:55 -04:00
- name: Set DEB_FILE environment variable
run: echo "DEB_FILE=$(find . -type f -name '*.deb' | head -n 1)" >> $GITHUB_ENV
2024-09-20 19:26:18 -04:00
- name: Upload redist.zip to release
2024-09-20 19:29:48 -04:00
uses: softprops/action-gh-release@v1
2024-09-20 19:26:18 -04:00
with:
2024-09-20 19:47:30 -04:00
files: redist.zip
2024-09-20 19:29:48 -04:00
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2024-09-20 19:26:18 -04:00
- name: Upload ncc.deb to release
2024-09-20 19:29:48 -04:00
uses: softprops/action-gh-release@v1
2024-09-20 19:26:18 -04:00
with:
2024-09-20 19:47:30 -04:00
files: ${{ env.DEB_FILE }}
2024-09-20 19:29:48 -04:00
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}