mirror of
https://gitlab.com/Bockiii/deemix-docker.git
synced 2024-08-30 17:32:18 +00:00
45a63d2b9f
Build tag based on deemix commit change version handling also delete deemix version tag packages switch to ID asd asd asd
123 lines
6.2 KiB
YAML
123 lines
6.2 KiB
YAML
variables:
|
|
DOCKER_CLI_EXPERIMENTAL: enabled
|
|
PLATFORMS: "linux/amd64,linux/arm64,linux/arm/v7"
|
|
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic"
|
|
# Docker build will download via this url
|
|
PACKAGE_REGISTRY_URL_STATIC: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/static/static"
|
|
npm_config_cache: "$CI_PROJECT_DIR/.npm"
|
|
PKG_CACHE_PATH: "$CI_PROJECT_DIR/.nodejs-bin"
|
|
YARN_CACHE_FOLDER: "$CI_PROJECT_DIR/.yarn-cache"
|
|
|
|
|
|
stages:
|
|
- build-deemix
|
|
- build-docker-image
|
|
- create-release
|
|
|
|
build-deemix:
|
|
image: node:16
|
|
stage: build-deemix
|
|
cache:
|
|
key: "$CI_COMMIT_REF_SLUG"
|
|
paths:
|
|
- .npm
|
|
- .nodejs-bin
|
|
- .yarn-cache
|
|
policy: pull-push
|
|
|
|
before_script:
|
|
- apt update && apt install -y --no-install-recommends zip git curl jq
|
|
# Dropping static first package first
|
|
- echo get package ID of static
|
|
- export STATIC_ID=$(curl "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages" | jq '.[] | select(.name == "static") | .id')
|
|
- echo $STATIC_ID
|
|
- |
|
|
curl --request DELETE --header "PRIVATE-TOKEN: ${PAT_TOKEN}" "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/${STATIC_ID}"
|
|
# Get deemix version and remove packages if they are already present
|
|
- echo get current version for tagging
|
|
- export DEEMIX_VERSION=$(cat $CI_PROJECT_DIR/version)
|
|
- echo $DEEMIX_VERSION
|
|
- export DEEMIX_VERSION_ID=$(curl "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages" | jq '.[] | select(.name == "'"${DEEMIX_VERSION}"'") | .id')
|
|
- echo $DEEMIX_VERSION_ID
|
|
- |
|
|
curl --request DELETE --header "PRIVATE-TOKEN: ${PAT_TOKEN}" "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/${DEEMIX_VERSION_ID}"
|
|
|
|
script:
|
|
- git clone --depth=1 https://gitlab.com/RemixDev/deemix-gui.git --recursive src
|
|
# Patching pkg.targets to our need
|
|
- jq '.pkg.targets = ["node16-linuxstatic-x64","node16-linuxstatic-arm64","node16-linuxstatic-armv7"]' src/server/package.json > tmp.$$.json && mv tmp.$$.json src/server/package.json
|
|
- cd src
|
|
- ls -alh
|
|
- yarn config set network-timeout 1000000 -g
|
|
- yarn add pkg@latest
|
|
- yarn install-all
|
|
- yarn dist-server
|
|
- ls -al dist/
|
|
# Upload static files (overwritten) per build
|
|
- |
|
|
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file dist/deemix-server-x64 ${PACKAGE_REGISTRY_URL_STATIC}/deemix-server-linux-amd64
|
|
- |
|
|
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file dist/deemix-server-arm64 ${PACKAGE_REGISTRY_URL_STATIC}/deemix-server-linux-arm64
|
|
- |
|
|
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file dist/deemix-server-armv7 ${PACKAGE_REGISTRY_URL_STATIC}/deemix-server-linux-arm
|
|
# Upload per DEEMIX_VERSION
|
|
- |
|
|
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file dist/deemix-server-x64 ${PACKAGE_REGISTRY_URL}/${DEEMIX_VERSION}/${DEEMIX_VERSION}/deemix-server-linux-amd64
|
|
- |
|
|
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file dist/deemix-server-arm64 ${PACKAGE_REGISTRY_URL}/${DEEMIX_VERSION}/${DEEMIX_VERSION}/deemix-server-linux-arm64
|
|
- |
|
|
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file dist/deemix-server-armv7 ${PACKAGE_REGISTRY_URL}/${DEEMIX_VERSION}/${DEEMIX_VERSION}/deemix-server-linux-arm
|
|
only:
|
|
refs:
|
|
- master
|
|
|
|
create-release:
|
|
stage: create-release
|
|
image: registry.gitlab.com/gitlab-org/release-cli:latest
|
|
#rules:
|
|
# - if: $CI_COMMIT_TAG
|
|
script:
|
|
- export DATE=$(date +%Y%m%d)
|
|
- export DEEMIX_VERSION=$(cat $CI_PROJECT_DIR/version)
|
|
- |
|
|
release-cli create --name "Release $DEEMIX_VERSION" --tag-name $DEEMIX_VERSION --description "rollback to this version by changing the TAG release code above, registry.gitlab.com/bockiii/deemix-docker:TAG" \
|
|
--assets-link "{\"name\":\"deemix-server-linux-amd64\",\"url\":\"${PACKAGE_REGISTRY_URL}/${DEEMIX_VERSION}/${DEEMIX_VERSION}/deemix-server-linux-amd64\"}" \
|
|
--assets-link "{\"name\":\"deemix-server-linux-arm64\",\"url\":\"${PACKAGE_REGISTRY_URL}/${DEEMIX_VERSION}/${DEEMIX_VERSION}/deemix-server-linux-arm64\"}" \
|
|
--assets-link "{\"name\":\"deemix-server-linux-armv7\",\"url\":\"${PACKAGE_REGISTRY_URL}/${DEEMIX_VERSION}/${DEEMIX_VERSION}/deemix-server-linux-arm\"}" \
|
|
--assets-link "{\"name\":\"deemix-server-linux-static-amd64\",\"url\":\"${PACKAGE_REGISTRY_URL_STATIC}/deemix-server-linux-amd64\"}" \
|
|
--assets-link "{\"name\":\"deemix-server-linux-static-arm64\",\"url\":\"${PACKAGE_REGISTRY_URL_STATIC}/deemix-server-linux-arm64\"}" \
|
|
--assets-link "{\"name\":\"deemix-server-linux-static-armv7\",\"url\":\"${PACKAGE_REGISTRY_URL_STATIC}/deemix-server-linux-arm\"}" \
|
|
--assets-link "{\"name\":\"deemix-server-docker-pull\",\"url\":\"https://registry.gitlab.com/bockiii/deemix-docker:${DEEMIX_VERSION}\"}"
|
|
only:
|
|
refs:
|
|
- master
|
|
|
|
build-docker-image:
|
|
image: docker:20
|
|
stage: build-docker-image
|
|
services:
|
|
- docker:dind
|
|
before_script:
|
|
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
|
|
- apk add --update curl jq && rm -rf /var/cache/apk/*
|
|
- export CI_JOB_TIMESTAMP=$(date --utc -Iseconds)
|
|
- export DATE=$(date +%Y%m%d)
|
|
- export DEEMIX_VERSION=$(cat $CI_PROJECT_DIR/version)
|
|
script:
|
|
# Download latest buildx bin from github
|
|
- mkdir -p ~/.docker/cli-plugins/
|
|
- BUILDX_LATEST_BIN_URI=$(curl -s -L https://github.com/docker/buildx/releases/latest | grep 'linux-amd64' | grep 'href' | sed 's/.*href="/https:\/\/github.com/g; s/amd64".*/amd64/g')
|
|
- curl -s -L ${BUILDX_LATEST_BIN_URI} -o ~/.docker/cli-plugins/docker-buildx
|
|
- chmod a+x ~/.docker/cli-plugins/docker-buildx
|
|
# Get and run the latest docker/binfmt tag to use its qemu parts
|
|
- BINFMT_IMAGE_TAG=$(curl -s https://registry.hub.docker.com/v2/repositories/docker/binfmt/tags | jq '.results | sort_by(.last_updated)[-1].name' -r)
|
|
- docker run --rm --privileged docker/binfmt:${BINFMT_IMAGE_TAG}
|
|
# create the multibuilder
|
|
- docker buildx create --name multibuilder
|
|
- docker buildx use multibuilder
|
|
# build and push
|
|
- docker buildx build --platform "${PLATFORMS}" --build-arg BUILDDATE=$DATE --build-arg STATIC_URL=$PACKAGE_REGISTRY_URL_STATIC -t ${CI_REGISTRY_IMAGE}:${DEEMIX_VERSION} -t ${CI_REGISTRY_IMAGE} . --push
|
|
only:
|
|
refs:
|
|
- master
|