ncc/.gitlab-ci.yml

89 lines
2.3 KiB
YAML
Raw Normal View History

2023-08-16 15:47:53 -04:00
image: php:8.2
stages:
- setup
- build
- publish
2023-08-16 15:47:53 -04:00
before_script:
- apt update -yqq
2023-08-16 15:58:07 -04:00
- apt install -yqq git libzip-dev zip make wget gnupg2 libonig-dev libcurl4-openssl-dev
- apt-get clean
2023-08-16 15:47:53 -04:00
# Prepare the environment
setup:
stage: setup
2023-08-16 12:20:16 -04:00
script:
2023-08-16 15:17:48 -04:00
- docker-php-ext-install mbstring ctype posix zip curl fileinfo
2023-03-01 19:08:18 +00:00
2023-08-16 16:50:35 -04:00
# Build the project using the Makefile
build:
stage: build
script:
2023-08-16 12:22:30 -04:00
- wget -O phive.phar https://phar.io/releases/phive.phar
- wget -O phive.phar.asc https://phar.io/releases/phive.phar.asc
- chmod +x phive.phar
- mv phive.phar /usr/local/bin/phive
2023-08-16 15:52:36 -04:00
- phive install phpab --global --trust-gpg-keys 0x2A8299CE842DD38C
- make autoload
2023-08-16 12:22:30 -04:00
- make redist
- make tar
2023-08-16 12:20:16 -04:00
artifacts:
paths:
- build/*.tar.gz
2023-08-16 12:20:16 -04:00
# Build the Alpine Docker image
build-docker-alpine:
stage: build-docker
script:
- |
if [[ ! -z "$CI_COMMIT_TAG" ]]; then
DOCKER_TAG="$CI_COMMIT_TAG-alpine"
else
DOCKER_TAG="$CI_COMMIT_REF_SLUG-alpine"
fi
echo "Building Docker image with tag: $DOCKER_TAG"
docker build -f Dockerfile -t $CI_REGISTRY_IMAGE:$DOCKER_TAG .
docker push $CI_REGISTRY_IMAGE:$DOCKER_TAG
# Build the Debian Docker image
build-docker-debian:
stage: build-docker
script:
- |
if [[ ! -z "$CI_COMMIT_TAG" ]]; then
DOCKER_TAG="$CI_COMMIT_TAG-debian"
else
DOCKER_TAG="$CI_COMMIT_REF_SLUG-debian"
fi
echo "Building Docker image with tag: $DOCKER_TAG"
docker build -f Dockerfile.debian -t $CI_REGISTRY_IMAGE:$DOCKER_TAG .
docker push $CI_REGISTRY_IMAGE:$DOCKER_TAG
# Publish the package
publish:
stage: publish
2023-08-16 12:20:16 -04:00
script:
2023-08-16 12:22:30 -04:00
- |
2023-08-16 15:09:24 -04:00
if [[ ! -z "$CI_COMMIT_TAG" ]]; then
2023-08-16 17:02:09 -04:00
PACKAGE_NAME=$CI_COMMIT_TAG
FILE_NAME="ncc-$CI_COMMIT_TAG.tar.gz"
2023-08-16 12:22:30 -04:00
else
2023-08-16 17:02:09 -04:00
PACKAGE_NAME=$CI_COMMIT_REF_NAME
FILE_NAME="ncc-$CI_COMMIT_REF_NAME.tar.gz"
2023-08-16 12:22:30 -04:00
fi
2023-08-16 17:02:09 -04:00
mv build/*.tar.gz build/$FILE_NAME
echo "Package Name: $PACKAGE_NAME"
echo "File Name: $FILE_NAME"
curl --header "JOB-TOKEN: $CI_JOB_TOKEN" \
2023-08-16 17:02:09 -04:00
--upload-file build/$FILE_NAME \
"https://$CI_SERVER_HOST/api/v4/projects/$CI_PROJECT_ID/packages/generic/$PACKAGE_NAME/$CI_PIPELINE_ID/$FILE_NAME"
only:
- branches
2023-08-16 16:56:58 -04:00
- tags