Add --build-source flag to ncc build commands

This commit is contained in:
netkas 2024-09-23 13:50:21 -04:00
parent 230f865093
commit cfbbed5c4a
2 changed files with 154 additions and 26 deletions

145
.github/workflows/ci.yml vendored Normal file
View file

@ -0,0 +1,145 @@
name: CI
on:
push:
branches:
- 'master'
release:
types: [created]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
container:
image: php:8.3
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install dependencies
run: |
apt update -yqq
apt install git libpq-dev libzip-dev zip make wget gnupg -yqq
- 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
mv phive.phar /usr/local/bin/phive
- name: Install phab
run: |
phive install phpab --global --trust-gpg-keys 0x2A8299CE842DD38C
- name: Install latest version of NCC
run: |
git clone https://git.n64.cc/nosial/ncc.git
cd ncc
make redist
NCC_DIR=$(find build/ -type d -name "ncc_*" | head -n 1)
if [ -z "$NCC_DIR" ]; then
echo "NCC build directory not found"
exit 1
fi
php "$NCC_DIR/INSTALL" --auto --install-composer
cd .. && rm -rf ncc
- name: Build project
run: |
ncc build --config release --build-source --log-level debug
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: ncc-build
path: build/release/net.nosial.configlib.ncc
test:
needs: build
runs-on: ubuntu-latest
container:
image: php:8.3
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: ncc-build
path: ncc-build # Adjust this to download the artifact directly under 'ncc-build'
- name: Install dependencies
run: |
apt update -yqq
apt install git libpq-dev libzip-dev zip make wget gnupg -yqq
curl -sSLf -o /usr/local/bin/install-php-extensions https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions
chmod +x /usr/local/bin/install-php-extensions
install-php-extensions zip
- 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
mv phive.phar /usr/local/bin/phive
- name: Install phab
run: |
phive install phpab --global --trust-gpg-keys 0x2A8299CE842DD38C
- name: Install latest version of NCC
run: |
git clone https://git.n64.cc/nosial/ncc.git
cd ncc
make redist
NCC_DIR=$(find build/ -type d -name "ncc_*" | head -n 1)
if [ -z "$NCC_DIR" ]; then
echo "NCC build directory not found"
exit 1
fi
php "$NCC_DIR/INSTALL" --auto --install-composer
cd .. && rm -rf ncc
- name: Install NCC packages
run: |
ncc package install --package="ncc-build/net.nosial.configlib.ncc" --reinstall -y --log-level debug
- name: Run PHPUnit tests
run: |
wget https://phar.phpunit.de/phpunit-11.3.phar
php phpunit-11.3.phar --configuration phpunit.xml
release:
needs: [build, test]
permissions: write-all
runs-on: ubuntu-latest
container:
image: php:8.3
if: github.event_name == 'release'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: ncc-build
path: ncc-build
- name: Upload to GitHub Release
uses: softprops/action-gh-release@v1
with:
files: |
ncc-build/net.nosial.configlib.ncc
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View file

@ -1,37 +1,20 @@
# Variables
DEFAULT_CONFIGURATION ?= release
CONFIG ?= release
LOG_LEVEL = debug
OUTDIR = build/$(CONFIG)
PACKAGE = $(OUTDIR)/net.nosial.configlib.ncc
# Default Target
all: release debug release-compressed debug-compressed release-executable debug-executable release-compressed-executable debug-compressed-executable
all: build
# Build Steps
release:
ncc build --config=release --log-level $(LOG_LEVEL)
debug:
ncc build --config=debug --log-level $(LOG_LEVEL)
release-compressed:
ncc build --config=release-compressed --log-level $(LOG_LEVEL)
debug-compressed:
ncc build --config=debug-compressed --log-level $(LOG_LEVEL)
release-executable:
ncc build --config=release-executable --log-level $(LOG_LEVEL)
debug-executable:
ncc build --config=debug-executable --log-level $(LOG_LEVEL)
release-compressed-executable:
ncc build --config=release-compressed-executable --log-level $(LOG_LEVEL)
debug-compressed-executable:
ncc build --config=debug-compressed-executable --log-level $(LOG_LEVEL)
build:
ncc build --config=$(CONFIG) --build-source --log-level $(LOG_LEVEL)
install: release
ncc package install --package=build/release/net.nosial.configlib.ncc --skip-dependencies --build-source --reinstall -y --log-level $(LOG_LEVEL)
test: release
[ -f phpunit.xml ] || { echo "phpunit.xml not found"; exit 1; }
phpunit
install:
ncc package install --package=$(PACKAGE) --skip-dependencies --reinstall -y --log-level $(LOG_LEVEL)
clean:
rm -rf build
.PHONY: all install test clean release debug release-compressed debug-compressed release-executable debug-executable release-compressed-executable debug-compressed-executable
.PHONY: all build install clean