Unverified Commit 9da75407 authored by NexAdn's avatar NexAdn
Browse files

Add Go dep archive creator and publisher

parent 9e8375a7
Pipeline #2683 passed with stages
in 3 minutes and 37 seconds
image: golang:latest
variables:
XQ_PV: 0.0.7
XQ_SRC_URI: 'https://github.com/sibprogrammer/xq/archive/refs/tags/v${PV}.tar.gz'
image: debian:stable
stages:
- make_modcache
- deploy
default:
before_script:
- apt update
- apt -y install golang-go wget tar
make_modcache:xq:
.make_modcache:
stage: make_modcache
script:
- "./make_modcache.sh xq ${XQ_PV} ${XQ_SRC_URI}"
- "./make_modcache.sh ${PN} ${PV} ${SRC_URI}"
artifacts:
paths:
- dep-archives/
xq:
extends: .make_modcache
variables:
PN: "xq"
PV: "0.0.7"
SRC_URI: "https://github.com/sibprogrammer/xq/archive/refs/tags/v${PV}.tar.gz"
deploy-package-registry:
stage: deploy
before_script:
- apt update
- apt -y install curl
script:
- ./upload_dep_archives.sh
rules:
- if: '$CI_COMMIT_BRANCH == "master"'
......@@ -24,8 +24,10 @@ export GOMODCACHE="${PWD}/go-mod"
mkdir -p "${archivedir}" || die "Failed to create ${archivedir}"
cd "${tmpdir}" || die "cd ${tmpdir} failed"
info "Building modcache for ${P} from source ${SRC_URI}"
info "Fetching source"
eval "wget -q ${SRC_URI}" || die
eval "wget --no-verbose ${SRC_URI}" || die "wget failed"
eval "file=\$(basename \"${SRC_URI}\")"
info "Extracting source"
......
#!/bin/bash
cd "$(dirname "${0}")"
: ${DEP_ARCHIVES_DIR:="dep-archives"}
info() {
echo "[INFO] $*"
}
die() {
echo "[ERROR] $*"
exit 1
}
extract_pn_pv() {
local separated_pn_pv="$(echo ${1} | sed 's/^\(.*\)-\(\([[:digit:]].\)*[[:digit:]]\)-deps.tar.*$/\1 \2/g')"
PN="$(echo ${separated_pn_pv} | awk '{print $1;}')"
PV="$(echo ${separated_pn_pv} | awk '{print $2;}')"
P="${PN}-${PV}"
}
which curl 2>&1 || die "Failed to find curl executable"
which sed 2>&1 || die "Failed to find sed executable"
[[ "${CI_JOB_TOKEN}" == "" ]] && die "Empty CI_JOB_TOKEN"
[[ "${CI_API_V4_URL}" == "" ]] && die "Empty CI_API_V4_URL"
[[ "${CI_PROJECT_ID}" == "" ]] && die "Empty CI_PROJECT_ID"
pushd "${DEP_ARCHIVES_DIR}"
for archive in *-deps.tar*; do
! [[ -f "${archive}" ]] && continue
extract_pn_pv "${archive}"
info "Uploading ${P} to package registry"
curl \
--header "JOB-TOKEN: $CI_JOB_TOKEN" \
--upload-file "${archive}" \
"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${PN}/${PV}/${archive}" \
|| die "Failed to upload ${P}"
done
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment