mirror of
https://github.com/djhackersdev/bemanitools.git
synced 2024-11-12 01:10:49 +01:00
8ab92872ad
Instead of a single big block of code which only shows up as a single command executed, have each command on a separate "line" so they show up on debug output. If one line fails, it's easier to tell which one failed
137 lines
3.5 KiB
YAML
137 lines
3.5 KiB
YAML
#
|
|
# This pipeline requires packages to be switched on under the repository settings. Otherwise, you will 403s when
|
|
# uploading to the package repo is triggered.
|
|
#
|
|
# Variables to setup in GitLab CI/CD settings of the project
|
|
#
|
|
# The variables with BASE64 postfixes need to contain the base64 encoded data. Otherwise, masking
|
|
# in GitLab won't work due to not matching their pre-defined regex
|
|
#
|
|
# CI_PIGSTALL_DATA_PREFIX_BASE64
|
|
# CI_PIGSTALL_LINK_BASE64
|
|
# CI_PIGSTALL_PHP_SESSION_ID
|
|
# CI_PIGSTALL_SESSION_BASE64
|
|
#
|
|
# CI_TOOLS_UPLOAD_KEY
|
|
# CI_TOOLS_UPLOAD_URL
|
|
# CI_TOOLS_URL
|
|
|
|
image: docker:stable
|
|
|
|
variables:
|
|
DOCKER_TLS_CERTDIR: "/certs"
|
|
DIST_PACKAGE_RELATIVE_PATH: "build/docker/bemanitools.zip"
|
|
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/bemanitools"
|
|
|
|
services:
|
|
- docker:19.03.8-dind
|
|
|
|
stages:
|
|
- build
|
|
- upload
|
|
- release
|
|
|
|
build:
|
|
stage: build
|
|
only:
|
|
refs:
|
|
- master
|
|
- tags
|
|
before_script:
|
|
- apk update && apk add make > /dev/null
|
|
script:
|
|
- make build-docker
|
|
artifacts:
|
|
paths:
|
|
- build
|
|
expire_in: 1 week
|
|
|
|
upload-package-registry:
|
|
stage: upload
|
|
image: curlimages/curl:latest
|
|
only:
|
|
refs:
|
|
- master
|
|
- tags
|
|
dependencies:
|
|
- build
|
|
script:
|
|
- |
|
|
if [ "${CI_COMMIT_TAG}" ]; then
|
|
version="${CI_COMMIT_TAG}"
|
|
else
|
|
version="${CI_COMMIT_SHORT_SHA}"
|
|
fi
|
|
- |
|
|
curl \
|
|
--silent \
|
|
--fail \
|
|
--show-error \
|
|
--header "JOB-TOKEN: ${CI_JOB_TOKEN}" \
|
|
--upload-file "${DIST_PACKAGE_RELATIVE_PATH}" \
|
|
$PACKAGE_REGISTRY_URL/${version}/bemanitools.zip
|
|
|
|
upload-tools-page:
|
|
stage: upload
|
|
image: curlimages/curl:latest
|
|
only:
|
|
refs:
|
|
- tags
|
|
dependencies:
|
|
- build
|
|
script:
|
|
- |
|
|
curl \
|
|
--silent \
|
|
--fail \
|
|
--show-error \
|
|
--connect-timeout 5 \
|
|
--max-time 10 \
|
|
--retry 5 \
|
|
-F "key=${CI_TOOLS_UPLOAD_KEY}" \
|
|
-F "filename=${CI_PROJECT_NAME}-v${CI_COMMIT_TAG}.zip" \
|
|
-F "file=@${DIST_PACKAGE_RELATIVE_PATH}" \
|
|
${CI_TOOLS_UPLOAD_URL}
|
|
|
|
release-gitlab:
|
|
stage: release
|
|
image: registry.gitlab.com/gitlab-org/release-cli:v0.8.0
|
|
only:
|
|
refs:
|
|
- tags
|
|
script:
|
|
- version="$CI_COMMIT_TAG"
|
|
- release_message="$(scripts/ci/create-release-message.sh "${version}" < CHANGELOG.md)"
|
|
- |
|
|
release-cli create \
|
|
--name "bemanitools ${version}" \
|
|
--description="${release_message}" \
|
|
--tag-name ${version} \
|
|
--assets-link "{\"name\":\"Distribution binaries\",\"url\":\"${PACKAGE_REGISTRY_URL}/${version}/bemanitools.zip\"}"
|
|
|
|
release-pigstall:
|
|
stage: release
|
|
image: curlimages/curl:latest
|
|
only:
|
|
refs:
|
|
- tags
|
|
script:
|
|
- version="${CI_COMMIT_TAG}"
|
|
- changelog_excerpt="$(scripts/ci/create-release-message.sh "${version}" < CHANGELOG.md)"
|
|
- release_message="$(printf "bemanitools ${version} released\n${CI_TOOLS_URL}/bemanitools-v${version}.zip\n${changelog_excerpt}")"
|
|
- session="$(echo "$CI_PIGSTALL_SESSION_BASE64" | base64 -d)"
|
|
- data_prefix="$(echo "$CI_PIGSTALL_DATA_PREFIX_BASE64" | base64 -d)"
|
|
- link="$(echo "$CI_PIGSTALL_LINK_BASE64" | base64 -d)"
|
|
- |
|
|
curl \
|
|
--silent \
|
|
--fail \
|
|
--connect-timeout 5 \
|
|
--max-time 10 \
|
|
--retry 5 \
|
|
--show-error \
|
|
-H 'Content-Type: application/x-www-form-urlencoded' \
|
|
-H "Cookie: PHPSESSID=$CI_PIGSTALL_PHP_SESSION_ID; session=${session}" \
|
|
--data-raw "${data_prefix}&body=${release_message}" \
|
|
"${link}"
|