2020-06-05 20:49:21 +00:00
variables :
DOCKER_CLI_EXPERIMENTAL : enabled
2021-05-29 23:10:34 +00:00
PLATFORMS : "linux/amd64,linux/arm64,linux/arm/v7"
2022-03-17 22:05:39 +00:00
PACKAGE_REGISTRY_URL : "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic"
2022-02-11 09:09:33 +00:00
# Docker build will download via this url
2022-03-12 04:03:00 +00:00
PACKAGE_REGISTRY_URL_STATIC : "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/static/static"
2022-02-11 09:09:33 +00:00
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
2022-03-12 04:03:00 +00:00
before_script :
2022-02-11 09:09:33 +00:00
- apt update && apt install -y --no-install-recommends zip git curl jq
2022-03-12 04:03:00 +00:00
# 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
- |
2022-03-17 22:05:39 +00:00
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}"
2022-03-12 04:03:00 +00:00
script :
2022-03-18 20:06:04 +00:00
- git clone https://gitlab.com/RemixDev/deemix-gui.git --recursive src
2022-02-11 09:09:33 +00:00
# Patching pkg.targets to our need
- cd src
2022-03-18 20:06:04 +00:00
- export DEEMIX_BUILD_SHA=$(curl https://deemix.app/gui/latest | rev | cut -c1-10 | rev)
- git reset --hard --recurse-submodules $DEEMIX_BUILD_SHA
2022-04-28 09:19:56 +00:00
- jq '.pkg.targets = ["node16-linuxstatic-x64","node16-linuxstatic-arm64","node16-linuxstatic-armv7"]' server/package.json > tmp.$$.json && mv tmp.$$.json server/package.json
2022-02-11 09:09:33 +00:00
- ls -alh
- yarn config set network-timeout 1000000 -g
- yarn add pkg@latest
- yarn install-all
- yarn dist-server
- ls -al dist/
2022-03-12 04:03:00 +00:00
# Upload static files (overwritten) per build
2022-02-11 09:09:33 +00:00
- |
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
2022-03-17 22:05:39 +00:00
# Upload per DEEMIX_VERSION
2022-02-11 09:09:33 +00:00
- |
2022-03-17 22:05:39 +00:00
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file dist/deemix-server-x64 ${PACKAGE_REGISTRY_URL}/${DEEMIX_VERSION}/${DEEMIX_VERSION}/deemix-server-linux-amd64
2022-02-11 09:09:33 +00:00
- |
2022-03-17 22:05:39 +00:00
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file dist/deemix-server-arm64 ${PACKAGE_REGISTRY_URL}/${DEEMIX_VERSION}/${DEEMIX_VERSION}/deemix-server-linux-arm64
2022-02-11 09:09:33 +00:00
- |
2022-03-17 22:05:39 +00:00
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file dist/deemix-server-armv7 ${PACKAGE_REGISTRY_URL}/${DEEMIX_VERSION}/${DEEMIX_VERSION}/deemix-server-linux-arm
2022-02-11 09:09:33 +00:00
only :
refs :
- master
2020-06-05 20:49:21 +00:00
2022-02-11 09:09:33 +00:00
create-release :
stage : create-release
image : registry.gitlab.com/gitlab-org/release-cli:latest
#rules:
2022-03-12 04:03:00 +00:00
# - if: $CI_COMMIT_TAG
2022-02-11 09:09:33 +00:00
script :
2022-03-17 22:05:39 +00:00
- export DATE=$(date +%Y%m%d)
- export DEEMIX_VERSION=$(cat $CI_PROJECT_DIR/version)
2022-02-11 09:09:33 +00:00
- |
2022-03-17 22:05:39 +00:00
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\"}" \
2022-02-11 09:09:33 +00:00
--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\"}" \
2022-03-17 22:05:39 +00:00
--assets-link "{\"name\":\"deemix-server-docker-pull\",\"url\":\"https://registry.gitlab.com/bockiii/deemix-docker:${DEEMIX_VERSION}\"}"
2022-02-11 09:09:33 +00:00
only :
refs :
- master
2020-06-05 20:49:21 +00:00
2022-02-11 09:09:33 +00:00
build-docker-image :
2022-03-12 04:03:00 +00:00
image : docker:20
2022-02-11 09:09:33 +00:00
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)
2022-03-17 22:05:39 +00:00
- export DEEMIX_VERSION=$(cat $CI_PROJECT_DIR/version)
2020-06-05 20:49:21 +00:00
script :
2021-05-29 23:10:34 +00:00
# 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
2022-02-11 09:09:33 +00:00
- docker buildx use multibuilder
2022-03-12 04:03:00 +00:00
# build and push
2022-03-17 22:05:39 +00:00
- 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
2022-02-11 09:09:33 +00:00
only :
refs :
- master