mirror of
https://github.com/djhackersdev/bemanitools-supplement.git
synced 2026-04-26 08:37:27 -05:00
Update build and release pipeline, match with btools
Automatic uploads and releasing when new versions are tagged
This commit is contained in:
parent
bba54c0825
commit
c155775425
147
.gitlab-ci.yml
147
.gitlab-ci.yml
|
|
@ -1,51 +1,134 @@
|
||||||
image: debian
|
#
|
||||||
|
# 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/bemanitools-supplement.zip"
|
||||||
|
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/bemanitools-supplement"
|
||||||
|
|
||||||
|
services:
|
||||||
|
- docker:19.03.8-dind
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- build
|
- build
|
||||||
|
- upload
|
||||||
- release
|
- release
|
||||||
- releasetag
|
|
||||||
|
|
||||||
build:
|
build:
|
||||||
stage: build
|
stage: build
|
||||||
|
only:
|
||||||
|
refs:
|
||||||
|
- tags
|
||||||
before_script:
|
before_script:
|
||||||
- apt-get update && apt-get -qq install git make zip > /dev/null
|
- apk update && apk add make zip > /dev/null
|
||||||
script:
|
script:
|
||||||
- make
|
- make
|
||||||
artifacts:
|
artifacts:
|
||||||
name: "$CI_COMMIT_SHORT_SHA-$CI_JOB_NAME"
|
|
||||||
paths:
|
paths:
|
||||||
- build
|
- build
|
||||||
|
expire_in: 1 week
|
||||||
|
|
||||||
release:
|
upload-package-registry:
|
||||||
stage: release
|
stage: upload
|
||||||
variables:
|
image: curlimages/curl:latest
|
||||||
GIT_STRATEGY: none
|
only:
|
||||||
|
refs:
|
||||||
|
- tags
|
||||||
dependencies:
|
dependencies:
|
||||||
- build
|
- build
|
||||||
before_script:
|
|
||||||
- apt-get update && apt-get -qq install zip > /dev/null
|
|
||||||
script:
|
|
||||||
- mv build/bemanitools-supplements.zip ./bemanitools-supplements.zip
|
|
||||||
- find . -mindepth 1 ! -regex '^./bemanitools-supplements.zip' -delete
|
|
||||||
- unzip bemanitools-supplements.zip
|
|
||||||
- rm bemanitools-supplements.zip
|
|
||||||
artifacts:
|
|
||||||
name: "$CI_COMMIT_SHORT_SHA-$CI_JOB_NAME"
|
|
||||||
paths:
|
|
||||||
- ./*
|
|
||||||
|
|
||||||
releasetag:
|
|
||||||
stage: releasetag
|
|
||||||
dependencies: []
|
|
||||||
before_script:
|
|
||||||
- apt-get update && apt-get -qq install curl > /dev/null
|
|
||||||
script:
|
script:
|
||||||
- |
|
- |
|
||||||
curl --silent --show-error \
|
if [ "${CI_COMMIT_TAG}" ]; then
|
||||||
--data "{\"tag_name\": \"${CI_COMMIT_TAG}\", \"name\": \"${CI_PROJECT_NAME}-${CI_COMMIT_TAG}\", \"description\": \"${CI_COMMIT_TAG_MESSAGE:-No release notes.}\"}" \
|
version="${CI_COMMIT_TAG}"
|
||||||
--header "Content-Type: application/json" \
|
else
|
||||||
--header "Private-Token: ${CI_PRIVATE_TOKEN}" \
|
version="${CI_COMMIT_SHORT_SHA}"
|
||||||
--request POST \
|
fi
|
||||||
"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/releases"
|
- |
|
||||||
|
curl \
|
||||||
|
--silent \
|
||||||
|
--fail \
|
||||||
|
--show-error \
|
||||||
|
--header "JOB-TOKEN: ${CI_JOB_TOKEN}" \
|
||||||
|
--upload-file "${DIST_PACKAGE_RELATIVE_PATH}" \
|
||||||
|
$PACKAGE_REGISTRY_URL/${version}/bemanitools-supplement.zip
|
||||||
|
|
||||||
|
upload-tools-page:
|
||||||
|
stage: upload
|
||||||
|
image: curlimages/curl:latest
|
||||||
only:
|
only:
|
||||||
- tags
|
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-supplement ${version}" \
|
||||||
|
--description="${release_message}" \
|
||||||
|
--tag-name ${version} \
|
||||||
|
--assets-link "{\"name\":\"Distribution binaries\",\"url\":\"${PACKAGE_REGISTRY_URL}/${version}/bemanitools-supplement.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-supplement ${version} released\n${CI_TOOLS_URL}/bemanitools-supplement-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}"
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ $(zipdir)/misc.zip: \
|
||||||
$(V)echo ... $@
|
$(V)echo ... $@
|
||||||
$(V)zip -r $@ $^
|
$(V)zip -r $@ $^
|
||||||
|
|
||||||
$(BUILDDIR)/bemanitools-supplements.zip: \
|
$(BUILDDIR)/bemanitools-supplement.zip: \
|
||||||
$(zipdir)/iidx.zip \
|
$(zipdir)/iidx.zip \
|
||||||
$(zipdir)/misc.zip \
|
$(zipdir)/misc.zip \
|
||||||
README.md \
|
README.md \
|
||||||
|
|
@ -28,4 +28,4 @@ $(BUILDDIR)/bemanitools-supplements.zip: \
|
||||||
$(V)echo ... $@
|
$(V)echo ... $@
|
||||||
$(V)zip -j $@ $^
|
$(V)zip -j $@ $^
|
||||||
|
|
||||||
all: $(BUILDDIR)/bemanitools-supplements.zip
|
all: $(BUILDDIR)/bemanitools-supplement.zip
|
||||||
|
|
|
||||||
28
scripts/ci/create-release-message.sh
Normal file
28
scripts/ci/create-release-message.sh
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
VERSION="$1"
|
||||||
|
|
||||||
|
section_active=""
|
||||||
|
changelog_excerpt=""
|
||||||
|
|
||||||
|
while IFS= read -r line; do
|
||||||
|
if [ "$section_active" ]; then
|
||||||
|
if [[ "$(echo "$line" | grep '^#')" ]]; then
|
||||||
|
section_active=""
|
||||||
|
else
|
||||||
|
changelog_excerpt="$(printf "%s\n%s" "$changelog_excerpt" "$line")"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [ "$line" = "## $VERSION" ]; then
|
||||||
|
section_active="1"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$changelog_excerpt" ]; then
|
||||||
|
printf "%s" "$changelog_excerpt"
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
>&2 echo "Could not find version in changelog: $VERSION"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
Loading…
Reference in New Issue
Block a user