From 55bce0a4fa77f1eead3f3e239e1897f35a9d06e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20D=C5=82ugosz?= Date: Thu, 18 May 2023 11:35:18 +0200 Subject: [PATCH 1/7] added debian buster and ubuntu to packages build job --- .circleci/template.yml | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/.circleci/template.yml b/.circleci/template.yml index e560fe42d85..56fd09ee939 100644 --- a/.circleci/template.yml +++ b/.circleci/template.yml @@ -706,7 +706,7 @@ jobs: type: executor platform: type: enum - enum: [centos_7, debian_bullseye] + enum: [centos_7, debian_bullseye, debian_buster, ubuntu_jammy, ubuntu_focal, ubuntu_bionic] description: Platform type otp_package: type: string @@ -757,6 +757,34 @@ workflows: context: mongooseim-org otp_package: "25.0.1-1" filters: *all_tags + - package: + name: debian_buster + executor: otp_25 + platform: debian_buster + context: mongooseim-org + otp_package: "25.0.1-1" + filters: *all_tags + - package: + name: ubuntu_jammy + executor: otp_25 + platform: ubuntu_jammy + context: mongooseim-org + otp_package: "25.0.1-1" + filters: *all_tags + - package: + name: ubuntu_focal + executor: otp_25 + platform: ubuntu_focal + context: mongooseim-org + otp_package: "25.0.1-1" + filters: *all_tags + - package: + name: ubuntu_bionic + executor: otp_25 + platform: ubuntu_bionic + context: mongooseim-org + otp_package: "25.0.1-1" + filters: *all_tags # ======== BASE DOCKER BUILDS ======== - build_in_docker: name: otp_25_docker From ecea23497ec1ad5e477cd364888af66e10f688b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20D=C5=82ugosz?= Date: Thu, 18 May 2023 11:58:18 +0200 Subject: [PATCH 2/7] added publish package job --- .circleci/template.yml | 13 +++++------ tools/pkg/Dockerfile_deb | 3 --- tools/pkg/publish.sh | 48 ++++++++++++---------------------------- 3 files changed, 19 insertions(+), 45 deletions(-) diff --git a/.circleci/template.yml b/.circleci/template.yml index 56fd09ee939..931f1ccb6e3 100644 --- a/.circleci/template.yml +++ b/.circleci/template.yml @@ -706,7 +706,7 @@ jobs: type: executor platform: type: enum - enum: [centos_7, debian_bullseye, debian_buster, ubuntu_jammy, ubuntu_focal, ubuntu_bionic] + enum: [centos_7, debian_bullseye, debian_buster, ubuntu_xenial, ubuntu_focal, ubuntu_bionic] description: Platform type otp_package: type: string @@ -722,6 +722,10 @@ jobs: name: Build package command: | ./tools/test.sh -p pkg -s false + - run: + name: Publish package + command: | + ./tools/pkg/publish.sh filters: &all_tags tags: @@ -764,13 +768,6 @@ workflows: context: mongooseim-org otp_package: "25.0.1-1" filters: *all_tags - - package: - name: ubuntu_jammy - executor: otp_25 - platform: ubuntu_jammy - context: mongooseim-org - otp_package: "25.0.1-1" - filters: *all_tags - package: name: ubuntu_focal executor: otp_25 diff --git a/tools/pkg/Dockerfile_deb b/tools/pkg/Dockerfile_deb index 76fe75f520a..b4f2b0d42cb 100644 --- a/tools/pkg/Dockerfile_deb +++ b/tools/pkg/Dockerfile_deb @@ -3,9 +3,6 @@ ARG dockerfile_platform FROM $dockerfile_platform AS builder -# Update repositories -RUN sed -i 's/\/updates/-security/g' /etc/apt/sources.list - # Install build deps ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update diff --git a/tools/pkg/publish.sh b/tools/pkg/publish.sh index d669da4717d..e0f2da9aef4 100755 --- a/tools/pkg/publish.sh +++ b/tools/pkg/publish.sh @@ -1,41 +1,21 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash set -e -# Params - override for your env -SHA256SUM="shasum -a 256" -REMOTE_SHA256SUM=sha256sum -PACKAGES_LOCAL=packages -. env/publish +cd tools/pkg/packages +PACKAGE_NAME=$(ls) +PKG_PROFILE=packages +prefix=${pkg_PLATFORM/_//} -# CLI arguments -VERSION=${1:-"(missing)"} -REVISION=${2:-1} - -if [ x"$VERSION" = x"(missing)" ]; then - echo "usage: $0 VERSION [REVISION]" - echo - echo Look for package \$VERSION-\$REVISION and publish to $PACKAGES_HOST. - exit 1 +if which aws ; then + echo "aws tool ready" +else + curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" + unzip -q awscliv2.zip + sudo ./aws/install fi -set +e -PKG=$(ls -1 ${PACKAGES_LOCAL} | grep "$VERSION-$REVISION" | head -1) -if [ -z "$PKG" ]; then - echo "$0: can't find package version $VERSION-$REVISION" - exit 2 -fi -set -e +aws configure set aws_access_key_id $PKG_ACCESS_KEY_ID --profile $PKG_PROFILE +aws configure set aws_secret_access_key $PKG_SECRET_ACCESS_KEY --profile $PKG_PROFILE -rsync $PACKAGES_LOCAL/$PKG $PACKAGES_HOST:$PACKAGES_PATH -CHKSUM=$($SHA256SUM $PACKAGES_LOCAL/$PKG) -REMOTE_CHKSUM=$(ssh $PACKAGES_HOST "cd $PACKAGES_PATH && $REMOTE_SHA256SUM $PKG") - -if [ x"$(echo $CHKSUM | cut -d" " -f1)" != x"$(echo $REMOTE_CHKSUM | cut -d" " -f1)" ]; then - echo "$0: checksum mismatch - try again or check your connection" - exit 3 -fi -ssh $PACKAGES_HOST "sed -i /$VERSION-$REVISION/d $PACKAGES_PATH/sha256sum " \ - "&& echo $REMOTE_CHKSUM >> $PACKAGES_PATH/sha256sum" -echo Package $PKG is now public at: -echo https://$PACKAGES_HOST/$PACKAGES_PROJECT/$PKG +aws s3 cp ${PACKAGE_NAME} s3://arn:aws:s3:${PKG_AWS_REGION}:767271724337:accesspoint/mim-packages/$prefix/${PACKAGE_NAME} --acl public-read --profile $PKG_PROFILE --region $PKG_AWS_REGION From 5b5190337cfdbdd26edd5cb53577e2ce91f7fd82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20D=C5=82ugosz?= Date: Tue, 23 May 2023 11:49:57 +0200 Subject: [PATCH 3/7] added otp version info to package name --- tools/pkg/Dockerfile_deb | 2 +- tools/pkg/Dockerfile_rpm | 2 +- tools/pkg/scripts/deb/build_package.sh | 3 ++- tools/pkg/scripts/rpm/build_package.sh | 3 ++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/pkg/Dockerfile_deb b/tools/pkg/Dockerfile_deb index b4f2b0d42cb..4ef4c41c6fa 100644 --- a/tools/pkg/Dockerfile_deb +++ b/tools/pkg/Dockerfile_deb @@ -29,7 +29,7 @@ RUN cp -r ./mongooseim/tools/pkg/scripts/deb . ARG version ARG revision -RUN ./deb/build_package.sh $version $revision +RUN ./deb/build_package.sh $version $revision $erlang_version # Create image for sharing and validation of built package FROM $dockerfile_platform diff --git a/tools/pkg/Dockerfile_rpm b/tools/pkg/Dockerfile_rpm index 943757935bb..cce40b47701 100644 --- a/tools/pkg/Dockerfile_rpm +++ b/tools/pkg/Dockerfile_rpm @@ -45,7 +45,7 @@ RUN cp ./BUILD/mongooseim/tools/pkg/scripts/rpm/mongooseim.service \ ARG version ARG revision -RUN ./BUILD/mongooseim/tools/pkg/scripts/rpm/build_package.sh $version $revision +RUN ./BUILD/mongooseim/tools/pkg/scripts/rpm/build_package.sh $version $revision $erlang_version # Create image for sharing and validation of built package FROM $dockerfile_platform diff --git a/tools/pkg/scripts/deb/build_package.sh b/tools/pkg/scripts/deb/build_package.sh index c82adf82d88..3a4ae44be01 100755 --- a/tools/pkg/scripts/deb/build_package.sh +++ b/tools/pkg/scripts/deb/build_package.sh @@ -3,6 +3,7 @@ set -e version=$1 revision=$2 +otp_version=$3 arch="amd64" @@ -43,5 +44,5 @@ source /etc/os-release os=$ID os_version=$VERSION_CODENAME package_os_file_name=${os}~${os_version} -mv mongooseim_*.deb ~/mongooseim_${version}-${revision}~${package_os_file_name}_${arch}.deb +mv mongooseim_*.deb ~/mongooseim_${version}_${revision}_otp_${otp_version/-1/}~${package_os_file_name}_${arch}.deb diff --git a/tools/pkg/scripts/rpm/build_package.sh b/tools/pkg/scripts/rpm/build_package.sh index 524798d69aa..f0d44692fb8 100755 --- a/tools/pkg/scripts/rpm/build_package.sh +++ b/tools/pkg/scripts/rpm/build_package.sh @@ -3,6 +3,7 @@ set -e version=$1 revision=$2 +otp_version=$3 arch="x86_64" package_name_arch="amd64" @@ -20,4 +21,4 @@ os_version=$VERSION_ID package_os_file_name=${os}~${os_version} mv ~/rpmbuild/RPMS/${arch}/mongooseim-${version}-${revision}.${arch}.rpm \ - ~/mongooseim_${version}-${revision}~${package_os_file_name}_${package_name_arch}.rpm + ~/mongooseim_${version}_${revision}_otp_${otp_version/-1/}~${package_os_file_name}_${package_name_arch}.rpm From 8262a83f3d05c612eb37d0e858daa68dbc3d53e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20D=C5=82ugosz?= Date: Tue, 23 May 2023 12:08:43 +0200 Subject: [PATCH 4/7] bump otp version for building debian packages --- .circleci/template.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.circleci/template.yml b/.circleci/template.yml index 931f1ccb6e3..a23f2d475c1 100644 --- a/.circleci/template.yml +++ b/.circleci/template.yml @@ -759,28 +759,28 @@ workflows: executor: otp_25 platform: debian_bullseye context: mongooseim-org - otp_package: "25.0.1-1" + otp_package: "25.3-1" filters: *all_tags - package: name: debian_buster executor: otp_25 platform: debian_buster context: mongooseim-org - otp_package: "25.0.1-1" + otp_package: "25.3-1" filters: *all_tags - package: name: ubuntu_focal executor: otp_25 platform: ubuntu_focal context: mongooseim-org - otp_package: "25.0.1-1" + otp_package: "25.3-1" filters: *all_tags - package: name: ubuntu_bionic executor: otp_25 platform: ubuntu_bionic context: mongooseim-org - otp_package: "25.0.1-1" + otp_package: "25.3-1" filters: *all_tags # ======== BASE DOCKER BUILDS ======== - build_in_docker: From 202384521b592cb1ef3b437b495ad691d9609637 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20D=C5=82ugosz?= Date: Mon, 29 May 2023 10:13:22 +0200 Subject: [PATCH 5/7] Add rockylinux and almalinux package build --- .circleci/template.yml | 18 ++++++++++++++++-- tools/pkg/Dockerfile_rpm | 2 +- tools/test.sh | 2 +- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/.circleci/template.yml b/.circleci/template.yml index a23f2d475c1..593be424cef 100644 --- a/.circleci/template.yml +++ b/.circleci/template.yml @@ -706,7 +706,7 @@ jobs: type: executor platform: type: enum - enum: [centos_7, debian_bullseye, debian_buster, ubuntu_xenial, ubuntu_focal, ubuntu_bionic] + enum: [centos_7, rockylinux_9, rockylinux_8, almalinux_9, almalinux_8, debian_bullseye, debian_buster, ubuntu_xenial, ubuntu_focal, ubuntu_bionic] description: Platform type otp_package: type: string @@ -752,7 +752,21 @@ workflows: executor: otp_25 platform: centos_7 context: mongooseim-org - otp_package: "25.0.1-1" + otp_package: "25.0.3-1" + filters: *all_tags + - package: + name: rockylinux_8 + executor: otp_24 + platform: rockylinux_8 + context: mongooseim-org + otp_package: "24.1.7-1" + filters: *all_tags + - package: + name: almalinux_8 + executor: otp_24 + platform: almalinux_8 + context: mongooseim-org + otp_package: "24.1.7-1" filters: *all_tags - package: name: debian_bullseye diff --git a/tools/pkg/Dockerfile_rpm b/tools/pkg/Dockerfile_rpm index cce40b47701..d5fa8643394 100644 --- a/tools/pkg/Dockerfile_rpm +++ b/tools/pkg/Dockerfile_rpm @@ -19,7 +19,7 @@ RUN yum install -y rpm-build rpmdevtools git make zlib-devel unixODBC-devel gcc # Fix locale setup # See https://github.com/CentOS/sig-cloud-instance-images/issues/71#issuecomment-266957519 ARG dockerfile_platform -RUN if [ "$dockerfile_platform" == "centos:8" ]; then \ +RUN if [ "$dockerfile_platform" == "rockylinux:8" ] || [ "$dockerfile_platform" == "almalinux:8" ]; then \ dnf install -y glibc-locale-source; \ fi RUN localedef -i en_US -f UTF-8 en_US.UTF-8 diff --git a/tools/test.sh b/tools/test.sh index 70652b2b791..a9ddcb2463d 100755 --- a/tools/test.sh +++ b/tools/test.sh @@ -282,7 +282,7 @@ build_pkg () { local esl_erlang_pkg_vsn=$2 local project_root=$(git rev-parse --show-toplevel) - if [[ $platform == centos* ]]; then + if [[ $platform == centos* ]] || [[ $platform == rockylinux* ]] || [[ $platform == almalinux* ]]; then local dockerfile_name="Dockerfile_rpm" elif [[ $platform == debian* ]] || [[ $platform == ubuntu* ]]; then local dockerfile_name="Dockerfile_deb" From 9522a9fe8ba525f6c71b7aff4eedd01c87f80068 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20D=C5=82ugosz?= Date: Fri, 2 Jun 2023 12:10:36 +0200 Subject: [PATCH 6/7] code review follow-up --- tools/pkg/publish.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/pkg/publish.sh b/tools/pkg/publish.sh index e0f2da9aef4..177cdcb661f 100755 --- a/tools/pkg/publish.sh +++ b/tools/pkg/publish.sh @@ -15,7 +15,7 @@ else sudo ./aws/install fi -aws configure set aws_access_key_id $PKG_ACCESS_KEY_ID --profile $PKG_PROFILE -aws configure set aws_secret_access_key $PKG_SECRET_ACCESS_KEY --profile $PKG_PROFILE +aws configure set aws_access_key_id "$PKG_ACCESS_KEY_ID" --profile "$PKG_PROFILE" +aws configure set aws_secret_access_key "$PKG_SECRET_ACCESS_KEY" --profile "$PKG_PROFILE" -aws s3 cp ${PACKAGE_NAME} s3://arn:aws:s3:${PKG_AWS_REGION}:767271724337:accesspoint/mim-packages/$prefix/${PACKAGE_NAME} --acl public-read --profile $PKG_PROFILE --region $PKG_AWS_REGION +aws s3 cp "$PACKAGE_NAME" "s3://arn:aws:s3:$PKG_AWS_REGION:$PKG_USER_ID:accesspoint/mim-packages/$prefix/$PACKAGE_NAME" --acl public-read --profile "$PKG_PROFILE" --region "$PKG_AWS_REGION" From 5c2ed1f22a4b1fc91870083ed0b24060be681d17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20D=C5=82ugosz?= Date: Tue, 13 Jun 2023 10:22:49 +0200 Subject: [PATCH 7/7] Publishing only on release --- .circleci/template.yml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.circleci/template.yml b/.circleci/template.yml index 593be424cef..d876b0dfc7c 100644 --- a/.circleci/template.yml +++ b/.circleci/template.yml @@ -722,10 +722,16 @@ jobs: name: Build package command: | ./tools/test.sh -p pkg -s false - - run: - name: Publish package - command: | - ./tools/pkg/publish.sh + - when: + condition: + matches: + pattern: /^\d+\.\d+\.\d+/ + value: << pipeline.git.tag >> + steps: + - run: + name: Publish package + command: | + ./tools/pkg/publish.sh filters: &all_tags tags: