From bdbf19e3497feecb016a5e34d88fb1e94f0f5dd3 Mon Sep 17 00:00:00 2001 From: Nicholas Dille Date: Mon, 28 Oct 2024 16:08:29 +0100 Subject: [PATCH] Added all releases to gitlab pipeline --- k3s.yaml | 39 ++++++++++++++++++++++++++++++++++++++ namespace.yaml | 38 +++++++++++++++++++++++++++++++++++++ nodejs-lts.yaml | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ passage.yaml | 44 +++++++++++++++++++++++++++++++++++++++++++ python-3.12.yaml | 47 ++++++++++++++++++++++++++++++++++++++++++++++ python.yaml | 47 ++++++++++++++++++++++++++++++++++++++++++++++ renovate.json | 7 ++----- rke2.yaml | 39 ++++++++++++++++++++++++++++++++++++++ 8 files changed, 305 insertions(+), 5 deletions(-) create mode 100644 k3s.yaml create mode 100644 namespace.yaml create mode 100644 nodejs-lts.yaml create mode 100644 passage.yaml create mode 100644 python-3.12.yaml create mode 100644 python.yaml create mode 100644 rke2.yaml diff --git a/k3s.yaml b/k3s.yaml new file mode 100644 index 0000000..6242973 --- /dev/null +++ b/k3s.yaml @@ -0,0 +1,39 @@ +k3s-check: + image: registry.gitlab.com/uniget-org/images/ubuntu:rolling + script: + - | + VERSION="$( + curl --silent --show-error --location --fail \ + --url "https://api.github.com/repos/k3s-io/k3s/releases/latest" \ + | jq --raw-output '.tag_name' \ + | sed -E 's/^v([[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+)\+k3s([[:digit:]]+)$/\1.\2/' + )" + if test -z "${VERSION}"; then + echo "Failed to fetch latest tag and extract version from GitHub" + exit 1 + fi + echo "Got version <${VERSION}>" + + echo "version=${VERSION}" >>variables.env + artifacts: + reports: + dotenv: variables.env + +k3s-release: + needs: + - k3s-check + image: registry.gitlab.com/gitlab-org/release-cli:v0.19.0 + script: + - | + echo "### Releasing k3s v${VERSION}" + if release-cli get --tag-name k3s/${VERSION}; then + echo " Already exists" + exit 0 + + else + release-cli create \ + --name "k3s v${VERSION}" \ + --description "Custom release of k3s v${VERSION}" \ + --tag-name "k3s/${VERSION}" \ + --ref "${CI_COMMIT_SHA}" + fi diff --git a/namespace.yaml b/namespace.yaml new file mode 100644 index 0000000..b4ab9f0 --- /dev/null +++ b/namespace.yaml @@ -0,0 +1,38 @@ +namespace-check: + image: registry.gitlab.com/uniget-org/images/ubuntu:rolling + script: + - | + VERSION="$( + curl --silent --show-error --location --fail https://github.com/namespacelabs/homebrew-namespace/raw/main/nsc.rb \ + | grep version \ + | cut -d'"' -f2 + )" + if test -z "${VERSION}"; then + echo "Failed to fetch latest tag and extract version from GitHub" + exit 1 + fi + echo "Got version <${VERSION}>" + + echo "version=${VERSION}" >>variables.env + artifacts: + reports: + dotenv: variables.env + +namespace-release: + needs: + - namespace-check + image: registry.gitlab.com/gitlab-org/release-cli:v0.19.0 + script: + - | + echo "### Releasing namespace v${VERSION}" + if release-cli get --tag-name namespace/${VERSION}; then + echo " Already exists" + exit 0 + + else + release-cli create \ + --name "namespace v${VERSION}" \ + --description "Custom release of namespace v${VERSION}" \ + --tag-name "namespace/${VERSION}" \ + --ref "${CI_COMMIT_SHA}" + fi diff --git a/nodejs-lts.yaml b/nodejs-lts.yaml new file mode 100644 index 0000000..baa4274 --- /dev/null +++ b/nodejs-lts.yaml @@ -0,0 +1,49 @@ +nodejs-lts-check: + image: registry.gitlab.com/uniget-org/images/ubuntu:rolling + script: + - | + MAJOR_VERSION="$( + curl --silent --location --fail https://github.com/nodejs/Release/raw/main/schedule.json \ + | jq -r 'to_entries[] | select(.value.maintenance > (now | todate)) | select(.value.lts != null) | select(.value.lts < (now | todate)) | .key' + )" + if test -z "${MAJOR_VERSION}"; then + echo "Failed to fetch latest tag and extract major version from release schedule" + exit 1 + fi + echo "### Found LTS major version ${MAJOR_VERSION}" + + VERSION="$( + git ls-remote https://github.com/nodejs/node "refs/tags/${MAJOR_VERSION}.*" \ + | grep -v '\^{}' \ + | cut -f2 | cut -d/ -f3 | tr -d v \ + | sort -Vr | head -1 + )" + if test -z "${VERSION}"; then + echo "Failed to fetch tag and extract version from GitHub" + exit 1 + fi + echo "### Found LTS version ${VERSION}" + + echo "version=${VERSION}" >>variables.env + artifacts: + reports: + dotenv: variables.env + +nodejs-lts-release: + needs: + - nodejs-lts-check + image: registry.gitlab.com/gitlab-org/release-cli:v0.19.0 + script: + - | + echo "### Releasing nodejs-lts v${VERSION}" + if release-cli get --tag-name nodejs-lts/${VERSION}; then + echo " Already exists" + exit 0 + + else + release-cli create \ + --name "nodejs-lts v${VERSION}" \ + --description "Custom release of nodejs-lts v${VERSION}" \ + --tag-name "nodejs-lts/${VERSION}" \ + --ref "${CI_COMMIT_SHA}" + fi diff --git a/passage.yaml b/passage.yaml new file mode 100644 index 0000000..4a73f8b --- /dev/null +++ b/passage.yaml @@ -0,0 +1,44 @@ +passage-check: + image: registry.gitlab.com/uniget-org/images/ubuntu:rolling + script: + - | + git clone https://github.com/FiloSottile/passage + cd passage + + VERSION="$(git rev-list --count --all)" + if test -z "${VERSION}"; then + echo "Failed to count commits" + exit 1 + fi + + COMMIT="$(git rev-parse --short HEAD)" + if test -z "${COMMIT}"; then + echo "Failed to get short commit hash" + exit 1 + fi + + echo "Got version <${VERSION}.${COMMIT}>" + + echo "version=${VERSION}.${COMMIT}" >>variables.env + artifacts: + reports: + dotenv: variables.env + +passage-release: + needs: + - passage-check + image: registry.gitlab.com/gitlab-org/release-cli:v0.19.0 + script: + - | + echo "### Releasing passage v${VERSION}" + if release-cli get --tag-name passage/${VERSION}; then + echo " Already exists" + exit 0 + + else + release-cli create \ + --name "passage v${VERSION}" \ + --description "Custom release of passage v${VERSION}" \ + --tag-name "passage/${VERSION}" \ + --ref "${CI_COMMIT_SHA}" + fi diff --git a/python-3.12.yaml b/python-3.12.yaml new file mode 100644 index 0000000..b552bf4 --- /dev/null +++ b/python-3.12.yaml @@ -0,0 +1,47 @@ +python-3.12-check: + image: registry.gitlab.com/uniget-org/images/ubuntu:rolling + variables: + # renovate: datasource=github-releases depName=indygreg/python-build-standalone versioning=loose + INDYGREG_PYTHON_BUILD_STANDALONE_VERSION: 20241016 + script: + - | + # Find cpython-${PYTHON_VERSION}+${version}-${arch}-unknown-linux-musl-install_only.tar.gz + VERSION="$( + curl --silent --show-error --location --fail \ + --url "https://api.github.com/repos/indygreg/python-build-standalone/releases/tags/${INDYGREG_PYTHON_BUILD_STANDALONE_VERSION}" \ + | jq --raw-output '.assets[].name' \ + | grep -E -- '-x86_64-unknown-linux-musl-install_only.tar.gz$' \ + | sed -E 's/^cpython-([^+]+)\+.+$/\1/' \ + | grep -P '^3\.12\.\d+$' \ + | sort -Vr \ + | head -n 1 + )" + if test -z "${VERSION}"; then + echo "Failed to fetch latest tag and extract version from GitHub" + exit 1 + fi + echo "Got version <${VERSION}>" + + echo "version=${VERSION}.${INDYGREG_PYTHON_BUILD_STANDALONE_VERSION}" >>variables.env + artifacts: + reports: + dotenv: variables.env + +python-3.12-release: + needs: + - python-3.12-check + image: registry.gitlab.com/gitlab-org/release-cli:v0.19.0 + script: + - | + echo "### Releasing python-3.12 v${VERSION}" + if release-cli get --tag-name python-3.12/${VERSION}; then + echo " Already exists" + exit 0 + + else + release-cli create \ + --name "python-3.12 v${VERSION}" \ + --description "Custom release of python-3.12 v${VERSION}" \ + --tag-name "python-3.12/${VERSION}" \ + --ref "${CI_COMMIT_SHA}" + fi diff --git a/python.yaml b/python.yaml new file mode 100644 index 0000000..8197dc6 --- /dev/null +++ b/python.yaml @@ -0,0 +1,47 @@ +k3s-check: + image: registry.gitlab.com/uniget-org/images/ubuntu:rolling + variables: + # renovate: datasource=github-releases depName=indygreg/python-build-standalone versioning=loose + INDYGREG_PYTHON_BUILD_STANDALONE_VERSION: 20241016 + script: + - | + # Find cpython-${PYTHON_VERSION}+${version}-${arch}-unknown-linux-musl-install_only.tar.gz + VERSION="$( + curl --silent --show-error --location --fail \ + --url "https://api.github.com/repos/indygreg/python-build-standalone/releases/tags/${INDYGREG_PYTHON_BUILD_STANDALONE_VERSION}" \ + | jq --raw-output '.assets[].name' \ + | grep -E -- '-x86_64-unknown-linux-musl-install_only.tar.gz$' \ + | sed -E 's/^cpython-([^+]+)\+.+$/\1/' \ + | grep -P '^\d+\.\d+\.\d+$' \ + | sort -Vr \ + | head -n 1 + )" + if test -z "${VERSION}"; then + echo "Failed to fetch latest tag and extract version from GitHub" + exit 1 + fi + echo "Got version <${VERSION}>" + + echo "version=${VERSION}.${INDYGREG_PYTHON_BUILD_STANDALONE_VERSION}" >>variables.env + artifacts: + reports: + dotenv: variables.env + +k3s-release: + needs: + - k3s-check + image: registry.gitlab.com/gitlab-org/release-cli:v0.19.0 + script: + - | + echo "### Releasing k3s v${VERSION}" + if release-cli get --tag-name k3s/${VERSION}; then + echo " Already exists" + exit 0 + + else + release-cli create \ + --name "k3s v${VERSION}" \ + --description "Custom release of k3s v${VERSION}" \ + --tag-name "k3s/${VERSION}" \ + --ref "${CI_COMMIT_SHA}" + fi diff --git a/renovate.json b/renovate.json index 2d8c05a..3e34e2a 100644 --- a/renovate.json +++ b/renovate.json @@ -2,13 +2,10 @@ "$schema": "https://docs.renovatebot.com/renovate-schema.json", "extends": [ "config:base", - "regexManagers:githubActionsVersions" + "regexManagers:githubActionsVersions", + "customManagers:gitlabPipelineVersions" ], "packageRules": [ - { - "matchDatasources": [ "github-actions" ], - "automerge": true - }, { "matchPackageNames": [ "indygreg/python-build-standalone" ], "ignoreTests": true, diff --git a/rke2.yaml b/rke2.yaml new file mode 100644 index 0000000..1564077 --- /dev/null +++ b/rke2.yaml @@ -0,0 +1,39 @@ +rke2-check: + image: registry.gitlab.com/uniget-org/images/ubuntu:rolling + script: + - | + VERSION="$( + curl --silent --show-error --location --fail \ + --url "https://api.github.com/repos/rancher/rke2/releases/latest" \ + | jq --raw-output '.tag_name' \ + | sed -E 's/^v([[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+)\+rke2r([[:digit:]]+)$/\1.\2/' + )" + if test -z "${VERSION}"; then + echo "Failed to fetch latest tag and extract version from GitHub" + exit 1 + fi + echo "Got version <${VERSION}>" + + echo "version=${VERSION}" >>variables.env + artifacts: + reports: + dotenv: variables.env + +rke2-release: + needs: + - rke2-check + image: registry.gitlab.com/gitlab-org/release-cli:v0.19.0 + script: + - | + echo "### Releasing rke2 v${VERSION}" + if release-cli get --tag-name rke2/${VERSION}; then + echo " Already exists" + exit 0 + + else + release-cli create \ + --name "rke2 v${VERSION}" \ + --description "Custom release of rke2 v${VERSION}" \ + --tag-name "rke2/${VERSION}" \ + --ref "${CI_COMMIT_SHA}" + fi