Installing Samarth packages from Gitlab
Add Gitlab CI file to project
Add a file named .gitlab-ci.yml
to the root of the project.
publish:
image: curlimages/curl:latest
stage: build
variables:
URL: "$CI_SERVER_PROTOCOL://$CI_SERVER_HOST:$CI_SERVER_PORT/api/v4/projects/$CI_PROJECT_ID/packages/composer?job_token=$CI_JOB_TOKEN"
script:
- version=$([[ -z "$CI_COMMIT_TAG" ]] && echo "branch=$CI_COMMIT_REF_NAME" || echo "tag=$CI_COMMIT_TAG")
- insecure=$([ "$CI_SERVER_PROTOCOL" = "http" ] && echo "--insecure" || echo "")
- response=$(curl -s -w "\n%{http_code}" $insecure --data $version $URL)
- code=$(echo "$response" | tail -n 1)
- body=$(echo "$response" | head -n 1)
# Output state information
- if [ $code -eq 201 ]; then
echo "Package created - Code $code - $body";
else
echo "Could not create package - Code $code - $body";
exit 1;
fi
This will publish the package on each commit. Published packages will be visible in the Packages & Registries Tab of the project.
Add repositories to composer
Add the following repository to the composer.json
{
...
"repositories": [
...
{
"type": "composer",
"url": "<git-url>/api/v4/group/17/-/packages/composer/"
}
],
...
"config": {
...
"gitlab-domains": [
"<git-domain>"
],
...
}
...
}
Edit the auth.json file
Add any one of the following to the ~/.config/composer/auth.json
file
{
...
"gitlab-token": {
"<git-domain>": "<gitlab token with api permissions>"
}
...
}
or
{
"http-basic": {
...
"<git-domain>": {
"username" : "___token___",
"password": "<gitlab token with api permissions>"
}
...
}
}