From 0bb682b9bca3930f9cf7981c541ef8745ac216f4 Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Mon, 19 Jun 2023 14:30:01 +0200 Subject: [PATCH 01/32] Prepare CMakeLists.txt for unified builds - Remove CI_BUILD Cmake variable. - Convert CI_TAG from ENV variable to CMake variable - CI_VERSION_PRE_RELEASE can be set in non CI builds --- CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 162b33d5c0..f3e9c3c316 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,7 +23,6 @@ execute_process( OUTPUT_VARIABLE GIT_COMMIT_HASH OUTPUT_STRIP_TRAILING_WHITESPACE) -option(CI_BUILD false) option(CI_VERSION_PRE_RELEASE false) set(COVERAGE @@ -38,18 +37,19 @@ if(MSVC) add_definitions(/MP) endif() +set(CPACK_PACKAGE_VENDOR "Nano Currency") set(CPACK_PACKAGE_VERSION_MAJOR "26") set(CPACK_PACKAGE_VERSION_MINOR "0") set(CPACK_PACKAGE_VERSION_PATCH "0") -if(CI_BUILD AND CI_VERSION_PRE_RELEASE) + +if(CI_VERSION_PRE_RELEASE) set(CPACK_PACKAGE_VERSION_PRE_RELEASE "${CI_VERSION_PRE_RELEASE}") else() set(CPACK_PACKAGE_VERSION_PRE_RELEASE "99") endif() -set(CPACK_PACKAGE_VENDOR "Nano Currency") -if(CI_BUILD) - set(TAG_VERSION_STRING "$ENV{CI_TAG}") +if(CI_TAG) + set(TAG_VERSION_STRING "${CI_TAG}") else() set(TAG_VERSION_STRING "V${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}") From 50d7093f6d866d63d8bca95b8bbf646a9b8eef10 Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Thu, 22 Jun 2023 10:34:35 +0200 Subject: [PATCH 02/32] Prepare build.sh and node Dockerfile for unified builds - add CI_TAG and CI_VERSION_PRE_RELEASE to build.sh - add useful ARG with default values to Dockerfile so they can be passed to the build.sh script --- ci/build.sh | 2 ++ docker/node/Dockerfile | 11 ++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index a238241022..62192e7e7d 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -54,6 +54,8 @@ cmake \ -DNANO_TEST=${NANO_TEST:-OFF} \ -DNANO_GUI=${NANO_GUI:-OFF} \ -DCOVERAGE=${COVERAGE:-OFF} \ +-DCI_TAG=${CI_TAG:-OFF} \ +-DCI_VERSION_PRE_RELEASE=${CI_VERSION_PRE_RELEASE:-OFF} \ ${CMAKE_SANITIZER:-} \ ${CMAKE_QT_DIR:-} \ ${CMAKE_BACKTRACE:-} \ diff --git a/docker/node/Dockerfile b/docker/node/Dockerfile index 53bd060df3..580f6979d1 100644 --- a/docker/node/Dockerfile +++ b/docker/node/Dockerfile @@ -4,9 +4,6 @@ ARG COMPILER=gcc ARG BUILD_TYPE=RelWithDebInfo ARG SANITIZER ARG NANO_NETWORK=live -ARG CI_TAG=DEV_BUILD -ARG CI_BUILD=OFF -ARG CI_VERSION_PRE_RELEASE=OFF # Install build dependencies COPY ./ci/prepare/linux /tmp/prepare @@ -15,6 +12,14 @@ RUN /tmp/prepare/prepare.sh COPY ./ /tmp/src WORKDIR /tmp/src +#Define ARGs for ci/build-node.sh +ARG BUILD_TYPE=RelWidthDebInfo +ARG NANO_TEST=OFF +ARG COVERAGE=OFF +ARG CMAKE_SANITIZER="" +ARG CI_TAG=DEV_BUILD +ARG CI_VERSION_PRE_RELEASE=OFF + # Build node RUN ci/build-node.sh RUN echo ${NANO_NETWORK} >/etc/nano-network From dd5695898cfa0ab29161f5672292724df66cfcd7 Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Mon, 19 Jun 2023 14:45:37 +0200 Subject: [PATCH 03/32] Prepare WIndows for unified builds - remove CI_BUILD - convert DCI_TAG from ENV to CMake variable --- ci/actions/windows/build.ps1 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ci/actions/windows/build.ps1 b/ci/actions/windows/build.ps1 index af867129c5..4d1fd30eb9 100644 --- a/ci/actions/windows/build.ps1 +++ b/ci/actions/windows/build.ps1 @@ -13,13 +13,12 @@ if (${env:artifact} -eq 1) { $env:NETWORK_CFG = "live" } $env:NANO_TEST = "-DNANO_TEST=OFF" - $env:CI_TAG = ${env:TAG} if ([string]::IsNullOrEmpty(${env:VERSION_PRE_RELEASE})) { $env:CI_VERSION_PRE_RELEASE = "OFF" } else { $env:CI_VERSION_PRE_RELEASE = ${env:VERSION_PRE_RELEASE} } - $env:CI = "-DCI_BUILD=ON -DCI_VERSION_PRE_RELEASE=${env:CI_VERSION_PRE_RELEASE}" + $env:CI = "-DCI_TAG=${env:TAG} -DCI_VERSION_PRE_RELEASE=${env:CI_VERSION_PRE_RELEASE}" $env:RUN = "artifact" } else { From f25d684b7b484625e8ab174bcc160f7335d6fe96 Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Mon, 19 Jun 2023 14:40:10 +0200 Subject: [PATCH 04/32] Convert TEST BETA and LIVE variable to NETWORK variable for easier workflow matrix usage --- ci/actions/deploy.sh | 4 ++-- ci/actions/windows/build.ps1 | 4 ++-- ci/actions/windows/deploy.ps1 | 4 ++-- ci/build-deploy.sh | 4 ++-- ci/build-gitlab.sh | 5 ++++- ci/build-rhel.sh | 4 ++-- 6 files changed, 14 insertions(+), 11 deletions(-) diff --git a/ci/actions/deploy.sh b/ci/actions/deploy.sh index eed405e585..06b674617d 100755 --- a/ci/actions/deploy.sh +++ b/ci/actions/deploy.sh @@ -6,9 +6,9 @@ set -o xtrace OS=$(uname) IS_RPM_DEPLOY="${LINUX_RPM:-0}" -if [[ "${BETA:-0}" -eq 1 ]]; then +if [[ "${NETWORK}" == "BETA" ]]; then BUILD="beta" -elif [[ "${TEST:-0}" -eq 1 ]]; then +elif [[ "${NETWORK}" == "TEST" ]]; then BUILD="test" else BUILD="live" diff --git a/ci/actions/windows/build.ps1 b/ci/actions/windows/build.ps1 index 4d1fd30eb9..45d05bea92 100644 --- a/ci/actions/windows/build.ps1 +++ b/ci/actions/windows/build.ps1 @@ -2,11 +2,11 @@ $ErrorActionPreference = "Continue" if (${env:artifact} -eq 1) { $env:BUILD_TYPE = "Release" - if ( ${env:BETA} -eq 1 ) { + if ( ${env:NETWORK} -eq "BETA" ) { $env:NETWORK_CFG = "beta" $env:BUILD_TYPE = "RelWithDebInfo" } - elseif (${env:TEST} -eq 1) { + elseif (${env:NETWORK} -eq "TEST") { $env:NETWORK_CFG = "test" } else { diff --git a/ci/actions/windows/deploy.ps1 b/ci/actions/windows/deploy.ps1 index 167756ec27..b7891cae56 100644 --- a/ci/actions/windows/deploy.ps1 +++ b/ci/actions/windows/deploy.ps1 @@ -1,9 +1,9 @@ $ErrorActionPreference = "Continue" -if ( ${env:BETA} -eq 1 ) { +if ( "${env:NETWORK}" -eq "BETA" ) { $network_cfg = "beta" } -elseif ( ${env:TEST} -eq 1 ) { +elseif ( "${env:NETWORK}" -eq "TEST" ) { $network_cfg = "test" } else { diff --git a/ci/build-deploy.sh b/ci/build-deploy.sh index 25f716e906..c520a3a718 100755 --- a/ci/build-deploy.sh +++ b/ci/build-deploy.sh @@ -15,10 +15,10 @@ mkdir build pushd build CONFIGURATION="Release" -if [[ "${BETA:-0}" -eq 1 ]]; then +if [[ "${NETWORK}" == "BETA" ]]; then NETWORK_CFG="beta" CONFIGURATION="RelWithDebInfo" -elif [[ "${TEST:-0}" -eq 1 ]]; then +elif [[ "${NETWORK}" == "TEST" ]]; then NETWORK_CFG="test" else NETWORK_CFG="live" diff --git a/ci/build-gitlab.sh b/ci/build-gitlab.sh index 83a62e15da..7eb8894e6a 100755 --- a/ci/build-gitlab.sh +++ b/ci/build-gitlab.sh @@ -52,7 +52,10 @@ if [[ ${FLAVOR-_} == "_" ]]; then FLAVOR="" fi -if [[ "${BETA}" -eq 1 ]]; then +if [[ "${NETWORK}" == "TEST" ]]; then + NETWORK_CFG="-DACTIVE_NETWORK=nano_test_network" + CONFIGURATION="RelWithDebInfo" +elif [[ "${NETWORK}" == "BETA" ]]; then NETWORK_CFG="-DACTIVE_NETWORK=nano_beta_network" CONFIGURATION="RelWithDebInfo" else diff --git a/ci/build-rhel.sh b/ci/build-rhel.sh index 6726567504..96c358ef09 100755 --- a/ci/build-rhel.sh +++ b/ci/build-rhel.sh @@ -11,9 +11,9 @@ run_source() { run_build() { mkdir -p ~/rpmbuild/SOURCES/ mv -f ~/nano-${VERSION}.tar.gz ~/rpmbuild/SOURCES/. - if [ "${LIVE:-}" == "1" ]; then + if [[ "${NETWORK}" == "LIVE" ]]; then scl enable gcc-toolset-12 'rpmbuild --nodebuginfo -ba nanocurrency.spec' - elif [ "${BETA:-}" == "1" ]; then + elif [[ "${NETWORK}" == "BETA" ]]; then scl enable gcc-toolset-12 'rpmbuild -ba nanocurrency-beta.spec' else echo "Error: the node network was not defined." From b86b65bceae6f80d3d9ae50caf8a792e966a93f9 Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Mon, 19 Jun 2023 16:55:56 +0200 Subject: [PATCH 05/32] Make docker builds and deploys more modular - Remove dependency on the workflow name - COnvert $GITHUB_WORKFLOW to $NETWORK - Create smaller functions with limited scope - Create similar deploy functions for docker and github container registries (hub.docker and ghcr) --- ci/actions/linux/docker-deploy-env.sh | 8 + ci/actions/linux/docker-impl/docker-common.sh | 155 +++++++++++++----- ci/actions/linux/ghcr-deploy-env.sh | 8 + ci/actions/linux/ghcr-deploy.sh | 8 + ci/actions/linux/ghcr_push.sh | 15 -- 5 files changed, 138 insertions(+), 56 deletions(-) create mode 100755 ci/actions/linux/docker-deploy-env.sh create mode 100755 ci/actions/linux/ghcr-deploy-env.sh create mode 100755 ci/actions/linux/ghcr-deploy.sh delete mode 100755 ci/actions/linux/ghcr_push.sh diff --git a/ci/actions/linux/docker-deploy-env.sh b/ci/actions/linux/docker-deploy-env.sh new file mode 100755 index 0000000000..d7392c0b98 --- /dev/null +++ b/ci/actions/linux/docker-deploy-env.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +set -e +set -x + +source "$(dirname "$BASH_SOURCE")/docker-impl/docker-common.sh" + +docker_deploy_env diff --git a/ci/actions/linux/docker-impl/docker-common.sh b/ci/actions/linux/docker-impl/docker-common.sh index c61e144889..11fd8f1d5a 100755 --- a/ci/actions/linux/docker-impl/docker-common.sh +++ b/ci/actions/linux/docker-impl/docker-common.sh @@ -1,34 +1,35 @@ #!/bin/bash - set -e set -a scripts="$PWD/ci" -CI_BRANCH=$(git branch | cut -f2 -d' ') +CI_BRANCH=$(git rev-parse --abbrev-ref HEAD) tags=() + if [ -n "$CI_TAG" ]; then tags+=("$CI_TAG") elif [ -n "$CI_BRANCH" ]; then CI_TAG=$CI_BRANCH tags+=("$CI_BRANCH") fi -if [[ "$GITHUB_WORKFLOW" = "Live" ]]; then + + +if [[ "$NETWORK" = "LIVE" ]]; then echo "Live" network_tag_suffix='' network="live" -elif [[ "$GITHUB_WORKFLOW" = "Beta" ]]; then +elif [[ "$NETWORK" = "BETA" ]]; then echo "Beta" network_tag_suffix="-beta" network="beta" -elif [[ "$GITHUB_WORKFLOW" = "Test" ]]; then +elif [[ "$NETWORK" = "TEST" ]]; then echo "Test" network_tag_suffix="-test" network="test" fi -if [[ "$GITHUB_WORKFLOW" != "Develop Branch Dockers Deploy" ]]; then - docker_image_name="nanocurrency/nano${network_tag_suffix}" -fi +docker_image_name="nanocurrency/nano${network_tag_suffix}" +ghcr_image_name="ghcr.io/${GITHUB_REPOSITORY}/nano${network_tag_suffix}" docker_build() { @@ -37,44 +38,116 @@ docker_build() ci_version_pre_release="$CI_VERSION_PRE_RELEASE" fi - if [[ "$GITHUB_WORKFLOW" != "Develop Branch Dockers Deploy" ]]; then - ghcr_image_name="ghcr.io/${GITHUB_REPOSITORY}/nano${network_tag_suffix}" - "$scripts"/build-docker-image.sh docker/node/Dockerfile "$docker_image_name" --build-arg NETWORK="$network" --build-arg CI_BUILD=true --build-arg CI_VERSION_PRE_RELEASE="$ci_version_pre_release" --build-arg CI_TAG="$CI_TAG" - for tag in "${tags[@]}"; do - # Sanitize docker tag - # https://docs.docker.com/engine/reference/commandline/tag/ - tag="$(printf '%s' "$tag" | tr -c '[a-z][A-Z][0-9]_.-' -)" - if [ "$tag" != "latest" ]; then - docker tag "$docker_image_name" "${docker_image_name}:$tag" - docker tag "$ghcr_image_name" "${ghcr_image_name}:$tag" - fi - done + build_docker_image "$ci_version_pre_release" + + for tag in "${tags[@]}"; do + local sanitized_tag=$(sanitize_tag "$tag") + tag_docker_image "$sanitized_tag" + done +} + +build_docker_image() { + local ci_version_pre_release="$1" + "$scripts"/build-docker-image.sh docker/node/Dockerfile "$docker_image_name" \ + --build-arg NETWORK="$network" \ + --build-arg CI_VERSION_PRE_RELEASE="$ci_version_pre_release" \ + --build-arg CI_TAG="$CI_TAG" +} + +sanitize_tag() { + local tag="$1" + # Sanitize docker tag + # https://docs.docker.com/engine/reference/commandline/tag/ + tag="$(printf '%s' "$tag" | tr -c '[a-z][A-Z][0-9]_.-' -)" + echo "$tag" +} + +tag_docker_image() { + local tag="$1" + if [ "$tag" != "latest" ]; then + docker tag "$docker_image_name" "${docker_image_name}:$tag" + docker tag "$ghcr_image_name" "${ghcr_image_name}:$tag" fi } + + docker_deploy() { - if [ -n "$DOCKER_PASSWORD" ]; then - echo "$DOCKER_PASSWORD" | docker login -u nanoreleaseteam --password-stdin - if [[ "$GITHUB_WORKFLOW" = "Develop Branch Dockers Deploy" ]]; then - "$scripts"/custom-timeout.sh 30 docker push "nanocurrency/nano-env:base" - "$scripts"/custom-timeout.sh 30 docker push "nanocurrency/nano-env:gcc" - "$scripts"/custom-timeout.sh 30 docker push "nanocurrency/nano-env:clang" - echo "Deployed nano-env" - exit 0 - else - if [[ "$GITHUB_WORKFLOW" = "Live" ]]; then - tags=$(docker images --format '{{.Repository}}:{{.Tag }}' | grep nanocurrency | grep -vE "env|ghcr.io|none|latest") - else - tags=$(docker images --format '{{.Repository}}:{{.Tag }}' | grep nanocurrency | grep -vE "env|ghcr.io|none") - fi - for a in $tags; do - "$scripts"/custom-timeout.sh 30 docker push "$a" - done - echo "$docker_image_name with tags ${tags//$'\n'/' '} deployed" - fi + docker_login "nanoreleaseteam" "$DOCKER_PASSWORD" + if [[ "$NETWORK" = "LIVE" ]]; then + deploy_tags "nanocurrency" "env|ghcr.io|none|latest" else - echo "\$DOCKER_PASSWORD environment variable required" - exit 0 + deploy_tags "nanocurrency" "env|ghcr.io|none" fi } + +ghcr_deploy() +{ + deploy_tags "ghcr.io/${GITHUB_REPOSITORY}" "env|none" +} + +ghcr_deploy_env() +{ + local images=( + "ghcr.io/${GITHUB_REPOSITORY}/nano-env:base" + "ghcr.io/${GITHUB_REPOSITORY}/nano-env:gcc" + "ghcr.io/${GITHUB_REPOSITORY}/nano-env:clang" + "ghcr.io/${GITHUB_REPOSITORY}/nano-env:rhel" + ) + deploy_env_images "${images[@]}" +} + +docker_deploy_env() +{ + docker_login "nanoreleaseteam" "$DOCKER_PASSWORD" + local images=( + "nanocurrency/nano-env:base" + "nanocurrency/nano-env:gcc" + "nanocurrency/nano-env:clang" + ) + deploy_env_images "${images[@]}" +} + +docker_login() +{ + local username=$1 + local password=$2 + + if [ -z "$password" ]; then + echo "\$DOCKER_PASSWORD or \$GHCR_TOKEN environment variable required" + exit 1 + fi + + echo "$password" | docker login -u "$username" --password-stdin +} + +push_docker_image() +{ + local image_name=$1 + "$scripts"/custom-timeout.sh 30 docker push "$image_name" +} + +deploy_env_images() +{ + local images=("$@") + + for image in "${images[@]}"; do + push_docker_image "$image" + done + + echo "Deployed nano-env" +} + +deploy_tags() +{ + local repo=$1 + local exclude_pattern=$2 + local tags=$(docker images --format '{{.Repository}}:{{.Tag }}' | grep "$repo" | grep -vE "$exclude_pattern") + + for tag in $tags; do + push_docker_image "$tag" + done + + echo "$repo with tags ${tags//$'\n'/' '} deployed" +} diff --git a/ci/actions/linux/ghcr-deploy-env.sh b/ci/actions/linux/ghcr-deploy-env.sh new file mode 100755 index 0000000000..69a53d3187 --- /dev/null +++ b/ci/actions/linux/ghcr-deploy-env.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +set -e +set -x + +source "$(dirname "$BASH_SOURCE")/docker-impl/docker-common.sh" + +ghcr_deploy_env \ No newline at end of file diff --git a/ci/actions/linux/ghcr-deploy.sh b/ci/actions/linux/ghcr-deploy.sh new file mode 100755 index 0000000000..c8247f4d3b --- /dev/null +++ b/ci/actions/linux/ghcr-deploy.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +set -e +set -x + +source "$(dirname "$BASH_SOURCE")/docker-impl/docker-common.sh" + +ghcr_deploy \ No newline at end of file diff --git a/ci/actions/linux/ghcr_push.sh b/ci/actions/linux/ghcr_push.sh deleted file mode 100755 index 89ac8ac8a5..0000000000 --- a/ci/actions/linux/ghcr_push.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash -set -e - -scripts="$PWD/ci" -if [[ "$GITHUB_WORKFLOW" = "Develop Branch Dockers Deploy" ]]; then - "$scripts"/custom-timeout.sh 30 docker push "ghcr.io/${GITHUB_REPOSITORY}/nano-env:base" - "$scripts"/custom-timeout.sh 30 docker push "ghcr.io/${GITHUB_REPOSITORY}/nano-env:gcc" - "$scripts"/custom-timeout.sh 30 docker push "ghcr.io/${GITHUB_REPOSITORY}/nano-env:clang" - "$scripts"/custom-timeout.sh 30 docker push "ghcr.io/${GITHUB_REPOSITORY}/nano-env:rhel" -else - tags=$(docker images --format '{{.Repository}}:{{.Tag }}' | grep "ghcr.io" | grep -vE "env|none") - for a in $tags; do - "$scripts"/custom-timeout.sh 30 docker push "$a" - done -fi From 02afcb6af45fe824908143836109b30edda1fdec Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Thu, 22 Jun 2023 10:58:33 +0200 Subject: [PATCH 06/32] Create unified workflow to build TEST BETA and LIVE artifacts - Remove old workflows - Create 1 workflow for all environments (Network Matrix) - Keep current build logic (build scripts still differ per OS) --- .github/workflows/artifacts_build_deploy.yml | 219 ++++++++++++++++++ .github/workflows/beta_artifacts.yml | 205 ---------------- .../beta_artifacts_latest_release_branch.yml | 192 --------------- .github/workflows/live_artifacts.yml | 155 ------------- .github/workflows/test_network_artifacts.yml | 125 ---------- 5 files changed, 219 insertions(+), 677 deletions(-) create mode 100644 .github/workflows/artifacts_build_deploy.yml delete mode 100644 .github/workflows/beta_artifacts.yml delete mode 100644 .github/workflows/beta_artifacts_latest_release_branch.yml delete mode 100644 .github/workflows/live_artifacts.yml delete mode 100644 .github/workflows/test_network_artifacts.yml diff --git a/.github/workflows/artifacts_build_deploy.yml b/.github/workflows/artifacts_build_deploy.yml new file mode 100644 index 0000000000..c8479e214a --- /dev/null +++ b/.github/workflows/artifacts_build_deploy.yml @@ -0,0 +1,219 @@ +name: All (Live Beta Test) +on: + schedule: + - cron: "0 0 * * 3,6" + workflow_dispatch: + inputs: + repo: + description: "repo" + default: "nanocurrency/nano-node" + required: true + ci_tag: + description: "tag to build" + default: "develop" + required: true +env: + artifact: 1 + +jobs: + prepare_build: + runs-on: ubuntu-20.04 + outputs: + CI_TAG: ${{ steps.tag_set.outputs.CI_TAG }} + CI_VERSION_PRE_RELEASE: ${{ steps.tag_set.outputs.CI_VERSION_PRE_RELEASE }} + steps: + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0 + with: + ref: ${{ (github.event.inputs.ci_tag == 'AUTO' || github.event.inputs.ci_tag == '') && 'develop' || github.event.inputs.ci_tag }} + repository: ${{ github.event.inputs.repo || 'nanocurrency/nano-node' }} + - name: Fetch the repository tags + run: git fetch --tags + - name: Set the tag and version + id: tag_set + run: | + if [[ "${{ github.event.inputs.ci_tag }}" == "AUTO" ]] || [[ "${{ github.event.inputs.ci_tag }}" == "" ]]; then + output_var_file="variable_list.txt" + ci/actions/dev-build-tag-gen.sh -o "${output_var_file}" + CI_TAG=$(grep 'build_tag' ${output_var_file} | cut -d= -f2) + CI_VERSION_PRE_RELEASE=$(grep 'version_pre_release' ${output_var_file} | cut -d= -f2) + else + CI_TAG=${{ github.event.inputs.ci_tag }} + CI_VERSION_PRE_RELEASE='OFF' + fi + echo "CI_TAG=${CI_TAG}" >> $GITHUB_ENV + echo "CI_VERSION_PRE_RELEASE=${CI_VERSION_PRE_RELEASE}" >> $GITHUB_ENV + echo "CI_TAG=${CI_TAG}" >> $GITHUB_OUTPUT + echo "CI_VERSION_PRE_RELEASE=${CI_VERSION_PRE_RELEASE}" >> $GITHUB_OUTPUT + - name: Push the new tag + run: | + if [[ "${{ github.event.inputs.ci_tag }}" == "AUTO" ]] || [[ "${{ github.event.inputs.ci_tag }}" == "" ]]; then + # Set git configuration + git config user.name "${GITHUB_ACTOR}" + git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" + # Create and push the tag + git tag -a "${CI_TAG}" -m "This tag was automatically generated by the Beta workflow" + git push origin "${CI_TAG}" + fi + + + osx_job: + needs: prepare_build + runs-on: macOS-12 + timeout-minutes: 90 + strategy: + matrix: + network: ["TEST", "BETA", "LIVE"] + steps: + + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0 + with: + submodules: "recursive" + ref: ${{ needs.prepare_build.outputs.CI_TAG }} + repository: ${{ github.event.inputs.repo }} + - name: Fetch Deps + run: ci/actions/osx/install_deps.sh + - name: Build Artifact + run: NETWORK=${{ matrix.network }} CI_TAG="${{ needs.prepare_build.outputs.CI_TAG }}" CI_VERSION_PRE_RELEASE="${{ needs.prepare_build.outputs.CI_VERSION_PRE_RELEASE }}" ci/build-deploy.sh "/tmp/qt/lib/cmake/Qt5"; + - name: Deploy Artifact + run: ci/actions/deploy.sh + env: + NETWORK: ${{ matrix.network }} + TAG: ${{ github.event.inputs.ci_tag }} + + S3_BUILD_DIRECTORY: ${{ secrets.S3_BUILD_DIRECTORY }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_DEFAULT_REGION: us-east-2 + + + linux_job: + needs: prepare_build + runs-on: ubuntu-22.04 + timeout-minutes: 90 + strategy: + matrix: + network: ["TEST", "BETA", "LIVE"] + steps: + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0 + with: + submodules: "recursive" + ref: ${{ needs.prepare_build.outputs.CI_TAG }} + repository: ${{ github.event.inputs.repo }} + - name: Fetch Deps + env: + COMPILER: gcc + run: ci/actions/linux/install_deps.sh + - name: Build Artifact + run: docker run -v ${GITHUB_WORKSPACE}:/workspace nanocurrency/nano-env:gcc /bin/bash -c "cd /workspace && NETWORK=${{ matrix.network }} CI_TAG=${{ needs.prepare_build.outputs.CI_TAG }} CI_VERSION_PRE_RELEASE=${{ needs.prepare_build.outputs.CI_VERSION_PRE_RELEASE }} ci/build-deploy.sh /usr/lib/x86_64-linux-gnu/cmake/Qt5" + - name: Deploy Artifact + run: ci/actions/deploy.sh + env: + NETWORK: ${{ matrix.network }} + TAG: ${{ github.event.inputs.ci_tag }} + + S3_BUILD_DIRECTORY: ${{ secrets.S3_BUILD_DIRECTORY }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_DEFAULT_REGION: us-east-2 + + linux_rpm_job: + needs: prepare_build + runs-on: ubuntu-22.04 + timeout-minutes: 90 + strategy: + matrix: + network: ["BETA", "LIVE"] #No path to build TEST exists ci/build-rhel.sh + steps: + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0 + with: + submodules: "recursive" + ref: "develop" #build-rhel.sh needs develop branch and then sets the tag + repository: ${{ github.event.inputs.repo }} + - name: RockyLinux 8 Base + run: ci/build-docker-image.sh docker/ci/Dockerfile-rhel nanocurrency/nano-env:rhel + - name: Build Artifact + run: | + mkdir -p ${GITHUB_WORKSPACE}/artifacts + docker run -e NETWORK=${{ matrix.network }} -e TAG=${{ needs.prepare_build.outputs.CI_TAG }} -e REPO_TO_BUILD=${{ github.event.inputs.repo }} -e RPM_RELEASE=1 \ + -v ${GITHUB_WORKSPACE}:/workspace \ + -v ${GITHUB_WORKSPACE}/artifacts:/root/rpmbuild \ + nanocurrency/nano-env:rhel /bin/bash -c "ci/build-rhel.sh" + - name: Deploy Artifacts + run: ci/actions/deploy.sh + env: + LINUX_RPM: 1 + NETWORK: ${{ matrix.network }} + # TAG: ${{ github.event.inputs.ci_tag }} # (not used in the deploy script if LINUX_RPM==1 ) + + S3_BUILD_DIRECTORY: ${{ secrets.S3_BUILD_DIRECTORY }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_DEFAULT_REGION: us-east-2 + + linux_docker_job: + needs: prepare_build + runs-on: ubuntu-22.04 + timeout-minutes: 90 + strategy: + matrix: + network: ["TEST", "BETA", "LIVE"] + steps: + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0 + with: + submodules: "recursive" + ref: ${{ needs.prepare_build.outputs.CI_TAG }} + repository: ${{ github.event.inputs.repo }} + - name: Fetch Deps + env: + COMPILER: gcc + run: ci/actions/linux/install_deps.sh + - name: Build Docker + run: NETWORK=${{ matrix.network }} CI_TAG=${{ needs.prepare_build.outputs.CI_TAG }} CI_VERSION_PRE_RELEASE=${{ needs.prepare_build.outputs.CI_VERSION_PRE_RELEASE }} ci/actions/linux/docker-build.sh + + + - name: Deploy Docker Hub + if: ${{ github.repository == 'nanocurrency/nano-node' }} + run: CI_TAG=${{ needs.prepare_build.outputs.CI_TAG }} ci/actions/linux/docker-deploy.sh + env: + + + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + - name: Login to ghcr.io + uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a #v2.1.0 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Deploy Docker (ghcr.io) + run: ci/actions/linux/ghcr-deploy.sh + + windows_job: + needs: prepare_build + runs-on: windows-latest + timeout-minutes: 90 + strategy: + matrix: + network: ["TEST", "BETA", "LIVE"] + steps: + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0 + with: + submodules: "recursive" + ref: ${{ needs.prepare_build.outputs.CI_TAG }} + repository: ${{ github.event.inputs.repo }} + - name: Fetch Deps + run: ci/actions/windows/install_deps.ps1 + - name: Build Artifact + run: ci/actions/windows/build.ps1 + env: + CSC_LINK: ${{ secrets.CSC_LINK }} + CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }} + - name: Deploy Artifact + run: ci/actions/windows/deploy.ps1 + env: + NETWORK: ${{ matrix.network }} + TAG: ${{ github.event.inputs.ci_tag }} + + S3_BUILD_DIRECTORY: ${{ secrets.S3_BUILD_DIRECTORY }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_DEFAULT_REGION: us-east-2 diff --git a/.github/workflows/beta_artifacts.yml b/.github/workflows/beta_artifacts.yml deleted file mode 100644 index 6f35fadeaf..0000000000 --- a/.github/workflows/beta_artifacts.yml +++ /dev/null @@ -1,205 +0,0 @@ -name: Beta -on: - schedule: - - cron: "0 0 * * 3,6" - workflow_dispatch: - inputs: - repo: - description: "repo" - default: "nanocurrency/nano-node" - required: true - ref: - description: "tag to build" - default: "develop" - required: true -env: - BETA: 1 - artifact: 1 - -jobs: - build_auto_setup_job: - if: ${{ github.event.inputs.ref == '' }} - runs-on: ubuntu-20.04 - outputs: - build_tag: ${{ steps.tag_gen.outputs.build_tag }} - build_number: ${{ steps.tag_gen.outputs.build_number }} - steps: - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0 - with: - ref: "develop" - repository: "nanocurrency/nano-node" - - name: Fetch the repository tags - run: | - git fetch --tags - - name: Generate the new tag - id: tag_gen - run: | - output_var_file="variable_list.txt" - ci/actions/dev-build-tag-gen.sh -o "${output_var_file}" - cat "${output_var_file}" - cat "${output_var_file}" >> $GITHUB_OUTPUT - - name: Push the new tag - run: | - # Set the tag locally - TAG="${{ steps.tag_gen.outputs.build_tag }}" - # Set git configuration - git config user.name "${GITHUB_ACTOR}" - git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" - # Create and push the tag - git tag -a "${TAG}" -m "This tag was automatically generated by the Beta workflow" - git push origin "${TAG}" - - osx_job: - if: ${{ github.event.inputs.ref == '' && needs.build_auto_setup_job.result == 'success' && always() || github.event.inputs.ref != '' && always() }} - needs: build_auto_setup_job - runs-on: macOS-12 - timeout-minutes: 90 - steps: - - name: Set the tag and the pre-release version - run: | - echo "TAG=${{ github.event.inputs.ref == '' && needs.build_auto_setup_job.outputs.build_tag || github.event.inputs.ref }}" >> $GITHUB_ENV - echo "VERSION_PRE_RELEASE=${{ github.event.inputs.ref == '' && needs.build_auto_setup_job.outputs.build_number || 'OFF' }}" >> $GITHUB_ENV - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0 - with: - submodules: "recursive" - ref: ${{ env.TAG }} - repository: ${{ github.event.inputs.repo }} - - name: Fetch Deps - run: ci/actions/osx/install_deps.sh - - name: Build Artifact - run: CI_TAG=${TAG} CI_VERSION_PRE_RELEASE=${VERSION_PRE_RELEASE} ci/build-deploy.sh "/tmp/qt/lib/cmake/Qt5"; - - name: Deploy Artifact - run: ci/actions/deploy.sh - env: - S3_BUILD_DIRECTORY: ${{ secrets.S3_BUILD_DIRECTORY }} - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_DEFAULT_REGION: us-east-2 - - linux_job: - if: ${{ github.event.inputs.ref == '' && needs.build_auto_setup_job.result == 'success' && always() || github.event.inputs.ref != '' && always() }} - needs: build_auto_setup_job - runs-on: ubuntu-20.04 - timeout-minutes: 90 - steps: - - name: Set the tag and the pre-release version - run: | - echo "TAG=${{ github.event.inputs.ref == '' && needs.build_auto_setup_job.outputs.build_tag || github.event.inputs.ref }}" >> $GITHUB_ENV - echo "VERSION_PRE_RELEASE=${{ github.event.inputs.ref == '' && needs.build_auto_setup_job.outputs.build_number || 'OFF' }}" >> $GITHUB_ENV - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0 - with: - submodules: "recursive" - ref: ${{ env.TAG }} - repository: ${{ github.event.inputs.repo }} - - name: Fetch Deps - env: - COMPILER: gcc - run: ci/actions/linux/install_deps.sh - - name: Build Artifact - run: docker run -v ${GITHUB_WORKSPACE}:/workspace nanocurrency/nano-env:gcc /bin/bash -c "cd /workspace && BETA=1 CI_TAG=${TAG} CI_VERSION_PRE_RELEASE=${VERSION_PRE_RELEASE} ci/build-deploy.sh /usr/lib/x86_64-linux-gnu/cmake/Qt5" - - name: Deploy Artifact - run: ci/actions/deploy.sh - env: - S3_BUILD_DIRECTORY: ${{ secrets.S3_BUILD_DIRECTORY }} - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_DEFAULT_REGION: us-east-2 - - linux_rpm_job: - if: ${{ github.event.inputs.ref == '' && needs.build_auto_setup_job.result == 'success' && always() || github.event.inputs.ref != '' && always() }} - needs: build_auto_setup_job - runs-on: ubuntu-22.04 - timeout-minutes: 90 - steps: - - name: Sets the tag and repo variables (to build) - run: | - echo "TAG=${{ github.event.inputs.ref == '' && needs.build_auto_setup_job.outputs.build_tag || github.event.inputs.ref }}" >> $GITHUB_ENV - echo "VERSION_PRE_RELEASE=${{ github.event.inputs.ref == '' && needs.build_auto_setup_job.outputs.build_number || 'OFF' }}" >> $GITHUB_ENV - echo "REPO_TO_BUILD=${{ github.event.inputs.repo }}" >> $GITHUB_ENV - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0 - with: - submodules: "recursive" - ref: ${{ github.ref }} - repository: ${{ github.repository }} - - name: RockyLinux 8 Base - run: ci/build-docker-image.sh docker/ci/Dockerfile-rhel nanocurrency/nano-env:rhel - - name: Build Artifact - run: | - mkdir -p ${GITHUB_WORKSPACE}/artifacts - docker run -e BETA=1 -e TAG=$TAG -e REPO_TO_BUILD=$REPO_TO_BUILD -e RPM_RELEASE=1 \ - -v ${GITHUB_WORKSPACE}:/workspace \ - -v ${GITHUB_WORKSPACE}/artifacts:/root/rpmbuild \ - nanocurrency/nano-env:rhel /bin/bash -c "ci/build-rhel.sh" - - name: Deploy Artifacts - run: ci/actions/deploy.sh - env: - LINUX_RPM: 1 - S3_BUILD_DIRECTORY: ${{ secrets.S3_BUILD_DIRECTORY }} - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_DEFAULT_REGION: us-east-2 - - linux_docker_job: - if: ${{ github.event.inputs.ref == '' && needs.build_auto_setup_job.result == 'success' && always() || github.event.inputs.ref != '' && always() }} - needs: build_auto_setup_job - runs-on: ubuntu-20.04 - timeout-minutes: 90 - steps: - - name: Set the tag and the pre-release version - run: | - echo "TAG=${{ github.event.inputs.ref == '' && needs.build_auto_setup_job.outputs.build_tag || github.event.inputs.ref }}" >> $GITHUB_ENV - echo "VERSION_PRE_RELEASE=${{ github.event.inputs.ref == '' && needs.build_auto_setup_job.outputs.build_number || 'OFF' }}" >> $GITHUB_ENV - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0 - with: - submodules: "recursive" - ref: ${{ env.TAG }} - repository: ${{ github.event.inputs.repo }} - - name: Fetch Deps - env: - COMPILER: gcc - run: ci/actions/linux/install_deps.sh - - name: Build Docker (nanocurrency/nano-beta) - run: CI_TAG=${TAG} CI_VERSION_PRE_RELEASE=${VERSION_PRE_RELEASE} ci/actions/linux/docker-build.sh - - name: Deploy Docker Hub (nanocurrency/nano-beta) - if: ${{ github.repository == 'nanocurrency/nano-node' }} - run: CI_TAG=${TAG} ci/actions/linux/docker-deploy.sh - env: - DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} - - name: Login to ghcr.io - uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a #v2.1.0 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Deploy Docker (ghcr.io) - run: ci/actions/linux/ghcr_push.sh - - windows_job: - if: ${{ github.event.inputs.ref == '' && needs.build_auto_setup_job.result == 'success' && always() || github.event.inputs.ref != '' && always() }} - needs: build_auto_setup_job - runs-on: windows-latest - timeout-minutes: 90 - steps: - - name: Set the tag and the pre-release version - run: | - Write-Output "TAG=${{ github.event.inputs.ref == '' && needs.build_auto_setup_job.outputs.build_tag || github.event.inputs.ref }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - Write-Output "VERSION_PRE_RELEASE=${{ github.event.inputs.ref == '' && needs.build_auto_setup_job.outputs.build_number || 'OFF' }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0 - with: - submodules: "recursive" - ref: ${{ env.TAG }} - repository: ${{ github.event.inputs.repo }} - - name: Fetch Deps - run: ci/actions/windows/install_deps.ps1 - - name: Build Artifact - run: ci/actions/windows/build.ps1 - env: - CSC_LINK: ${{ secrets.CSC_LINK }} - CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }} - - name: Deploy Artifact - run: ci/actions/windows/deploy.ps1 - env: - S3_BUILD_DIRECTORY: ${{ secrets.S3_BUILD_DIRECTORY }} - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_DEFAULT_REGION: us-east-2 diff --git a/.github/workflows/beta_artifacts_latest_release_branch.yml b/.github/workflows/beta_artifacts_latest_release_branch.yml deleted file mode 100644 index 7627a46e58..0000000000 --- a/.github/workflows/beta_artifacts_latest_release_branch.yml +++ /dev/null @@ -1,192 +0,0 @@ -name: Beta (Latest Release Branch) -on: - schedule: - - cron: "0 0 * * 3,6" -env: - BETA: 1 - artifact: 1 - -jobs: - build_auto_setup_job: - runs-on: ubuntu-20.04 - outputs: - build_tag: ${{ steps.tag_gen.outputs.build_tag }} - build_number: ${{ steps.tag_gen.outputs.build_number }} - release_branch: ${{ steps.tag_gen.outputs.release_branch }} - steps: - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0 - with: - ref: "develop" - repository: "nanocurrency/nano-node" - - name: Fetch the repository tags - run: | - git fetch --tags - - name: Generate the new tag - id: tag_gen - run: | - output_var_file="variable_list.txt" - ci/actions/dev-build-tag-gen.sh -r -o "${output_var_file}" - cat "${output_var_file}" - cat "${output_var_file}" >> $GITHUB_OUTPUT - - name: Push the new tag - run: | - # Set the tag locally - TAG="${{ steps.tag_gen.outputs.build_tag }}" - # Set git configuration - git config user.name "${GITHUB_ACTOR}" - git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" - # Set to the specified release branch - git checkout origin/${{ steps.tag_gen.outputs.release_branch }} -b ${{ steps.tag_gen.outputs.release_branch }} - # Create and push the tag - git tag -a "${TAG}" -m "This tag was automatically generated by the Beta workflow" - git push origin "${TAG}" - - osx_job: - needs: build_auto_setup_job - runs-on: macOS-12 - timeout-minutes: 90 - steps: - - name: Set the tag and the pre-release version - run: | - echo "TAG=${{ github.event.inputs.ref == '' && needs.build_auto_setup_job.outputs.build_tag || github.event.inputs.ref }}" >> $GITHUB_ENV - echo "VERSION_PRE_RELEASE=${{ github.event.inputs.ref == '' && needs.build_auto_setup_job.outputs.build_number || 'OFF' }}" >> $GITHUB_ENV - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0 - with: - submodules: "recursive" - ref: ${{ env.TAG }} - repository: ${{ github.event.inputs.repo }} - - name: Fetch Deps - run: ci/actions/osx/install_deps.sh - - name: Build Artifact - run: CI_TAG=${TAG} CI_VERSION_PRE_RELEASE=${VERSION_PRE_RELEASE} ci/build-deploy.sh "/tmp/qt/lib/cmake/Qt5"; - - name: Deploy Artifact - run: ci/actions/deploy.sh - env: - S3_BUILD_DIRECTORY: ${{ secrets.S3_BUILD_DIRECTORY }} - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_DEFAULT_REGION: us-east-2 - - linux_job: - needs: build_auto_setup_job - runs-on: ubuntu-20.04 - timeout-minutes: 90 - steps: - - name: Set the tag and the pre-release version - run: | - echo "TAG=${{ github.event.inputs.ref == '' && needs.build_auto_setup_job.outputs.build_tag || github.event.inputs.ref }}" >> $GITHUB_ENV - echo "VERSION_PRE_RELEASE=${{ github.event.inputs.ref == '' && needs.build_auto_setup_job.outputs.build_number || 'OFF' }}" >> $GITHUB_ENV - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0 - with: - submodules: "recursive" - ref: ${{ env.TAG }} - repository: ${{ github.event.inputs.repo }} - - name: Fetch Deps - env: - COMPILER: gcc - run: ci/actions/linux/install_deps.sh - - name: Build Artifact - run: docker run -v ${GITHUB_WORKSPACE}:/workspace nanocurrency/nano-env:gcc /bin/bash -c "cd /workspace && BETA=1 CI_TAG=${TAG} CI_VERSION_PRE_RELEASE=${VERSION_PRE_RELEASE} ci/build-deploy.sh /usr/lib/x86_64-linux-gnu/cmake/Qt5" - - name: Deploy Artifact - run: ci/actions/deploy.sh - env: - S3_BUILD_DIRECTORY: ${{ secrets.S3_BUILD_DIRECTORY }} - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_DEFAULT_REGION: us-east-2 - - linux_rpm_job: - needs: build_auto_setup_job - runs-on: ubuntu-22.04 - timeout-minutes: 90 - steps: - - name: Sets the tag and repo variables (to build) - run: | - echo "TAG=${{ github.event.inputs.ref == '' && needs.build_auto_setup_job.outputs.build_tag || github.event.inputs.ref }}" >> $GITHUB_ENV - echo "VERSION_PRE_RELEASE=${{ github.event.inputs.ref == '' && needs.build_auto_setup_job.outputs.build_number || 'OFF' }}" >> $GITHUB_ENV - echo "REPO_TO_BUILD=${{ github.event.inputs.repo }}" >> $GITHUB_ENV - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0 - with: - submodules: "recursive" - ref: ${{ github.ref }} - repository: ${{ github.repository }} - - name: RockyLinux 8 Base - run: ci/build-docker-image.sh docker/ci/Dockerfile-rhel nanocurrency/nano-env:rhel - - name: Build Artifact - run: | - mkdir -p ${GITHUB_WORKSPACE}/artifacts - docker run -e BETA=1 -e TAG=$TAG -e REPO_TO_BUILD=$REPO_TO_BUILD -e RPM_RELEASE=1 \ - -v ${GITHUB_WORKSPACE}:/workspace \ - -v ${GITHUB_WORKSPACE}/artifacts:/root/rpmbuild \ - nanocurrency/nano-env:rhel /bin/bash -c "ci/build-rhel.sh" - - name: Deploy Artifacts - run: ci/actions/deploy.sh - env: - LINUX_RPM: 1 - S3_BUILD_DIRECTORY: ${{ secrets.S3_BUILD_DIRECTORY }} - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_DEFAULT_REGION: us-east-2 - - linux_docker_job: - needs: build_auto_setup_job - runs-on: ubuntu-20.04 - timeout-minutes: 90 - steps: - - name: Set the tag and the pre-release version - run: | - echo "TAG=${{ github.event.inputs.ref == '' && needs.build_auto_setup_job.outputs.build_tag || github.event.inputs.ref }}" >> $GITHUB_ENV - echo "VERSION_PRE_RELEASE=${{ github.event.inputs.ref == '' && needs.build_auto_setup_job.outputs.build_number || 'OFF' }}" >> $GITHUB_ENV - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0 - with: - submodules: "recursive" - ref: ${{ env.TAG }} - repository: ${{ github.event.inputs.repo }} - - name: Fetch Deps - env: - COMPILER: gcc - run: ci/actions/linux/install_deps.sh - - name: Build Docker (nanocurrency/nano-beta) - run: CI_TAG=${TAG} CI_VERSION_PRE_RELEASE=${VERSION_PRE_RELEASE} ci/actions/linux/docker-build.sh - - name: Deploy Docker Hub (nanocurrency/nano-beta) - if: ${{ github.repository == 'nanocurrency/nano-node' }} - run: CI_TAG=${TAG} ci/actions/linux/docker-deploy.sh - env: - DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} - - name: Login to ghcr.io - uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a #v2.1.0 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Deploy Docker (ghcr.io) - run: ci/actions/linux/ghcr_push.sh - - windows_job: - needs: build_auto_setup_job - runs-on: windows-latest - timeout-minutes: 90 - steps: - - name: Set the tag and the pre-release version - run: | - Write-Output "TAG=${{ github.event.inputs.ref == '' && needs.build_auto_setup_job.outputs.build_tag || github.event.inputs.ref }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - Write-Output "VERSION_PRE_RELEASE=${{ github.event.inputs.ref == '' && needs.build_auto_setup_job.outputs.build_number || 'OFF' }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0 - with: - submodules: "recursive" - ref: ${{ env.TAG }} - repository: ${{ github.event.inputs.repo }} - - name: Fetch Deps - run: ci/actions/windows/install_deps.ps1 - - name: Build Artifact - run: ci/actions/windows/build.ps1 - env: - CSC_LINK: ${{ secrets.CSC_LINK }} - CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }} - - name: Deploy Artifact - run: ci/actions/windows/deploy.ps1 - env: - S3_BUILD_DIRECTORY: ${{ secrets.S3_BUILD_DIRECTORY }} - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_DEFAULT_REGION: us-east-2 diff --git a/.github/workflows/live_artifacts.yml b/.github/workflows/live_artifacts.yml deleted file mode 100644 index d5fa7df57c..0000000000 --- a/.github/workflows/live_artifacts.yml +++ /dev/null @@ -1,155 +0,0 @@ -name: Live -on: - workflow_dispatch: - inputs: - repo: - description: "repo" - default: "nanocurrency/nano-node" - required: true - ref: - description: "tag to build" - default: "develop" - required: true -env: - artifact: 1 - -jobs: - osx_job: - runs-on: macOS-12 - timeout-minutes: 90 - steps: - - name: tag - run: | - echo "TAG=${{ github.event.inputs.ref }}" >> $GITHUB_ENV - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0 - with: - submodules: "recursive" - ref: ${{ github.event.inputs.ref }} - repository: ${{ github.event.inputs.repo }} - - name: Fetch Deps - run: ci/actions/osx/install_deps.sh - - name: Build Artifact - run: CI_TAG=${TAG} ci/build-deploy.sh "/tmp/qt/lib/cmake/Qt5"; - - name: Deploy Artifact - run: ci/actions/deploy.sh - env: - S3_BUILD_DIRECTORY: ${{ secrets.S3_BUILD_DIRECTORY }} - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_DEFAULT_REGION: us-east-2 - - linux_job: - runs-on: ubuntu-20.04 - timeout-minutes: 90 - steps: - - name: tag - run: | - echo "TAG=${{ github.event.inputs.ref }}" >> $GITHUB_ENV - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0 - with: - submodules: "recursive" - ref: ${{ github.event.inputs.ref }} - repository: ${{ github.event.inputs.repo }} - - name: Fetch Deps - env: - COMPILER: gcc - run: ci/actions/linux/install_deps.sh - - name: Build Artifact - run: docker run -v ${GITHUB_WORKSPACE}:/workspace nanocurrency/nano-env:gcc /bin/bash -c "cd /workspace && CI_TAG=${TAG} ci/build-deploy.sh /usr/lib/x86_64-linux-gnu/cmake/Qt5" - - name: Deploy Artifact - run: ci/actions/deploy.sh - env: - S3_BUILD_DIRECTORY: ${{ secrets.S3_BUILD_DIRECTORY }} - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_DEFAULT_REGION: us-east-2 - - linux_rpm_job: - runs-on: ubuntu-22.04 - timeout-minutes: 90 - steps: - - name: Sets the tag and repo variables (to build) - run: | - echo "TAG=${{ github.event.inputs.ref }}" >> $GITHUB_ENV - echo "REPO_TO_BUILD=${{ github.event.inputs.repo }}" >> $GITHUB_ENV - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0 - with: - submodules: "recursive" - ref: ${{ github.ref }} - repository: ${{ github.repository }} - - name: RockyLinux 8 Base - run: ci/build-docker-image.sh docker/ci/Dockerfile-rhel nanocurrency/nano-env:rhel - - name: Build Artifact - run: | - mkdir -p ${GITHUB_WORKSPACE}/artifacts - docker run -e LIVE=1 -e TAG=$TAG -e REPO_TO_BUILD=$REPO_TO_BUILD -e RPM_RELEASE=1 \ - -v ${GITHUB_WORKSPACE}:/workspace \ - -v ${GITHUB_WORKSPACE}/artifacts:/root/rpmbuild \ - nanocurrency/nano-env:rhel /bin/bash -c "ci/build-rhel.sh" - - name: Deploy Artifacts - run: ci/actions/deploy.sh - env: - LINUX_RPM: 1 - S3_BUILD_DIRECTORY: ${{ secrets.S3_BUILD_DIRECTORY }} - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_DEFAULT_REGION: us-east-2 - - linux_docker_job: - runs-on: ubuntu-20.04 - timeout-minutes: 90 - steps: - - name: tag - run: | - echo "TAG=${{ github.event.inputs.ref }}" >> $GITHUB_ENV - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0 - with: - submodules: "recursive" - ref: ${{ github.event.inputs.ref }} - repository: ${{ github.event.inputs.repo }} - - name: Fetch Deps - env: - COMPILER: gcc - run: ci/actions/linux/install_deps.sh - - name: Build Docker (nanocurrency/nano) - run: CI_TAG=${TAG} ci/actions/linux/docker-build.sh - - name: Deploy Docker Hub (nanocurrency/nano) - if: ${{ github.repository == 'nanocurrency/nano-node' }} - run: CI_TAG=${TAG} ci/actions/linux/docker-deploy.sh - env: - DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} - - name: Login to ghcr.io - uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a #v2.1.0 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Deploy Docker (ghcr.io) - run: ci/actions/linux/ghcr_push.sh - - windows_job: - runs-on: windows-latest - timeout-minutes: 90 - steps: - - name: tag - run: | - Write-Output "TAG=${{ github.event.inputs.ref }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0 - with: - submodules: "recursive" - ref: ${{ github.event.inputs.ref }} - repository: ${{ github.event.inputs.repo }} - - name: Fetch Deps - run: ci/actions/windows/install_deps.ps1 - - name: Build Artifact - run: ci/actions/windows/build.ps1 - env: - CSC_LINK: ${{ secrets.CSC_LINK }} - CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }} - - name: Deploy Artifact - run: ci/actions/windows/deploy.ps1 - env: - S3_BUILD_DIRECTORY: ${{ secrets.S3_BUILD_DIRECTORY }} - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_DEFAULT_REGION: us-east-2 diff --git a/.github/workflows/test_network_artifacts.yml b/.github/workflows/test_network_artifacts.yml deleted file mode 100644 index 2969877691..0000000000 --- a/.github/workflows/test_network_artifacts.yml +++ /dev/null @@ -1,125 +0,0 @@ -name: Test -on: - workflow_dispatch: - inputs: - repo: - description: "repo" - default: "nanocurrency/nano-node" - required: true - ref: - description: "tag to build" - default: "develop" - required: true -env: - artifact: 1 - TEST: 1 - -jobs: - osx_job: - runs-on: macOS-12 - timeout-minutes: 90 - steps: - - name: tag - run: | - echo "TAG=${{ github.event.inputs.ref }}" >> $GITHUB_ENV - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0 - with: - submodules: "recursive" - ref: ${{ github.event.inputs.ref }} - repository: ${{ github.event.inputs.repo }} - - name: Fetch Deps - run: ci/actions/osx/install_deps.sh - - name: Build Artifact - run: CI_TAG=${TAG} ci/build-deploy.sh "/tmp/qt/lib/cmake/Qt5"; - - name: Deploy Artifact - run: ci/actions/deploy.sh - env: - S3_BUILD_DIRECTORY: ${{ secrets.S3_BUILD_DIRECTORY }} - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_DEFAULT_REGION: us-east-2 - - linux_job: - runs-on: ubuntu-20.04 - timeout-minutes: 90 - steps: - - name: tag - run: | - echo "TAG=${{ github.event.inputs.ref }}" >> $GITHUB_ENV - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0 - with: - submodules: "recursive" - ref: ${{ github.event.inputs.ref }} - repository: ${{ github.event.inputs.repo }} - - name: Fetch Deps - env: - COMPILER: gcc - run: ci/actions/linux/install_deps.sh - - name: Build Artifact - run: docker run -e TEST -v ${GITHUB_WORKSPACE}:/workspace nanocurrency/nano-env:gcc /bin/bash -c "cd /workspace && CI_TAG=${TAG} ci/build-deploy.sh /usr/lib/x86_64-linux-gnu/cmake/Qt5" - - name: Deploy Artifact - run: ci/actions/deploy.sh - env: - S3_BUILD_DIRECTORY: ${{ secrets.S3_BUILD_DIRECTORY }} - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_DEFAULT_REGION: us-east-2 - - linux_docker_job: - runs-on: ubuntu-20.04 - timeout-minutes: 90 - steps: - - name: tag - run: | - echo "TAG=${{ github.event.inputs.ref }}" >> $GITHUB_ENV - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0 - with: - submodules: "recursive" - ref: ${{ github.event.inputs.ref }} - repository: ${{ github.event.inputs.repo }} - - name: Fetch Deps - env: - COMPILER: gcc - run: ci/actions/linux/install_deps.sh - - name: Build Docker (nanocurrency/nano) - run: CI_TAG=${TAG} ci/actions/linux/docker-build.sh - - name: Deploy Docker Hub (nanocurrency/nano-test) - if: ${{ github.repository == 'nanocurrency/nano-node' }} - run: CI_TAG=${TAG} ci/actions/linux/docker-deploy.sh - env: - DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} - - name: Login to ghcr.io - uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a #v2.1.0 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Deploy Docker (ghcr.io) - run: ci/actions/linux/ghcr_push.sh - - windows_job: - runs-on: windows-latest - timeout-minutes: 90 - steps: - - name: tag - run: | - Write-Output "TAG=${{ github.event.inputs.ref }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0 - with: - submodules: "recursive" - ref: ${{ github.event.inputs.ref }} - repository: ${{ github.event.inputs.repo }} - - name: Fetch Deps - run: ci/actions/windows/install_deps.ps1 - - name: Build Artifact - run: ci/actions/windows/build.ps1 - env: - CSC_LINK: ${{ secrets.CSC_LINK }} - CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }} - - name: Deploy Artifact - run: ci/actions/windows/deploy.ps1 - env: - S3_BUILD_DIRECTORY: ${{ secrets.S3_BUILD_DIRECTORY }} - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_DEFAULT_REGION: us-east-2 From 847427e1f010a70434d5f2fad935722ffae7d062 Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Thu, 22 Jun 2023 11:07:42 +0200 Subject: [PATCH 07/32] Remove hardcoded repo from build and deploy scripts - skip hub.docker deploys if DOCKER_PASSWORD is not provided - Create DOCKER_HUB variable which defaults to nanocurrency (backwards compatible) - Create DOCKER_USER variable which defaults to nanoreleaseteam (backwards compatible) - create S3_BUCKET_NAME variable that defaults to repo.nano.org if not provided (backwards compatible) - only use S3_BUILD_DIRECTORY if provided --- .github/workflows/artifacts_build_deploy.yml | 26 ++++++++--------- .../develop_branch_dockers_deploy.yml | 11 +++++-- ci/actions/deploy.sh | 29 ++++++++++--------- ci/actions/linux/docker-impl/docker-common.sh | 18 +++++++----- ci/actions/windows/deploy.ps1 | 15 +++++----- 5 files changed, 55 insertions(+), 44 deletions(-) diff --git a/.github/workflows/artifacts_build_deploy.yml b/.github/workflows/artifacts_build_deploy.yml index c8479e214a..0ee8bd810f 100644 --- a/.github/workflows/artifacts_build_deploy.yml +++ b/.github/workflows/artifacts_build_deploy.yml @@ -6,11 +6,11 @@ on: inputs: repo: description: "repo" - default: "nanocurrency/nano-node" - required: true + + ci_tag: description: "tag to build" - default: "develop" + default: "develop" #use AUTO to run the CI build flow required: true env: artifact: 1 @@ -25,7 +25,7 @@ jobs: - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0 with: ref: ${{ (github.event.inputs.ci_tag == 'AUTO' || github.event.inputs.ci_tag == '') && 'develop' || github.event.inputs.ci_tag }} - repository: ${{ github.event.inputs.repo || 'nanocurrency/nano-node' }} + repository: ${{ github.event.inputs.repo || github.repository }} - name: Fetch the repository tags run: git fetch --tags - name: Set the tag and version @@ -79,7 +79,7 @@ jobs: env: NETWORK: ${{ matrix.network }} TAG: ${{ github.event.inputs.ci_tag }} - + S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }} S3_BUILD_DIRECTORY: ${{ secrets.S3_BUILD_DIRECTORY }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} @@ -110,7 +110,7 @@ jobs: env: NETWORK: ${{ matrix.network }} TAG: ${{ github.event.inputs.ci_tag }} - + S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }} S3_BUILD_DIRECTORY: ${{ secrets.S3_BUILD_DIRECTORY }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} @@ -144,7 +144,7 @@ jobs: LINUX_RPM: 1 NETWORK: ${{ matrix.network }} # TAG: ${{ github.event.inputs.ci_tag }} # (not used in the deploy script if LINUX_RPM==1 ) - + S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }} S3_BUILD_DIRECTORY: ${{ secrets.S3_BUILD_DIRECTORY }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} @@ -169,14 +169,14 @@ jobs: run: ci/actions/linux/install_deps.sh - name: Build Docker run: NETWORK=${{ matrix.network }} CI_TAG=${{ needs.prepare_build.outputs.CI_TAG }} CI_VERSION_PRE_RELEASE=${{ needs.prepare_build.outputs.CI_VERSION_PRE_RELEASE }} ci/actions/linux/docker-build.sh - - + - name: Check if secrets.DOCKER_PASSWORD exists + run: echo "DOCKER_PASSWORD_EXISTS=${{ secrets.DOCKER_PASSWORD != '' }}" >> $GITHUB_ENV - name: Deploy Docker Hub - if: ${{ github.repository == 'nanocurrency/nano-node' }} + if: env.DOCKER_PASSWORD_EXISTS == 'true' run: CI_TAG=${{ needs.prepare_build.outputs.CI_TAG }} ci/actions/linux/docker-deploy.sh env: - - + DOCKER_HUB: ${{ secrets.DOCKER_HUB }} + DOCKER_USER: ${{ secrets.DOCKER_USER }} DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} - name: Login to ghcr.io uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a #v2.1.0 @@ -212,7 +212,7 @@ jobs: env: NETWORK: ${{ matrix.network }} TAG: ${{ github.event.inputs.ci_tag }} - + S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }} S3_BUILD_DIRECTORY: ${{ secrets.S3_BUILD_DIRECTORY }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} diff --git a/.github/workflows/develop_branch_dockers_deploy.yml b/.github/workflows/develop_branch_dockers_deploy.yml index a0109415fb..38f263281b 100644 --- a/.github/workflows/develop_branch_dockers_deploy.yml +++ b/.github/workflows/develop_branch_dockers_deploy.yml @@ -7,7 +7,7 @@ on: jobs: linux_job: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0 with: @@ -21,8 +21,13 @@ jobs: username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: Deploy Docker (ghcr.io) - run: ci/actions/linux/ghcr_push.sh + run: ci/actions/linux/ghcr-deploy-env.sh + - name: Check if secrets.DOCKER_PASSWORD exists + run: echo "DOCKER_PASSWORD_EXISTS=${{ secrets.DOCKER_PASSWORD != '' }}" >> $GITHUB_ENV - name: Deploy Docker (nanocurrency/nano-env) - run: ci/actions/linux/docker-deploy.sh + if: env.DOCKER_PASSWORD_EXISTS == 'true' + run: ci/actions/linux/docker-deploy-env.sh env: + DOCKER_HUB: ${{ secrets.DOCKER_HUB }} + DOCKER_USER: ${{ secrets.DOCKER_USER }} DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} diff --git a/ci/actions/deploy.sh b/ci/actions/deploy.sh index 06b674617d..ac4b74c8d0 100755 --- a/ci/actions/deploy.sh +++ b/ci/actions/deploy.sh @@ -5,6 +5,7 @@ set -o nounset set -o xtrace OS=$(uname) IS_RPM_DEPLOY="${LINUX_RPM:-0}" +S3_BUCKET_NAME="${S3_BUCKET_NAME:-repo.nano.org}" if [[ "${NETWORK}" == "BETA" ]]; then BUILD="beta" @@ -14,10 +15,12 @@ else BUILD="live" fi -if [[ "${GITHUB_REPOSITORY:-}" == "nanocurrency/nano-node" ]]; then - DIRECTORY=$BUILD -else +if [[ -n "${S3_BUILD_DIRECTORY}" ]]; then + + DIRECTORY="${S3_BUILD_DIRECTORY}/${BUILD}" +else + DIRECTORY=$BUILD fi if [[ "$OS" == 'Linux' && "$IS_RPM_DEPLOY" -eq "1" ]]; then @@ -29,8 +32,8 @@ if [[ "$OS" == 'Linux' && "$IS_RPM_DEPLOY" -eq "1" ]]; then echo "Hash: $SHA" echo $SHA > ${GITHUB_WORKSPACE}/$(basename "${rpm}.sha256") - aws s3 cp ${rpm} s3://repo.nano.org/$DIRECTORY/binaries/$(basename "${rpm}") --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers - aws s3 cp ${GITHUB_WORKSPACE}/$(basename "${rpm}.sha256") s3://repo.nano.org/$DIRECTORY/binaries/$(basename "${rpm}.sha256") --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers + aws s3 cp ${rpm} s3://${S3_BUCKET_NAME}/$DIRECTORY/binaries/$(basename "${rpm}") --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers + aws s3 cp ${GITHUB_WORKSPACE}/$(basename "${rpm}.sha256") s3://${S3_BUCKET_NAME}/$DIRECTORY/binaries/$(basename "${rpm}.sha256") --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers done for srpm in $SRPMS; do @@ -38,8 +41,8 @@ if [[ "$OS" == 'Linux' && "$IS_RPM_DEPLOY" -eq "1" ]]; then echo "Hash: $SHA" echo $SHA > ${GITHUB_WORKSPACE}/$(basename "${srpm}).sha256") - aws s3 cp ${srpm} s3://repo.nano.org/$DIRECTORY/source/$(basename "${srpm}") --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers - aws s3 cp ${GITHUB_WORKSPACE}/$(basename "${srpm}).sha256") s3://repo.nano.org/$DIRECTORY/source/$(basename "${srpm}.sha256") --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers + aws s3 cp ${srpm} s3://${S3_BUCKET_NAME}/$DIRECTORY/source/$(basename "${srpm}") --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers + aws s3 cp ${GITHUB_WORKSPACE}/$(basename "${srpm}).sha256") s3://${S3_BUCKET_NAME}/$DIRECTORY/source/$(basename "${srpm}.sha256") --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers done elif [[ "$OS" == 'Linux' ]]; then SHA=$(sha256sum $GITHUB_WORKSPACE/build/nano-node-*-Linux.tar.bz2) @@ -50,15 +53,15 @@ elif [[ "$OS" == 'Linux' ]]; then echo "Hash: $SHA" echo $SHA >$GITHUB_WORKSPACE/nano-node-$TAG-Linux.deb.sha256 - aws s3 cp $GITHUB_WORKSPACE/build/nano-node-*-Linux.tar.bz2 s3://repo.nano.org/$DIRECTORY/binaries/nano-node-$TAG-Linux.tar.bz2 --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers - aws s3 cp $GITHUB_WORKSPACE/nano-node-$TAG-Linux.tar.bz2.sha256 s3://repo.nano.org/$DIRECTORY/binaries/nano-node-$TAG-Linux.tar.bz2.sha256 --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers - aws s3 cp $GITHUB_WORKSPACE/build/nano-node-*-Linux.deb s3://repo.nano.org/$DIRECTORY/binaries/nano-node-$TAG-Linux.deb --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers - aws s3 cp $GITHUB_WORKSPACE/nano-node-$TAG-Linux.deb.sha256 s3://repo.nano.org/$DIRECTORY/binaries/nano-node-$TAG-Linux.deb.sha256 --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers + aws s3 cp $GITHUB_WORKSPACE/build/nano-node-*-Linux.tar.bz2 s3://${S3_BUCKET_NAME}/$DIRECTORY/binaries/nano-node-$TAG-Linux.tar.bz2 --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers + aws s3 cp $GITHUB_WORKSPACE/nano-node-$TAG-Linux.tar.bz2.sha256 s3://${S3_BUCKET_NAME}/$DIRECTORY/binaries/nano-node-$TAG-Linux.tar.bz2.sha256 --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers + aws s3 cp $GITHUB_WORKSPACE/build/nano-node-*-Linux.deb s3://${S3_BUCKET_NAME}/$DIRECTORY/binaries/nano-node-$TAG-Linux.deb --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers + aws s3 cp $GITHUB_WORKSPACE/nano-node-$TAG-Linux.deb.sha256 s3://${S3_BUCKET_NAME}/$DIRECTORY/binaries/nano-node-$TAG-Linux.deb.sha256 --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers else SHA=$(sha256sum $GITHUB_WORKSPACE/build/nano-node-*-Darwin.dmg) echo "Hash: $SHA" echo $SHA >$GITHUB_WORKSPACE/build/nano-node-$TAG-Darwin.dmg.sha256 - aws s3 cp $GITHUB_WORKSPACE/build/nano-node-*-Darwin.dmg s3://repo.nano.org/$DIRECTORY/binaries/nano-node-$TAG-Darwin.dmg --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers - aws s3 cp $GITHUB_WORKSPACE/build/nano-node-$TAG-Darwin.dmg.sha256 s3://repo.nano.org/$DIRECTORY/binaries/nano-node-$TAG-Darwin.dmg.sha256 --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers + aws s3 cp $GITHUB_WORKSPACE/build/nano-node-*-Darwin.dmg s3://${S3_BUCKET_NAME}/$DIRECTORY/binaries/nano-node-$TAG-Darwin.dmg --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers + aws s3 cp $GITHUB_WORKSPACE/build/nano-node-$TAG-Darwin.dmg.sha256 s3://${S3_BUCKET_NAME}/$DIRECTORY/binaries/nano-node-$TAG-Darwin.dmg.sha256 --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers fi diff --git a/ci/actions/linux/docker-impl/docker-common.sh b/ci/actions/linux/docker-impl/docker-common.sh index 11fd8f1d5a..25460a6f9b 100755 --- a/ci/actions/linux/docker-impl/docker-common.sh +++ b/ci/actions/linux/docker-impl/docker-common.sh @@ -4,6 +4,8 @@ set -a scripts="$PWD/ci" CI_BRANCH=$(git rev-parse --abbrev-ref HEAD) +DOCKER_HUB="${DOCKER_HUB:-nanocurrency}" +DOCKER_USER="${DOCKER_USER:-nanoreleaseteam}" tags=() if [ -n "$CI_TAG" ]; then @@ -28,7 +30,7 @@ elif [[ "$NETWORK" = "TEST" ]]; then network="test" fi -docker_image_name="nanocurrency/nano${network_tag_suffix}" +docker_image_name="${DOCKER_HUB}/nano${network_tag_suffix}" ghcr_image_name="ghcr.io/${GITHUB_REPOSITORY}/nano${network_tag_suffix}" docker_build() @@ -74,11 +76,11 @@ tag_docker_image() { docker_deploy() { - docker_login "nanoreleaseteam" "$DOCKER_PASSWORD" + docker_login "$DOCKER_USER" "$DOCKER_PASSWORD" if [[ "$NETWORK" = "LIVE" ]]; then - deploy_tags "nanocurrency" "env|ghcr.io|none|latest" + deploy_tags "$DOCKER_HUB" "env|ghcr.io|none|latest" else - deploy_tags "nanocurrency" "env|ghcr.io|none" + deploy_tags "$DOCKER_HUB" "env|ghcr.io|none" fi } @@ -100,11 +102,11 @@ ghcr_deploy_env() docker_deploy_env() { - docker_login "nanoreleaseteam" "$DOCKER_PASSWORD" + docker_login "$DOCKER_USER" "$DOCKER_PASSWORD" local images=( - "nanocurrency/nano-env:base" - "nanocurrency/nano-env:gcc" - "nanocurrency/nano-env:clang" + "$DOCKER_HUB/nano-env:base" + "$DOCKER_HUB/nano-env:gcc" + "$DOCKER_HUB/nano-env:clang" ) deploy_env_images "${images[@]}" } diff --git a/ci/actions/windows/deploy.ps1 b/ci/actions/windows/deploy.ps1 index b7891cae56..4a859ecebf 100644 --- a/ci/actions/windows/deploy.ps1 +++ b/ci/actions/windows/deploy.ps1 @@ -1,5 +1,6 @@ $ErrorActionPreference = "Continue" +$env:S3_BUCKET_NAME = $env:S3_BUCKET_NAME ?? "repo.nano.org" if ( "${env:NETWORK}" -eq "BETA" ) { $network_cfg = "beta" } @@ -10,11 +11,11 @@ else { $network_cfg = "live" } -if ( ${env:GITHUB_REPOSITORY} -eq "nanocurrency/nano-node" ) { - $directory=$network_cfg +if (![string]::IsNullOrEmpty($env:S3_BUILD_DIRECTORY)) { + $directory = "$env:S3_BUILD_DIRECTORY/$network_cfg" } else { - $directory=${env:S3_BUILD_DIRECTORY}+"/"+$network_cfg + $directory = $network_cfg } $exe = Resolve-Path -Path $env:GITHUB_WORKSPACE\build\nano-node-*-win64.exe @@ -29,7 +30,7 @@ $zip_hash | Out-file -FilePath "$zip.sha256" Write-Output "Hash: $exe_hash" Write-Output "Hash: $zip_hash" -aws s3 cp "$exe" s3://repo.nano.org/$directory/binaries/nano-node-$env:TAG-win64.exe --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers -aws s3 cp "$exe.sha256" s3://repo.nano.org/$directory/binaries/nano-node-$env:TAG-win64.exe.sha256 --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers -aws s3 cp "$zip" s3://repo.nano.org/$directory/binaries/nano-node-$env:TAG-win64.zip --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers -aws s3 cp "$zip.sha256" s3://repo.nano.org/$directory/binaries/nano-node-$env:TAG-win64.zip.sha256 --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers \ No newline at end of file +aws s3 cp "$exe" s3://$env:S3_BUCKET_NAME/$directory/binaries/nano-node-$env:TAG-win64.exe --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers +aws s3 cp "$exe.sha256" s3://$env:S3_BUCKET_NAME/$directory/binaries/nano-node-$env:TAG-win64.exe.sha256 --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers +aws s3 cp "$zip" s3://$env:S3_BUCKET_NAME/$directory/binaries/nano-node-$env:TAG-win64.zip --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers +aws s3 cp "$zip.sha256" s3://$env:S3_BUCKET_NAME/$directory/binaries/nano-node-$env:TAG-win64.zip.sha256 --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers From e958a40299eaaa0d58f03d2d6dc17e359be014d3 Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Thu, 22 Jun 2023 11:18:08 +0200 Subject: [PATCH 08/32] Make workflow repository agnostic Convert nanocurrency/nano-env image to self built ghcr.io/${{ github.repository }} image --- .github/workflows/code_sanitizers.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/code_sanitizers.yml b/.github/workflows/code_sanitizers.yml index 616768662e..a6797ff25c 100644 --- a/.github/workflows/code_sanitizers.yml +++ b/.github/workflows/code_sanitizers.yml @@ -16,7 +16,7 @@ jobs: TEST_USE_ROCKSDB: [0, 1] COMPILER: [clang] SANITIZER: [ASAN, ASAN_INT, TSAN] - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 outputs: issue_reported: ${{ steps.show_report.outputs.issue_reported }} env: @@ -41,17 +41,17 @@ jobs: run: ci/actions/linux/install_deps.sh - name: Build Tests id: build_tests - run: docker run -e TEST_USE_ROCKSDB -v ${PWD}:/workspace nanocurrency/nano-env:${{ matrix.COMPILER }} /bin/bash -c \ - "cd /workspace && ${{ matrix.SANITIZER }}=1 ./ci/build-ci.sh /usr/lib/x86_64-linux-gnu/cmake/Qt5 'core_test rpc_test'" + run: docker run -e TEST_USE_ROCKSDB -v ${PWD}:/workspace ghcr.io/${{ github.repository }}/nano-env:${{ matrix.COMPILER }} /bin/bash -c \ + "cd /workspace && ${{ matrix.SANITIZER }}=1 ci/build-ci.sh /usr/lib/x86_64-linux-gnu/cmake/Qt5 'core_test rpc_test'" - name: Run core_test id: core_test continue-on-error: true - run: docker run -v ${PWD}:/workspace nanocurrency/nano-env:${{ matrix.COMPILER }} /bin/bash -c \ + run: docker run -v ${PWD}:/workspace ghcr.io/${{ github.repository }}/nano-env:${{ matrix.COMPILER }} /bin/bash -c \ "cd /workspace/build && ${XSAN}_OPTIONS=${XSAN_SUPPRESSIONS}log_exe_name=1:log_path=sanitizer_report ./core_test" - name: Run rpc_test id: rpc_test continue-on-error: true - run: docker run -v ${PWD}:/workspace nanocurrency/nano-env:${{ matrix.COMPILER }} /bin/bash -c \ + run: docker run -v ${PWD}:/workspace ghcr.io/${{ github.repository }}/nano-env:${{ matrix.COMPILER }} /bin/bash -c \ "cd /workspace/build && ${XSAN}_OPTIONS=${XSAN_SUPPRESSIONS}log_exe_name=1:log_path=sanitizer_report ./rpc_test" - name: Test Reports id: show_report @@ -63,7 +63,7 @@ jobs: echo "Report Output:" for report in ${reports}; do echo "File: $report" - docker run -v ${PWD}:/workspace nanocurrency/nano-env:${{ matrix.COMPILER }} /bin/bash -c "cat /workspace/${report}" + docker run -v ${PWD}:/workspace ghcr.io/${{ github.repository }}/nano-env:${{ matrix.COMPILER }} /bin/bash -c "cat /workspace/${report}" echo done issue_reported=true From bacd49613caf2e3f0fc6e545729ab377365952ba Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Thu, 22 Jun 2023 15:56:45 +0200 Subject: [PATCH 09/32] Fix CI_TAG usage - convert ref to CI_TAG - use CI_TAG in aws deploys --- .github/workflows/artifacts_build_deploy.yml | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/.github/workflows/artifacts_build_deploy.yml b/.github/workflows/artifacts_build_deploy.yml index 0ee8bd810f..136142fb86 100644 --- a/.github/workflows/artifacts_build_deploy.yml +++ b/.github/workflows/artifacts_build_deploy.yml @@ -6,9 +6,7 @@ on: inputs: repo: description: "repo" - - - ci_tag: + ref: description: "tag to build" default: "develop" #use AUTO to run the CI build flow required: true @@ -24,20 +22,20 @@ jobs: steps: - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0 with: - ref: ${{ (github.event.inputs.ci_tag == 'AUTO' || github.event.inputs.ci_tag == '') && 'develop' || github.event.inputs.ci_tag }} + ref: ${{ (github.event.inputs.ref == 'AUTO' || github.event.inputs.ref == '') && 'develop' || github.event.inputs.ref }} repository: ${{ github.event.inputs.repo || github.repository }} - name: Fetch the repository tags run: git fetch --tags - name: Set the tag and version id: tag_set run: | - if [[ "${{ github.event.inputs.ci_tag }}" == "AUTO" ]] || [[ "${{ github.event.inputs.ci_tag }}" == "" ]]; then + if [[ "${{ github.event.inputs.ref }}" == "AUTO" ]] || [[ "${{ github.event.inputs.ref }}" == "" ]]; then output_var_file="variable_list.txt" ci/actions/dev-build-tag-gen.sh -o "${output_var_file}" CI_TAG=$(grep 'build_tag' ${output_var_file} | cut -d= -f2) CI_VERSION_PRE_RELEASE=$(grep 'version_pre_release' ${output_var_file} | cut -d= -f2) else - CI_TAG=${{ github.event.inputs.ci_tag }} + CI_TAG=${{ github.event.inputs.ref }} CI_VERSION_PRE_RELEASE='OFF' fi echo "CI_TAG=${CI_TAG}" >> $GITHUB_ENV @@ -46,7 +44,7 @@ jobs: echo "CI_VERSION_PRE_RELEASE=${CI_VERSION_PRE_RELEASE}" >> $GITHUB_OUTPUT - name: Push the new tag run: | - if [[ "${{ github.event.inputs.ci_tag }}" == "AUTO" ]] || [[ "${{ github.event.inputs.ci_tag }}" == "" ]]; then + if [[ "${{ github.event.inputs.ref }}" == "AUTO" ]] || [[ "${{ github.event.inputs.ref }}" == "" ]]; then # Set git configuration git config user.name "${GITHUB_ACTOR}" git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" @@ -78,7 +76,7 @@ jobs: run: ci/actions/deploy.sh env: NETWORK: ${{ matrix.network }} - TAG: ${{ github.event.inputs.ci_tag }} + TAG: ${{ needs.prepare_build.outputs.CI_TAG }} S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }} S3_BUILD_DIRECTORY: ${{ secrets.S3_BUILD_DIRECTORY }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} @@ -109,7 +107,7 @@ jobs: run: ci/actions/deploy.sh env: NETWORK: ${{ matrix.network }} - TAG: ${{ github.event.inputs.ci_tag }} + TAG: ${{ needs.prepare_build.outputs.CI_TAG }} S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }} S3_BUILD_DIRECTORY: ${{ secrets.S3_BUILD_DIRECTORY }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} @@ -143,7 +141,7 @@ jobs: env: LINUX_RPM: 1 NETWORK: ${{ matrix.network }} - # TAG: ${{ github.event.inputs.ci_tag }} # (not used in the deploy script if LINUX_RPM==1 ) + # TAG: ${{ needs.prepare_build.outputs.CI_TAG }} # (not used in the deploy script if LINUX_RPM==1 ) S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }} S3_BUILD_DIRECTORY: ${{ secrets.S3_BUILD_DIRECTORY }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} @@ -211,7 +209,7 @@ jobs: run: ci/actions/windows/deploy.ps1 env: NETWORK: ${{ matrix.network }} - TAG: ${{ github.event.inputs.ci_tag }} + TAG: ${{ needs.prepare_build.outputs.CI_TAG }} S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }} S3_BUILD_DIRECTORY: ${{ secrets.S3_BUILD_DIRECTORY }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} From f6e595555a11878d7d39e5602987587069ee7042 Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Thu, 22 Jun 2023 17:20:50 +0200 Subject: [PATCH 10/32] Use same login for ghcr and hub.docker --- .github/workflows/artifacts_build_deploy.yml | 18 ++++---- .../develop_branch_dockers_deploy.yml | 10 ++--- ci/actions/linux/docker-impl/docker-common.sh | 43 +++++++++++-------- 3 files changed, 38 insertions(+), 33 deletions(-) diff --git a/.github/workflows/artifacts_build_deploy.yml b/.github/workflows/artifacts_build_deploy.yml index 136142fb86..2fcf014910 100644 --- a/.github/workflows/artifacts_build_deploy.yml +++ b/.github/workflows/artifacts_build_deploy.yml @@ -171,19 +171,21 @@ jobs: run: echo "DOCKER_PASSWORD_EXISTS=${{ secrets.DOCKER_PASSWORD != '' }}" >> $GITHUB_ENV - name: Deploy Docker Hub if: env.DOCKER_PASSWORD_EXISTS == 'true' - run: CI_TAG=${{ needs.prepare_build.outputs.CI_TAG }} ci/actions/linux/docker-deploy.sh + run: ci/actions/linux/docker-deploy.sh env: - DOCKER_HUB: ${{ secrets.DOCKER_HUB }} + CI_TAG: ${{ needs.prepare_build.outputs.CI_TAG }} + NETWORK: ${{ matrix.network }} + DOCKER_REGISTRY: ${{ secrets.DOCKER_HUB }} DOCKER_USER: ${{ secrets.DOCKER_USER }} DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} - - name: Login to ghcr.io - uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a #v2.1.0 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - name: Deploy Docker (ghcr.io) run: ci/actions/linux/ghcr-deploy.sh + env: + CI_TAG: ${{ needs.prepare_build.outputs.CI_TAG }} + NETWORK: ${{ matrix.network }} + DOCKER_REGISTRY: ghcr.io + DOCKER_USER: ${{ github.repository_owner }} + DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }} windows_job: needs: prepare_build diff --git a/.github/workflows/develop_branch_dockers_deploy.yml b/.github/workflows/develop_branch_dockers_deploy.yml index 38f263281b..f69ee795be 100644 --- a/.github/workflows/develop_branch_dockers_deploy.yml +++ b/.github/workflows/develop_branch_dockers_deploy.yml @@ -14,14 +14,12 @@ jobs: submodules: "recursive" - name: Fetch Deps run: ci/actions/linux/install_deps.sh - - name: Login to ghcr.io - uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a #v2.1.0 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - name: Deploy Docker (ghcr.io) run: ci/actions/linux/ghcr-deploy-env.sh + env: + DOCKER_REGISTRY: ghcr.io + DOCKER_USER: ${{ github.repository_owner }} + DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }} - name: Check if secrets.DOCKER_PASSWORD exists run: echo "DOCKER_PASSWORD_EXISTS=${{ secrets.DOCKER_PASSWORD != '' }}" >> $GITHUB_ENV - name: Deploy Docker (nanocurrency/nano-env) diff --git a/ci/actions/linux/docker-impl/docker-common.sh b/ci/actions/linux/docker-impl/docker-common.sh index 25460a6f9b..457fc7077c 100755 --- a/ci/actions/linux/docker-impl/docker-common.sh +++ b/ci/actions/linux/docker-impl/docker-common.sh @@ -4,7 +4,7 @@ set -a scripts="$PWD/ci" CI_BRANCH=$(git rev-parse --abbrev-ref HEAD) -DOCKER_HUB="${DOCKER_HUB:-nanocurrency}" +DOCKER_REGISTRY="${DOCKER_REGISTRY:-nanocurrency}" DOCKER_USER="${DOCKER_USER:-nanoreleaseteam}" tags=() @@ -30,8 +30,8 @@ elif [[ "$NETWORK" = "TEST" ]]; then network="test" fi -docker_image_name="${DOCKER_HUB}/nano${network_tag_suffix}" -ghcr_image_name="ghcr.io/${GITHUB_REPOSITORY}/nano${network_tag_suffix}" +docker_image_name="${DOCKER_REGISTRY}/nano${network_tag_suffix}" +ghcr_image_name="${DOCKER_REGISTRY}/${GITHUB_REPOSITORY}/nano${network_tag_suffix}" docker_build() { @@ -78,35 +78,37 @@ docker_deploy() { docker_login "$DOCKER_USER" "$DOCKER_PASSWORD" if [[ "$NETWORK" = "LIVE" ]]; then - deploy_tags "$DOCKER_HUB" "env|ghcr.io|none|latest" + deploy_tags "${DOCKER_REGISTRY}" "env|ghcr.io|none|latest" else - deploy_tags "$DOCKER_HUB" "env|ghcr.io|none" + deploy_tags "${DOCKER_REGISTRY}" "env|ghcr.io|none" fi } ghcr_deploy() -{ - deploy_tags "ghcr.io/${GITHUB_REPOSITORY}" "env|none" +{ + docker_login "$DOCKER_USER" "$DOCKER_PASSWORD" + deploy_tags "${DOCKER_REGISTRY}/${GITHUB_REPOSITORY}" "env|none" } -ghcr_deploy_env() -{ +docker_deploy_env() +{ + docker_login "$DOCKER_USER" "$DOCKER_PASSWORD" local images=( - "ghcr.io/${GITHUB_REPOSITORY}/nano-env:base" - "ghcr.io/${GITHUB_REPOSITORY}/nano-env:gcc" - "ghcr.io/${GITHUB_REPOSITORY}/nano-env:clang" - "ghcr.io/${GITHUB_REPOSITORY}/nano-env:rhel" + "${DOCKER_REGISTRY}/nano-env:base" + "${DOCKER_REGISTRY}/nano-env:gcc" + "${DOCKER_REGISTRY}/nano-env:clang" ) - deploy_env_images "${images[@]}" + deploy_env_images "${images[@]}" } -docker_deploy_env() +ghcr_deploy_env() { - docker_login "$DOCKER_USER" "$DOCKER_PASSWORD" + docker_login "$DOCKER_USER" "$DOCKER_PASSWORD" local images=( - "$DOCKER_HUB/nano-env:base" - "$DOCKER_HUB/nano-env:gcc" - "$DOCKER_HUB/nano-env:clang" + "${DOCKER_REGISTRY}/${GITHUB_REPOSITORY}/nano-env:base" + "${DOCKER_REGISTRY}/${GITHUB_REPOSITORY}/nano-env:gcc" + "${DOCKER_REGISTRY}/${GITHUB_REPOSITORY}/nano-env:clang" + "${DOCKER_REGISTRY}/${GITHUB_REPOSITORY}/nano-env:rhel" ) deploy_env_images "${images[@]}" } @@ -147,6 +149,9 @@ deploy_tags() local exclude_pattern=$2 local tags=$(docker images --format '{{.Repository}}:{{.Tag }}' | grep "$repo" | grep -vE "$exclude_pattern") + #Debug list all tags + docker images --format '{{.Repository}}:{{.Tag }}' + for tag in $tags; do push_docker_image "$tag" done From f4dd847bb03a9a8667baca6c76153f4b558c5185 Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Thu, 29 Jun 2023 16:56:23 +0200 Subject: [PATCH 11/32] Fix docker login - add possibility to specify registry - use ghcr.io instead of variable for ghcr_image_name --- ci/actions/linux/docker-impl/docker-common.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ci/actions/linux/docker-impl/docker-common.sh b/ci/actions/linux/docker-impl/docker-common.sh index 457fc7077c..caab373d19 100755 --- a/ci/actions/linux/docker-impl/docker-common.sh +++ b/ci/actions/linux/docker-impl/docker-common.sh @@ -31,7 +31,7 @@ elif [[ "$NETWORK" = "TEST" ]]; then fi docker_image_name="${DOCKER_REGISTRY}/nano${network_tag_suffix}" -ghcr_image_name="${DOCKER_REGISTRY}/${GITHUB_REPOSITORY}/nano${network_tag_suffix}" +ghcr_image_name="ghcr.io/${GITHUB_REPOSITORY}/nano${network_tag_suffix}" docker_build() { @@ -86,7 +86,7 @@ docker_deploy() ghcr_deploy() { - docker_login "$DOCKER_USER" "$DOCKER_PASSWORD" + docker_login "$DOCKER_USER" "$DOCKER_PASSWORD" "ghcr.io" deploy_tags "${DOCKER_REGISTRY}/${GITHUB_REPOSITORY}" "env|none" } @@ -103,7 +103,7 @@ docker_deploy_env() ghcr_deploy_env() { - docker_login "$DOCKER_USER" "$DOCKER_PASSWORD" + docker_login "$DOCKER_USER" "$DOCKER_PASSWORD" "ghcr.io" local images=( "${DOCKER_REGISTRY}/${GITHUB_REPOSITORY}/nano-env:base" "${DOCKER_REGISTRY}/${GITHUB_REPOSITORY}/nano-env:gcc" @@ -117,13 +117,14 @@ docker_login() { local username=$1 local password=$2 + local registry=$3 #optional if [ -z "$password" ]; then echo "\$DOCKER_PASSWORD or \$GHCR_TOKEN environment variable required" exit 1 fi - echo "$password" | docker login -u "$username" --password-stdin + echo "$password" | docker login $registry -u "$username" --password-stdin } push_docker_image() From ea965542c04d5d961c7d7059932abd3da6b45b48 Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Thu, 29 Jun 2023 17:00:17 +0200 Subject: [PATCH 12/32] Fix nano network during build --- ci/actions/linux/docker-impl/docker-common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/actions/linux/docker-impl/docker-common.sh b/ci/actions/linux/docker-impl/docker-common.sh index caab373d19..bcda39fbbd 100755 --- a/ci/actions/linux/docker-impl/docker-common.sh +++ b/ci/actions/linux/docker-impl/docker-common.sh @@ -51,7 +51,7 @@ docker_build() build_docker_image() { local ci_version_pre_release="$1" "$scripts"/build-docker-image.sh docker/node/Dockerfile "$docker_image_name" \ - --build-arg NETWORK="$network" \ + --build-arg NANO_NETWORK="$network" \ --build-arg CI_VERSION_PRE_RELEASE="$ci_version_pre_release" \ --build-arg CI_TAG="$CI_TAG" } From 3ef06895ebbb4adf0b7af02135e7d72a34ad4e9e Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Thu, 29 Jun 2023 17:03:45 +0200 Subject: [PATCH 13/32] Use config variables instead of secrets for non secret variables - vars.S3_BUCKET_NAME - vars.S3_BUILD_DIRECTORY - vars.DOCKER_REGISTRY - vars.DOCKER_USER --- .github/workflows/artifacts_build_deploy.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/artifacts_build_deploy.yml b/.github/workflows/artifacts_build_deploy.yml index 2fcf014910..ca435e9e2e 100644 --- a/.github/workflows/artifacts_build_deploy.yml +++ b/.github/workflows/artifacts_build_deploy.yml @@ -77,8 +77,8 @@ jobs: env: NETWORK: ${{ matrix.network }} TAG: ${{ needs.prepare_build.outputs.CI_TAG }} - S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }} - S3_BUILD_DIRECTORY: ${{ secrets.S3_BUILD_DIRECTORY }} + S3_BUCKET_NAME: ${{ vars.S3_BUCKET_NAME }} + S3_BUILD_DIRECTORY: ${{ vars.S3_BUILD_DIRECTORY }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_DEFAULT_REGION: us-east-2 @@ -108,8 +108,8 @@ jobs: env: NETWORK: ${{ matrix.network }} TAG: ${{ needs.prepare_build.outputs.CI_TAG }} - S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }} - S3_BUILD_DIRECTORY: ${{ secrets.S3_BUILD_DIRECTORY }} + S3_BUCKET_NAME: ${{ vars.S3_BUCKET_NAME }} + S3_BUILD_DIRECTORY: ${{ vars.S3_BUILD_DIRECTORY }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_DEFAULT_REGION: us-east-2 @@ -142,8 +142,8 @@ jobs: LINUX_RPM: 1 NETWORK: ${{ matrix.network }} # TAG: ${{ needs.prepare_build.outputs.CI_TAG }} # (not used in the deploy script if LINUX_RPM==1 ) - S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }} - S3_BUILD_DIRECTORY: ${{ secrets.S3_BUILD_DIRECTORY }} + S3_BUCKET_NAME: ${{ vars.S3_BUCKET_NAME }} + S3_BUILD_DIRECTORY: ${{ vars.S3_BUILD_DIRECTORY }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_DEFAULT_REGION: us-east-2 @@ -175,8 +175,8 @@ jobs: env: CI_TAG: ${{ needs.prepare_build.outputs.CI_TAG }} NETWORK: ${{ matrix.network }} - DOCKER_REGISTRY: ${{ secrets.DOCKER_HUB }} - DOCKER_USER: ${{ secrets.DOCKER_USER }} + DOCKER_REGISTRY: ${{ vars.DOCKER_REGISTRY }} + DOCKER_USER: ${{ vars.DOCKER_USER }} DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} - name: Deploy Docker (ghcr.io) run: ci/actions/linux/ghcr-deploy.sh @@ -212,8 +212,8 @@ jobs: env: NETWORK: ${{ matrix.network }} TAG: ${{ needs.prepare_build.outputs.CI_TAG }} - S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }} - S3_BUILD_DIRECTORY: ${{ secrets.S3_BUILD_DIRECTORY }} + S3_BUCKET_NAME: ${{ vars.S3_BUCKET_NAME }} + S3_BUILD_DIRECTORY: ${{ vars.S3_BUILD_DIRECTORY }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_DEFAULT_REGION: us-east-2 From 79ad3ddd3790449af68cd41ba4c140d228aae3cf Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Thu, 29 Jun 2023 17:05:20 +0200 Subject: [PATCH 14/32] Fix: Make build process repository agnostic by specifying vars.DOCKER_REGISTRY --- .github/workflows/artifacts_build_deploy.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/artifacts_build_deploy.yml b/.github/workflows/artifacts_build_deploy.yml index ca435e9e2e..12fe2bd349 100644 --- a/.github/workflows/artifacts_build_deploy.yml +++ b/.github/workflows/artifacts_build_deploy.yml @@ -166,7 +166,12 @@ jobs: COMPILER: gcc run: ci/actions/linux/install_deps.sh - name: Build Docker - run: NETWORK=${{ matrix.network }} CI_TAG=${{ needs.prepare_build.outputs.CI_TAG }} CI_VERSION_PRE_RELEASE=${{ needs.prepare_build.outputs.CI_VERSION_PRE_RELEASE }} ci/actions/linux/docker-build.sh + run: ci/actions/linux/docker-build.sh + env: + NETWORK: ${{ matrix.network }} + CI_TAG: ${{ needs.prepare_build.outputs.CI_TAG }} + CI_VERSION_PRE_RELEASE: ${{ needs.prepare_build.outputs.CI_VERSION_PRE_RELEASE }} + DOCKER_REGISTRY: ${{ vars.DOCKER_REGISTRY }} - name: Check if secrets.DOCKER_PASSWORD exists run: echo "DOCKER_PASSWORD_EXISTS=${{ secrets.DOCKER_PASSWORD != '' }}" >> $GITHUB_ENV - name: Deploy Docker Hub From 0381beb72f8efe4ddefae9caba36baed0cc0af39 Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Thu, 29 Jun 2023 17:30:03 +0200 Subject: [PATCH 15/32] Make tag generation branch agnostic The goal is to simplify tag generation process and commit the version_pre_release into CMakeLists.txt for each tag. If a user checks out a specific tag and builds it, the version_pre_release is set correctly. - remove workflow_dispatch inputs. It operates on the selected branch. - The cronjob is executed on develop branch only. - replace ci/actions/dev-build-tag-gen.sh with ci/actions/generate_next_git_tag.sh - generate_next_git_tag.sh is branch agnostic and operates on ${{ github.ref }} - generate_next_git_tag.sh succeeds even if no new tag is generated - the workflow only executes the build jobs if a new tag was created (if: ${{ needs.prepare_build.outputs.TAG_CREATED == 'true' }}) - generate_next_git_tag.sh uses V${current_version_major}.${current_version_minor}${branch_name} for tags. - for "develop" branch_name is converted to DB --> (e.g V26.0DB1) - generate_next_git_tag.sh uses a -c flag that is responsible to update CMakeLists.txt with correct version_pre_release, create and push the tag to origin. --- .github/workflows/artifacts_build_deploy.yml | 67 +++++------ ci/actions/generate_next_git_tag.sh | 114 +++++++++++++++++++ 2 files changed, 143 insertions(+), 38 deletions(-) create mode 100755 ci/actions/generate_next_git_tag.sh diff --git a/.github/workflows/artifacts_build_deploy.yml b/.github/workflows/artifacts_build_deploy.yml index 12fe2bd349..9e324bb75f 100644 --- a/.github/workflows/artifacts_build_deploy.yml +++ b/.github/workflows/artifacts_build_deploy.yml @@ -3,13 +3,7 @@ on: schedule: - cron: "0 0 * * 3,6" workflow_dispatch: - inputs: - repo: - description: "repo" - ref: - description: "tag to build" - default: "develop" #use AUTO to run the CI build flow - required: true + env: artifact: 1 @@ -19,43 +13,29 @@ jobs: outputs: CI_TAG: ${{ steps.tag_set.outputs.CI_TAG }} CI_VERSION_PRE_RELEASE: ${{ steps.tag_set.outputs.CI_VERSION_PRE_RELEASE }} + TAG_CREATED: ${{ steps.tag_set.outputs.tag_created }} steps: - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0 with: - ref: ${{ (github.event.inputs.ref == 'AUTO' || github.event.inputs.ref == '') && 'develop' || github.event.inputs.ref }} - repository: ${{ github.event.inputs.repo || github.repository }} - - name: Fetch the repository tags - run: git fetch --tags + ref: ${{ github.ref }} - name: Set the tag and version id: tag_set run: | - if [[ "${{ github.event.inputs.ref }}" == "AUTO" ]] || [[ "${{ github.event.inputs.ref }}" == "" ]]; then - output_var_file="variable_list.txt" - ci/actions/dev-build-tag-gen.sh -o "${output_var_file}" - CI_TAG=$(grep 'build_tag' ${output_var_file} | cut -d= -f2) - CI_VERSION_PRE_RELEASE=$(grep 'version_pre_release' ${output_var_file} | cut -d= -f2) - else - CI_TAG=${{ github.event.inputs.ref }} - CI_VERSION_PRE_RELEASE='OFF' - fi - echo "CI_TAG=${CI_TAG}" >> $GITHUB_ENV - echo "CI_VERSION_PRE_RELEASE=${CI_VERSION_PRE_RELEASE}" >> $GITHUB_ENV + output_var_file="variable_list.txt" + ci/actions/generate_next_git_tag.sh -c -o "${output_var_file}" + CI_TAG=$(grep 'build_tag' ${output_var_file} | cut -d= -f2) echo "CI_TAG=${CI_TAG}" >> $GITHUB_OUTPUT + CI_VERSION_PRE_RELEASE=$(grep 'version_pre_release' ${output_var_file} | cut -d= -f2) echo "CI_VERSION_PRE_RELEASE=${CI_VERSION_PRE_RELEASE}" >> $GITHUB_OUTPUT - - name: Push the new tag - run: | - if [[ "${{ github.event.inputs.ref }}" == "AUTO" ]] || [[ "${{ github.event.inputs.ref }}" == "" ]]; then - # Set git configuration - git config user.name "${GITHUB_ACTOR}" - git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" - # Create and push the tag - git tag -a "${CI_TAG}" -m "This tag was automatically generated by the Beta workflow" - git push origin "${CI_TAG}" - fi + TAG_CREATED=$(grep 'tag_created' ${output_var_file} | cut -d= -f2) + echo "TAG_CREATED=${TAG_CREATED}" >> $GITHUB_OUTPUT + env: + GITHUB_ACTOR: ${{ github.actor }} osx_job: needs: prepare_build + if: ${{ needs.prepare_build.outputs.TAG_CREATED == 'true' }} runs-on: macOS-12 timeout-minutes: 90 strategy: @@ -67,11 +47,15 @@ jobs: with: submodules: "recursive" ref: ${{ needs.prepare_build.outputs.CI_TAG }} - repository: ${{ github.event.inputs.repo }} + repository: ${{ github.repository }} - name: Fetch Deps run: ci/actions/osx/install_deps.sh - name: Build Artifact - run: NETWORK=${{ matrix.network }} CI_TAG="${{ needs.prepare_build.outputs.CI_TAG }}" CI_VERSION_PRE_RELEASE="${{ needs.prepare_build.outputs.CI_VERSION_PRE_RELEASE }}" ci/build-deploy.sh "/tmp/qt/lib/cmake/Qt5"; + run: ci/build-deploy.sh "/tmp/qt/lib/cmake/Qt5"; + env: + NETWORK: ${{ matrix.network }} + CI_TAG: ${{ needs.prepare_build.outputs.CI_TAG }} + CI_VERSION_PRE_RELEASE: ${{ needs.prepare_build.outputs.CI_VERSION_PRE_RELEASE }} - name: Deploy Artifact run: ci/actions/deploy.sh env: @@ -86,6 +70,7 @@ jobs: linux_job: needs: prepare_build + if: ${{ needs.prepare_build.outputs.TAG_CREATED == 'true' }} runs-on: ubuntu-22.04 timeout-minutes: 90 strategy: @@ -96,7 +81,7 @@ jobs: with: submodules: "recursive" ref: ${{ needs.prepare_build.outputs.CI_TAG }} - repository: ${{ github.event.inputs.repo }} + repository: ${{ github.repository }} - name: Fetch Deps env: COMPILER: gcc @@ -114,8 +99,10 @@ jobs: AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_DEFAULT_REGION: us-east-2 + linux_rpm_job: needs: prepare_build + if: ${{ needs.prepare_build.outputs.TAG_CREATED == 'true' }} runs-on: ubuntu-22.04 timeout-minutes: 90 strategy: @@ -126,7 +113,7 @@ jobs: with: submodules: "recursive" ref: "develop" #build-rhel.sh needs develop branch and then sets the tag - repository: ${{ github.event.inputs.repo }} + repository: ${{ github.repository }} - name: RockyLinux 8 Base run: ci/build-docker-image.sh docker/ci/Dockerfile-rhel nanocurrency/nano-env:rhel - name: Build Artifact @@ -148,8 +135,10 @@ jobs: AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_DEFAULT_REGION: us-east-2 + linux_docker_job: needs: prepare_build + if: ${{ needs.prepare_build.outputs.TAG_CREATED == 'true' }} runs-on: ubuntu-22.04 timeout-minutes: 90 strategy: @@ -160,7 +149,7 @@ jobs: with: submodules: "recursive" ref: ${{ needs.prepare_build.outputs.CI_TAG }} - repository: ${{ github.event.inputs.repo }} + repository: ${{ github.repository }} - name: Fetch Deps env: COMPILER: gcc @@ -192,8 +181,10 @@ jobs: DOCKER_USER: ${{ github.repository_owner }} DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }} + windows_job: needs: prepare_build + if: ${{ needs.prepare_build.outputs.TAG_CREATED == 'true' }} runs-on: windows-latest timeout-minutes: 90 strategy: @@ -204,7 +195,7 @@ jobs: with: submodules: "recursive" ref: ${{ needs.prepare_build.outputs.CI_TAG }} - repository: ${{ github.event.inputs.repo }} + repository: ${{ github.repository }} - name: Fetch Deps run: ci/actions/windows/install_deps.ps1 - name: Build Artifact diff --git a/ci/actions/generate_next_git_tag.sh b/ci/actions/generate_next_git_tag.sh new file mode 100755 index 0000000000..10dbc582f3 --- /dev/null +++ b/ci/actions/generate_next_git_tag.sh @@ -0,0 +1,114 @@ +#!/bin/bash + +# This script creates the next tag for the current branch by incrementing the version_pre_release by 1 +# A new tag is only created if a new commit has been detected compared to the previous tag. +# The tag has the following format V${current_version_major}.${current_version_minor}${branch_name} +# ${branch_name} is converted to "DB" if the script operates on develop branch. (e.g first tag for V26: V26.0DB1) +# if -c flag is provided, version_pre_release in CMakeLists.txt is incremented and a new tag is created and pushed to origin +# if -o is provided, "build_tag" , "version_pre_release" and "tag_created" are written to file + +set -e +output="" +create=false +tag_created="false" + +while getopts ":o:c" opt; do + case ${opt} in + o ) + output=$OPTARG + ;; + c ) + create=true + ;; + \? ) + echo "Invalid Option: -$OPTARG" 1>&2 + exit 1 + ;; + : ) + echo "Invalid Option: -$OPTARG requires an argument" 1>&2 + exit 1 + ;; + esac +done +shift $((OPTIND -1)) + +# Fetch all existing tags +git fetch --tags + +# Fetch the last commit hash of the current branch +current_commit_hash=$(git rev-parse HEAD) + +# Fetch branch name +branch_name=$(git rev-parse --abbrev-ref HEAD) + +# Check if the branch name is 'develop' +if [[ "$branch_name" == "develop" ]]; then + branch_name="DB" +fi + +# Replace special characters with underscores +branch_name=${branch_name//[^a-zA-Z0-9]/_} + +# Fetch major and minor version numbers from CMakeLists.txt +current_version_major=$(grep "CPACK_PACKAGE_VERSION_MAJOR" CMakeLists.txt | grep -o "[0-9]\+") +current_version_minor=$(grep "CPACK_PACKAGE_VERSION_MINOR" CMakeLists.txt | grep -o "[0-9]\+") + +# Construct the base version +base_version="V${current_version_major}.${current_version_minor}${branch_name}" + +# Fetch the existing tags +existing_tags=$(git tag --list "${base_version}*") + +# If no tag exists, then just append 1 to the base version +if [[ -z "$existing_tags" ]]; then + new_tag="${base_version}1" + tag_created="true" +else + # Fetch the last tag number, increment it, and append to the base version + last_tag=$(echo "$existing_tags" | sort -V | tail -n1) + last_tag_number=$(echo "$last_tag" | awk -F"${branch_name}" '{print $2}') + + # Fetch the commit hash of the last commit of the previous tag, ignoring the commit with the version change + last_tag_commit_hash=$(git rev-list -n 2 $last_tag | tail -n 1) + + if [[ "$current_commit_hash" == "$last_tag_commit_hash" ]]; then + echo "No new commits since the last tag. No new tag will be created." + else + next_tag_number=$((last_tag_number + 1)) + new_tag="${base_version}${next_tag_number}" + tag_created="true" + fi +fi +echo "$new_tag" + +# Update output file +if [[ -n "$output" ]]; then + echo "build_tag =$new_tag" > $output + echo "version_pre_release =$next_tag_number" >> $output + echo "tag_created =$tag_created" >> $output +fi + +# Skip tag creation if no new commits +if [[ "$tag_created" == "false" ]]; then + exit 0 +fi + +if [[ $create == true ]]; then + # Stash current changes + git config --global user.name "${GITHUB_ACTOR}" + git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" + + # Update CPACK_PACKAGE_VERSION_PRE_RELEASE in CMakeLists.txt (macOs compatible sed -i.bak) + sed -i.bak "s/set(CPACK_PACKAGE_VERSION_PRE_RELEASE \"[0-9]*\")/set(CPACK_PACKAGE_VERSION_PRE_RELEASE \"${next_tag_number}\")/g" CMakeLists.txt + rm CMakeLists.txt.bak + git add CMakeLists.txt + git commit -m "Update CPACK_PACKAGE_VERSION_PRE_RELEASE to $next_tag_number" + + # Create & Push the new tag + git tag -a "$new_tag" -m "This tag was created with generate_next_git_tag.sh" + git push origin "$new_tag" + + # Undo the last commit and apply stashed changes + git reset --hard HEAD~1 + echo "The tag $new_tag has been created and pushed, but the commit used for the tag does not exist on any branch." +fi \ No newline at end of file From 2c936ef2797fd07f8af176982f3cfafb9d9b0e36 Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Thu, 29 Jun 2023 17:49:15 +0200 Subject: [PATCH 16/32] Remove CI_VERSION_PRE_RELEASE as it has been committed to CMakeLists.txt in the tag used to build the node --- .github/workflows/artifacts_build_deploy.yml | 32 +++++++++++--------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/.github/workflows/artifacts_build_deploy.yml b/.github/workflows/artifacts_build_deploy.yml index 9e324bb75f..c6bfbcd27a 100644 --- a/.github/workflows/artifacts_build_deploy.yml +++ b/.github/workflows/artifacts_build_deploy.yml @@ -11,8 +11,7 @@ jobs: prepare_build: runs-on: ubuntu-20.04 outputs: - CI_TAG: ${{ steps.tag_set.outputs.CI_TAG }} - CI_VERSION_PRE_RELEASE: ${{ steps.tag_set.outputs.CI_VERSION_PRE_RELEASE }} + CI_TAG: ${{ steps.tag_set.outputs.CI_TAG }} TAG_CREATED: ${{ steps.tag_set.outputs.tag_created }} steps: - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0 @@ -24,9 +23,7 @@ jobs: output_var_file="variable_list.txt" ci/actions/generate_next_git_tag.sh -c -o "${output_var_file}" CI_TAG=$(grep 'build_tag' ${output_var_file} | cut -d= -f2) - echo "CI_TAG=${CI_TAG}" >> $GITHUB_OUTPUT - CI_VERSION_PRE_RELEASE=$(grep 'version_pre_release' ${output_var_file} | cut -d= -f2) - echo "CI_VERSION_PRE_RELEASE=${CI_VERSION_PRE_RELEASE}" >> $GITHUB_OUTPUT + echo "CI_TAG=${CI_TAG}" >> $GITHUB_OUTPUT TAG_CREATED=$(grep 'tag_created' ${output_var_file} | cut -d= -f2) echo "TAG_CREATED=${TAG_CREATED}" >> $GITHUB_OUTPUT env: @@ -54,8 +51,7 @@ jobs: run: ci/build-deploy.sh "/tmp/qt/lib/cmake/Qt5"; env: NETWORK: ${{ matrix.network }} - CI_TAG: ${{ needs.prepare_build.outputs.CI_TAG }} - CI_VERSION_PRE_RELEASE: ${{ needs.prepare_build.outputs.CI_VERSION_PRE_RELEASE }} + CI_TAG: ${{ needs.prepare_build.outputs.CI_TAG }} - name: Deploy Artifact run: ci/actions/deploy.sh env: @@ -87,7 +83,12 @@ jobs: COMPILER: gcc run: ci/actions/linux/install_deps.sh - name: Build Artifact - run: docker run -v ${GITHUB_WORKSPACE}:/workspace nanocurrency/nano-env:gcc /bin/bash -c "cd /workspace && NETWORK=${{ matrix.network }} CI_TAG=${{ needs.prepare_build.outputs.CI_TAG }} CI_VERSION_PRE_RELEASE=${{ needs.prepare_build.outputs.CI_VERSION_PRE_RELEASE }} ci/build-deploy.sh /usr/lib/x86_64-linux-gnu/cmake/Qt5" + run: | + docker run -v ${GITHUB_WORKSPACE}:/workspace \ + nanocurrency/nano-env:gcc /bin/bash -c "cd /workspace && \ + NETWORK=${{ matrix.network }} \ + CI_TAG=${{ needs.prepare_build.outputs.CI_TAG }} \ + ci/build-deploy.sh /usr/lib/x86_64-linux-gnu/cmake/Qt5" - name: Deploy Artifact run: ci/actions/deploy.sh env: @@ -119,10 +120,14 @@ jobs: - name: Build Artifact run: | mkdir -p ${GITHUB_WORKSPACE}/artifacts - docker run -e NETWORK=${{ matrix.network }} -e TAG=${{ needs.prepare_build.outputs.CI_TAG }} -e REPO_TO_BUILD=${{ github.event.inputs.repo }} -e RPM_RELEASE=1 \ - -v ${GITHUB_WORKSPACE}:/workspace \ - -v ${GITHUB_WORKSPACE}/artifacts:/root/rpmbuild \ - nanocurrency/nano-env:rhel /bin/bash -c "ci/build-rhel.sh" + docker run -v ${GITHUB_WORKSPACE}:/workspace -v ${GITHUB_WORKSPACE}/artifacts:/root/rpmbuild \ + nanocurrency/nano-env:rhel /bin/bash -c " \ + NETWORK=${{ matrix.network }} \ + TAG=${{ needs.prepare_build.outputs.CI_TAG }} \ + REPO_TO_BUILD=${{ github.repository }} \ + RPM_RELEASE=1 \ + ci/build-rhel.sh" + - name: Deploy Artifacts run: ci/actions/deploy.sh env: @@ -158,8 +163,7 @@ jobs: run: ci/actions/linux/docker-build.sh env: NETWORK: ${{ matrix.network }} - CI_TAG: ${{ needs.prepare_build.outputs.CI_TAG }} - CI_VERSION_PRE_RELEASE: ${{ needs.prepare_build.outputs.CI_VERSION_PRE_RELEASE }} + CI_TAG: ${{ needs.prepare_build.outputs.CI_TAG }} DOCKER_REGISTRY: ${{ vars.DOCKER_REGISTRY }} - name: Check if secrets.DOCKER_PASSWORD exists run: echo "DOCKER_PASSWORD_EXISTS=${{ secrets.DOCKER_PASSWORD != '' }}" >> $GITHUB_ENV From 14bf6594b2d0f233a2c38386b3e0a161563e2a58 Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Fri, 30 Jun 2023 13:32:08 +0200 Subject: [PATCH 17/32] Use the new prepare scripts - use the new prepare scripts (Linux, MacOS & Windows) - remove the need the dependency on nano-env:gcc --- .github/workflows/artifacts_build_deploy.yml | 29 ++++++++------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/.github/workflows/artifacts_build_deploy.yml b/.github/workflows/artifacts_build_deploy.yml index c6bfbcd27a..68c5465829 100644 --- a/.github/workflows/artifacts_build_deploy.yml +++ b/.github/workflows/artifacts_build_deploy.yml @@ -45,8 +45,8 @@ jobs: submodules: "recursive" ref: ${{ needs.prepare_build.outputs.CI_TAG }} repository: ${{ github.repository }} - - name: Fetch Deps - run: ci/actions/osx/install_deps.sh + - name: Prepare + run: ci/prepare/macos/prepare.sh - name: Build Artifact run: ci/build-deploy.sh "/tmp/qt/lib/cmake/Qt5"; env: @@ -78,17 +78,14 @@ jobs: submodules: "recursive" ref: ${{ needs.prepare_build.outputs.CI_TAG }} repository: ${{ github.repository }} - - name: Fetch Deps - env: - COMPILER: gcc - run: ci/actions/linux/install_deps.sh + - name: Prepare + run: sudo -E ci/prepare/linux/prepare.sh - name: Build Artifact - run: | - docker run -v ${GITHUB_WORKSPACE}:/workspace \ - nanocurrency/nano-env:gcc /bin/bash -c "cd /workspace && \ - NETWORK=${{ matrix.network }} \ - CI_TAG=${{ needs.prepare_build.outputs.CI_TAG }} \ - ci/build-deploy.sh /usr/lib/x86_64-linux-gnu/cmake/Qt5" + run: ci/build-deploy.sh "/usr/lib/x86_64-linux-gnu/cmake/Qt5" + env: + NETWORK: ${{ matrix.network }} \ + CI_TAG: ${{ needs.prepare_build.outputs.CI_TAG }} \ + - name: Deploy Artifact run: ci/actions/deploy.sh env: @@ -155,10 +152,6 @@ jobs: submodules: "recursive" ref: ${{ needs.prepare_build.outputs.CI_TAG }} repository: ${{ github.repository }} - - name: Fetch Deps - env: - COMPILER: gcc - run: ci/actions/linux/install_deps.sh - name: Build Docker run: ci/actions/linux/docker-build.sh env: @@ -200,8 +193,8 @@ jobs: submodules: "recursive" ref: ${{ needs.prepare_build.outputs.CI_TAG }} repository: ${{ github.repository }} - - name: Fetch Deps - run: ci/actions/windows/install_deps.ps1 + - name: Prepare + run: ci/prepare/windows/prepare.ps1 - name: Build Artifact run: ci/actions/windows/build.ps1 env: From b390221f7ad45d4d374162b61e8a8473d5fa5e80 Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Sat, 1 Jul 2023 10:47:13 +0200 Subject: [PATCH 18/32] Make usage of nano-env:rhel explicit - Build the nano-env docker image in the current workflow - Use the locally built image. --- .github/workflows/artifacts_build_deploy.yml | 9 +++++++-- ci/actions/linux/install_deps.sh | 12 +++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/.github/workflows/artifacts_build_deploy.yml b/.github/workflows/artifacts_build_deploy.yml index 68c5465829..5600152c40 100644 --- a/.github/workflows/artifacts_build_deploy.yml +++ b/.github/workflows/artifacts_build_deploy.yml @@ -112,13 +112,18 @@ jobs: submodules: "recursive" ref: "develop" #build-rhel.sh needs develop branch and then sets the tag repository: ${{ github.repository }} + - name: Build local/nano-env:rhel + run: ci/actions/linux/install_deps.sh + env: + COMPILER: rhel + DOCKER_REGISTRY: local - name: RockyLinux 8 Base - run: ci/build-docker-image.sh docker/ci/Dockerfile-rhel nanocurrency/nano-env:rhel + run: ci/build-docker-image.sh docker/ci/Dockerfile-rhel local/nano-env:rhel - name: Build Artifact run: | mkdir -p ${GITHUB_WORKSPACE}/artifacts docker run -v ${GITHUB_WORKSPACE}:/workspace -v ${GITHUB_WORKSPACE}/artifacts:/root/rpmbuild \ - nanocurrency/nano-env:rhel /bin/bash -c " \ + local/nano-env:rhel /bin/bash -c " \ NETWORK=${{ matrix.network }} \ TAG=${{ needs.prepare_build.outputs.CI_TAG }} \ REPO_TO_BUILD=${{ github.repository }} \ diff --git a/ci/actions/linux/install_deps.sh b/ci/actions/linux/install_deps.sh index 847a5f0719..5f1a42bf63 100755 --- a/ci/actions/linux/install_deps.sh +++ b/ci/actions/linux/install_deps.sh @@ -2,18 +2,20 @@ set -x +DOCKER_REGISTRY="${DOCKER_REGISTRY:-nanocurrency}" + echo "Script ci/actions/linux/install_deps.sh starting COMPILER=\"$COMPILER\"" # This enables IPv6 support in docker, needed to run node tests inside docker container sudo mkdir -p /etc/docker && echo '{"ipv6":true,"fixed-cidr-v6":"2001:db8:1::/64"}' | sudo tee /etc/docker/daemon.json && sudo service docker restart -ci/build-docker-image.sh docker/ci/Dockerfile-base nanocurrency/nano-env:base +ci/build-docker-image.sh docker/ci/Dockerfile-base ${DOCKER_REGISTRY}/nano-env:base if [[ "${COMPILER:-}" != "" ]]; then - ci/build-docker-image.sh docker/ci/Dockerfile-${COMPILER} nanocurrency/nano-env:${COMPILER} + ci/build-docker-image.sh docker/ci/Dockerfile-${COMPILER} ${DOCKER_REGISTRY}/nano-env:${COMPILER} else - ci/build-docker-image.sh docker/ci/Dockerfile-gcc nanocurrency/nano-env:gcc - ci/build-docker-image.sh docker/ci/Dockerfile-clang nanocurrency/nano-env:clang - ci/build-docker-image.sh docker/ci/Dockerfile-rhel nanocurrency/nano-env:rhel + ci/build-docker-image.sh docker/ci/Dockerfile-gcc ${DOCKER_REGISTRY}/nano-env:gcc + ci/build-docker-image.sh docker/ci/Dockerfile-clang ${DOCKER_REGISTRY}/nano-env:clang + ci/build-docker-image.sh docker/ci/Dockerfile-rhel ${DOCKER_REGISTRY}/nano-env:rhel fi echo "Script ci/actions/linux/install_deps.sh finished" From 06cf680aed5f8bb9ab90343faa68a1429e9f17dc Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Sat, 1 Jul 2023 15:28:28 +0200 Subject: [PATCH 19/32] Fix typo in default BUILD_TYPE - Remove duplicate BUILD_TYPE - move SANITIZER to ci/build-node.sh ARGs --- docker/node/Dockerfile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docker/node/Dockerfile b/docker/node/Dockerfile index 580f6979d1..0c36f545c8 100644 --- a/docker/node/Dockerfile +++ b/docker/node/Dockerfile @@ -1,8 +1,6 @@ FROM ubuntu:22.04 as builder ARG COMPILER=gcc -ARG BUILD_TYPE=RelWithDebInfo -ARG SANITIZER ARG NANO_NETWORK=live # Install build dependencies @@ -13,12 +11,13 @@ COPY ./ /tmp/src WORKDIR /tmp/src #Define ARGs for ci/build-node.sh -ARG BUILD_TYPE=RelWidthDebInfo +ARG BUILD_TYPE=RelWithDebInfo ARG NANO_TEST=OFF ARG COVERAGE=OFF ARG CMAKE_SANITIZER="" ARG CI_TAG=DEV_BUILD ARG CI_VERSION_PRE_RELEASE=OFF +ARG SANITIZER # Build node RUN ci/build-node.sh From a30b304ffbcbc827392b632bfac77978a12c354f Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Sat, 1 Jul 2023 22:25:50 +0200 Subject: [PATCH 20/32] Make sure the existing_tags ending is numeric - fixes a bug when we have 2 similar branches with tags (e.g. some-branch and some-branch-2) --- ci/actions/generate_next_git_tag.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/actions/generate_next_git_tag.sh b/ci/actions/generate_next_git_tag.sh index 10dbc582f3..9a0debd065 100755 --- a/ci/actions/generate_next_git_tag.sh +++ b/ci/actions/generate_next_git_tag.sh @@ -33,7 +33,7 @@ done shift $((OPTIND -1)) # Fetch all existing tags -git fetch --tags +git fetch --tags -f # Fetch the last commit hash of the current branch current_commit_hash=$(git rev-parse HEAD) @@ -57,7 +57,7 @@ current_version_minor=$(grep "CPACK_PACKAGE_VERSION_MINOR" CMakeLists.txt | grep base_version="V${current_version_major}.${current_version_minor}${branch_name}" # Fetch the existing tags -existing_tags=$(git tag --list "${base_version}*") +existing_tags=$(git tag --list "${base_version}*" | grep -E "${base_version}[0-9]+$") # If no tag exists, then just append 1 to the base version if [[ -z "$existing_tags" ]]; then From f22ba6a9be36568414c83e3281c6db8ff55a02ce Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Sat, 1 Jul 2023 22:27:59 +0200 Subject: [PATCH 21/32] Remove --global for git config Prevent modification of global git settings on a developer machine --- ci/actions/generate_next_git_tag.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/actions/generate_next_git_tag.sh b/ci/actions/generate_next_git_tag.sh index 9a0debd065..181c5295d5 100755 --- a/ci/actions/generate_next_git_tag.sh +++ b/ci/actions/generate_next_git_tag.sh @@ -95,8 +95,8 @@ fi if [[ $create == true ]]; then # Stash current changes - git config --global user.name "${GITHUB_ACTOR}" - git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" + git config user.name "${GITHUB_ACTOR}" + git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" # Update CPACK_PACKAGE_VERSION_PRE_RELEASE in CMakeLists.txt (macOs compatible sed -i.bak) sed -i.bak "s/set(CPACK_PACKAGE_VERSION_PRE_RELEASE \"[0-9]*\")/set(CPACK_PACKAGE_VERSION_PRE_RELEASE \"${next_tag_number}\")/g" CMakeLists.txt From 77ca7cbdf825159328603d926b14665ac4359398 Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Sun, 2 Jul 2023 10:54:55 +0200 Subject: [PATCH 22/32] Handling release branches differently. - refactored script by making it more modular - script expects releases to be made from a branch called `releases/v{Major}` - add -i flag to indicate wether or not to increment the generated tag - -i increments version_minor for release branches: tag --> V{Major}.{Minor + increment} - -i increments version_pre_release for all other non-release branches: tag --> V{Major}.{Minor}{branch_name}{pre_release + increment} - -o outputs either `version_pre_release` or `version_minor` depending on the branch Prevent incrementing if no tag exists yet - make sure V{Major}.0 is created even if the user forgets to set increment to 0 Make tag_created=true explicit --- ci/actions/generate_next_git_tag.sh | 172 +++++++++++++++++++++------- 1 file changed, 129 insertions(+), 43 deletions(-) diff --git a/ci/actions/generate_next_git_tag.sh b/ci/actions/generate_next_git_tag.sh index 181c5295d5..6578200b87 100755 --- a/ci/actions/generate_next_git_tag.sh +++ b/ci/actions/generate_next_git_tag.sh @@ -6,13 +6,18 @@ # ${branch_name} is converted to "DB" if the script operates on develop branch. (e.g first tag for V26: V26.0DB1) # if -c flag is provided, version_pre_release in CMakeLists.txt is incremented and a new tag is created and pushed to origin # if -o is provided, "build_tag" , "version_pre_release" and "tag_created" are written to file +# -i flag defines the incrementing. If the script runs on a "releases/v{Major}" branch, it increments minor_version. +# for all other non release branches it increments pre_release_vesrion. + +#!/bin/bash set -e output="" create=false tag_created="false" +increment=1 -while getopts ":o:c" opt; do +while getopts ":o:ci:" opt; do case ${opt} in o ) output=$OPTARG @@ -20,6 +25,9 @@ while getopts ":o:c" opt; do c ) create=true ;; + i ) + increment=$OPTARG + ;; \? ) echo "Invalid Option: -$OPTARG" 1>&2 exit 1 @@ -32,6 +40,76 @@ while getopts ":o:c" opt; do done shift $((OPTIND -1)) + +get_tag_suffix() { + local branch_name=$1 + local version_major=$2 + local tag_suffix=${branch_name//[^a-zA-Z0-9]/_} + + if [[ "$branch_name" == "develop" ]]; then + tag_suffix="DB" + fi + + echo $tag_suffix +} + +get_next_tag_number() { + local last_tag_number=$1 + local increment=$2 + echo $((last_tag_number + increment)) +} + +get_next_minor_version() { + local current_minor=$1 + local increment=$2 + echo $((current_minor + increment)) +} + +get_new_release_tag() { + local version_major=$1 + local next_minor=$2 + echo "V${version_major}.${next_minor}" +} + +get_new_other_tag() { + local base_version=$1 + local next_tag_number=$2 + echo "${base_version}${next_tag_number}" +} + +update_output_file() { + local output=$1 + local new_tag=$2 + local next_number=$3 + local tag_created=$4 + local tag_type=$5 + + if [[ -n "$output" ]]; then + echo "build_tag =$new_tag" > $output + echo "$tag_type =$next_number" >> $output + echo "tag_created =$tag_created" >> $output + fi +} + +update_cmake_lists() { + local tag_type=$1 + local next_number=$2 + local variable_to_update="" + + if [[ "$tag_type" == "version_pre_release" ]]; then + variable_to_update="CPACK_PACKAGE_VERSION_PRE_RELEASE" + elif [[ "$tag_type" == "version_minor" ]]; then + variable_to_update="CPACK_PACKAGE_VERSION_MINOR" + fi + + if [[ -n "$variable_to_update" ]]; then + sed -i.bak "s/set(${variable_to_update} \"[0-9]*\")/set(${variable_to_update} \"${next_number}\")/g" CMakeLists.txt + rm CMakeLists.txt.bak + git add CMakeLists.txt + git commit -m "Update ${variable_to_update} to $next_number" + fi +} + # Fetch all existing tags git fetch --tags -f @@ -41,74 +119,82 @@ current_commit_hash=$(git rev-parse HEAD) # Fetch branch name branch_name=$(git rev-parse --abbrev-ref HEAD) -# Check if the branch name is 'develop' -if [[ "$branch_name" == "develop" ]]; then - branch_name="DB" -fi - -# Replace special characters with underscores -branch_name=${branch_name//[^a-zA-Z0-9]/_} - # Fetch major and minor version numbers from CMakeLists.txt current_version_major=$(grep "CPACK_PACKAGE_VERSION_MAJOR" CMakeLists.txt | grep -o "[0-9]\+") current_version_minor=$(grep "CPACK_PACKAGE_VERSION_MINOR" CMakeLists.txt | grep -o "[0-9]\+") -# Construct the base version -base_version="V${current_version_major}.${current_version_minor}${branch_name}" - -# Fetch the existing tags -existing_tags=$(git tag --list "${base_version}*" | grep -E "${base_version}[0-9]+$") +# Initialize tag suffix and next number +tag_suffix="" +next_number=0 -# If no tag exists, then just append 1 to the base version -if [[ -z "$existing_tags" ]]; then - new_tag="${base_version}1" - tag_created="true" -else - # Fetch the last tag number, increment it, and append to the base version - last_tag=$(echo "$existing_tags" | sort -V | tail -n1) - last_tag_number=$(echo "$last_tag" | awk -F"${branch_name}" '{print $2}') +if [[ "$branch_name" == "releases/v$current_version_major" ]]; then - # Fetch the commit hash of the last commit of the previous tag, ignoring the commit with the version change - last_tag_commit_hash=$(git rev-list -n 2 $last_tag | tail -n 1) + tag_type="version_minor" + # Find existing tags for the release branch + existing_release_tags=$(git tag --list "V${current_version_major}.*" | grep -E "V${current_version_major}\.[0-9]+$") - if [[ "$current_commit_hash" == "$last_tag_commit_hash" ]]; then - echo "No new commits since the last tag. No new tag will be created." + # Check if any tag exists for the release branch + if [[ -z "$existing_release_tags" ]]; then + # No tag exists yet, use current minor version without incrementing + tag_created="true" + new_tag=$(get_new_release_tag $current_version_major $current_version_minor) + else + # Some tags already exist, increment the minor version with the defined $increment + tag_created="true" + next_number=$(get_next_minor_version $current_version_minor $increment) + new_tag=$(get_new_release_tag $current_version_major $next_number) + fi +else + # Non-release branches handling + tag_type="version_pre_release" + + tag_suffix=$(get_tag_suffix $branch_name $current_version_major) + base_version="V${current_version_major}.${current_version_minor}${tag_suffix}" + existing_tags=$(git tag --list "${base_version}*" | grep -E "${base_version}[0-9]+$") + last_tag_number=0 + + if [[ -n "$existing_tags" ]]; then + last_tag=$(echo "$existing_tags" | sort -V | tail -n1) + last_tag_number=$(echo "$last_tag" | awk -F"${tag_suffix}" '{print $2}') + last_tag_commit_hash=$(git rev-list -n 2 $last_tag | tail -n 1) + + if [[ "$current_commit_hash" == "$last_tag_commit_hash" ]]; then + echo "No new commits since the last tag. No new tag will be created." + tag_created="false" + else + tag_created="true" + next_number=$(get_next_tag_number $last_tag_number $increment) + new_tag=$(get_new_other_tag $base_version $next_number) + fi else - next_tag_number=$((last_tag_number + 1)) - new_tag="${base_version}${next_tag_number}" tag_created="true" + next_number=1 + new_tag=$(get_new_other_tag $base_version $next_number) fi fi -echo "$new_tag" -# Update output file -if [[ -n "$output" ]]; then - echo "build_tag =$new_tag" > $output - echo "version_pre_release =$next_tag_number" >> $output - echo "tag_created =$tag_created" >> $output -fi +update_output_file $output $new_tag $next_number $tag_created $tag_type # Skip tag creation if no new commits -if [[ "$tag_created" == "false" ]]; then +if [[ "$tag_created" == "true" ]]; then + echo "$new_tag" +else exit 0 fi if [[ $create == true ]]; then # Stash current changes git config user.name "${GITHUB_ACTOR}" - git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" + git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" - # Update CPACK_PACKAGE_VERSION_PRE_RELEASE in CMakeLists.txt (macOs compatible sed -i.bak) - sed -i.bak "s/set(CPACK_PACKAGE_VERSION_PRE_RELEASE \"[0-9]*\")/set(CPACK_PACKAGE_VERSION_PRE_RELEASE \"${next_tag_number}\")/g" CMakeLists.txt - rm CMakeLists.txt.bak - git add CMakeLists.txt - git commit -m "Update CPACK_PACKAGE_VERSION_PRE_RELEASE to $next_tag_number" + # Update variable in CMakeLists.txt + update_cmake_lists $tag_type $next_number # Create & Push the new tag git tag -a "$new_tag" -m "This tag was created with generate_next_git_tag.sh" git push origin "$new_tag" - # Undo the last commit and apply stashed changes + # Undo the last commit git reset --hard HEAD~1 echo "The tag $new_tag has been created and pushed, but the commit used for the tag does not exist on any branch." fi \ No newline at end of file From e4c150b131a0b1fdb20d49c20745eb0374075f6d Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Mon, 3 Jul 2023 08:49:38 +0200 Subject: [PATCH 23/32] Prevent output file from being created when -o is not provided - by redefining local output=$1 it is set to 0 instead of "" and a file called 0 was created --- ci/actions/generate_next_git_tag.sh | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/ci/actions/generate_next_git_tag.sh b/ci/actions/generate_next_git_tag.sh index 6578200b87..1b70d56303 100755 --- a/ci/actions/generate_next_git_tag.sh +++ b/ci/actions/generate_next_git_tag.sh @@ -77,12 +77,11 @@ get_new_other_tag() { echo "${base_version}${next_tag_number}" } -update_output_file() { - local output=$1 - local new_tag=$2 - local next_number=$3 - local tag_created=$4 - local tag_type=$5 +update_output_file() { + local new_tag=$1 + local next_number=$2 + local tag_created=$3 + local tag_type=$4 if [[ -n "$output" ]]; then echo "build_tag =$new_tag" > $output @@ -173,7 +172,7 @@ else fi fi -update_output_file $output $new_tag $next_number $tag_created $tag_type +update_output_file $new_tag $next_number $tag_created $tag_type # Skip tag creation if no new commits if [[ "$tag_created" == "true" ]]; then From 2f6ee01e06f254c4f03cb785f0c5ec185517bcfd Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Mon, 3 Jul 2023 12:04:53 +0200 Subject: [PATCH 24/32] prevent script exit from grep returning a non-zero exit status if it doesn't find anything --- ci/actions/generate_next_git_tag.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ci/actions/generate_next_git_tag.sh b/ci/actions/generate_next_git_tag.sh index 1b70d56303..93f899ea84 100755 --- a/ci/actions/generate_next_git_tag.sh +++ b/ci/actions/generate_next_git_tag.sh @@ -12,6 +12,7 @@ #!/bin/bash set -e +set -x output="" create=false tag_created="false" @@ -130,7 +131,7 @@ if [[ "$branch_name" == "releases/v$current_version_major" ]]; then tag_type="version_minor" # Find existing tags for the release branch - existing_release_tags=$(git tag --list "V${current_version_major}.*" | grep -E "V${current_version_major}\.[0-9]+$") + existing_release_tags=$(git tag --list "V${current_version_major}.*" | grep -E "V${current_version_major}\.[0-9]+$" || true) # Check if any tag exists for the release branch if [[ -z "$existing_release_tags" ]]; then @@ -149,7 +150,7 @@ else tag_suffix=$(get_tag_suffix $branch_name $current_version_major) base_version="V${current_version_major}.${current_version_minor}${tag_suffix}" - existing_tags=$(git tag --list "${base_version}*" | grep -E "${base_version}[0-9]+$") + existing_tags=$(git tag --list "${base_version}*" | grep -E "${base_version}[0-9]+$" || true) last_tag_number=0 if [[ -n "$existing_tags" ]]; then @@ -172,6 +173,8 @@ else fi fi + + update_output_file $new_tag $next_number $tag_created $tag_type # Skip tag creation if no new commits From aa4901092343a61956f09e29e2b1f7e05349f0d7 Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Mon, 3 Jul 2023 09:03:24 +0200 Subject: [PATCH 25/32] Add increment input to the workflow and force push if tag is unchanged - increment is 1 by default - if increment is 0, an existing tag will be updated (origin push -f). fixup! Add increment input to the workflow --- .github/workflows/artifacts_build_deploy.yml | 8 ++++++-- ci/actions/generate_next_git_tag.sh | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/artifacts_build_deploy.yml b/.github/workflows/artifacts_build_deploy.yml index 5600152c40..f464f85993 100644 --- a/.github/workflows/artifacts_build_deploy.yml +++ b/.github/workflows/artifacts_build_deploy.yml @@ -3,7 +3,11 @@ on: schedule: - cron: "0 0 * * 3,6" workflow_dispatch: - + inputs: + increment: + description: "increment version_minor (releases/v{} branch) or version_pre_release (all other branches)" + default: "1" + required: true env: artifact: 1 @@ -21,7 +25,7 @@ jobs: id: tag_set run: | output_var_file="variable_list.txt" - ci/actions/generate_next_git_tag.sh -c -o "${output_var_file}" + ci/actions/generate_next_git_tag.sh -c -o "${output_var_file}" -i ${{ github.event.inputs.increment }} CI_TAG=$(grep 'build_tag' ${output_var_file} | cut -d= -f2) echo "CI_TAG=${CI_TAG}" >> $GITHUB_OUTPUT TAG_CREATED=$(grep 'tag_created' ${output_var_file} | cut -d= -f2) diff --git a/ci/actions/generate_next_git_tag.sh b/ci/actions/generate_next_git_tag.sh index 93f899ea84..57d2d29ebe 100755 --- a/ci/actions/generate_next_git_tag.sh +++ b/ci/actions/generate_next_git_tag.sh @@ -194,7 +194,7 @@ if [[ $create == true ]]; then # Create & Push the new tag git tag -a "$new_tag" -m "This tag was created with generate_next_git_tag.sh" - git push origin "$new_tag" + git push origin "$new_tag" -f # Undo the last commit git reset --hard HEAD~1 From 105fd39a831a59bf0a5c40716cc9e945a92881dd Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Mon, 3 Jul 2023 17:00:41 +0200 Subject: [PATCH 26/32] Allow tag creation without file changes - the first tag of a releases/ branch creates no changes - a tag run with increment=0 creates no changes in both cases we want to create the tag (again) --- ci/actions/generate_next_git_tag.sh | 34 ++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/ci/actions/generate_next_git_tag.sh b/ci/actions/generate_next_git_tag.sh index 57d2d29ebe..c3f704ffc5 100755 --- a/ci/actions/generate_next_git_tag.sh +++ b/ci/actions/generate_next_git_tag.sh @@ -103,13 +103,26 @@ update_cmake_lists() { fi if [[ -n "$variable_to_update" ]]; then + echo "Update ${variable_to_update} to $next_number" sed -i.bak "s/set(${variable_to_update} \"[0-9]*\")/set(${variable_to_update} \"${next_number}\")/g" CMakeLists.txt - rm CMakeLists.txt.bak - git add CMakeLists.txt - git commit -m "Update ${variable_to_update} to $next_number" + rm CMakeLists.txt.bak fi + git add CMakeLists.txt } +function create_commit() { + git diff --cached --quiet + local has_changes=$? # store exit status of the last command + if [[ $has_changes -eq 0 ]]; then # no changes + echo "No changes to commit" + echo "false" + else # changes detected + git commit -m "Update CMakeLists.txt" + echo "true" + fi +} + + # Fetch all existing tags git fetch --tags -f @@ -190,13 +203,18 @@ if [[ $create == true ]]; then git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" # Update variable in CMakeLists.txt - update_cmake_lists $tag_type $next_number + update_cmake_lists "$tag_type" "$next_number" + + # Create commit in case of changes. Return "false" if no changes are detected. + commit_made=$(create_commit) - # Create & Push the new tag git tag -a "$new_tag" -m "This tag was created with generate_next_git_tag.sh" git push origin "$new_tag" -f + echo "The tag $new_tag has been created and pushed." - # Undo the last commit - git reset --hard HEAD~1 - echo "The tag $new_tag has been created and pushed, but the commit used for the tag does not exist on any branch." + #Only reset local branch if a commit was made + if [[ "$commit_made" == "true" ]]; then + git reset --hard HEAD~1 + echo "The commit used for the tag does not exist on any branch." + fi fi \ No newline at end of file From 2085d648d4ef4ab820508040bfd69948926c60b8 Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Thu, 29 Jun 2023 22:15:56 +0200 Subject: [PATCH 27/32] feat: implement workflow to prepare for a new major software release - Checks out the repository based on github.ref. - Extracts and sets current major and minor versions from CMakeLists.txt of github.ref. - Fetches the default branch name and sets it as an output. - Checks for existence of a corresponding release branch. If present, the workflow aborts, if not, it continues and sets the new release branch name. - Increments the major version in CMakeLists.txt on the default branch, commits this change, and pushes it back. - Checks out a new release branch, sets the pre-release version to 0 in CMakeLists.txt, commits this change, and pushes the new branch to the repository. fix: Configure git and fix output variables Change the order of steps to make the flow more natural Fix curl DEFAULT_BRANCH fix fix --- .github/workflows/prepare_release.yml | 71 +++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 .github/workflows/prepare_release.yml diff --git a/.github/workflows/prepare_release.yml b/.github/workflows/prepare_release.yml new file mode 100644 index 0000000000..57d01eecff --- /dev/null +++ b/.github/workflows/prepare_release.yml @@ -0,0 +1,71 @@ +name: Prepare Release +on: + workflow_dispatch: + +jobs: + promote_reference: + runs-on: ubuntu-22.04 + steps: + - name: Checkout repository + uses: actions/checkout@v3.1.0 + with: + ref: ${{ github.ref }} + fetch-depth: 0 + - name: Confifigure git user and email + run: | + git config --global user.name "${GITHUB_ACTOR}" + git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" + + - name: Fetch Major and Minor versions + id: fetch-versions + run: | + current_version_major=$(grep "CPACK_PACKAGE_VERSION_MAJOR" CMakeLists.txt | grep -o "[0-9]\+") + current_version_minor=$(grep "CPACK_PACKAGE_VERSION_MINOR" CMakeLists.txt | grep -o "[0-9]\+") + echo "Current major version: $current_version_major" + echo "Current minor version: $current_version_minor" + echo "major=${current_version_major}" >> $GITHUB_OUTPUT + echo "minor=${current_version_minor}" >> $GITHUB_OUTPUT + + - name: Check for existence of release branch + id: check-release-branch + run: | + release_branch_name="releases/v${{ steps.fetch-versions.outputs.major }}" + if git show-ref --verify --quiet refs/remotes/origin/$release_branch_name; then + echo "Release branch $release_branch_name already exists. Aborting..." + exit 1 + else + echo "Release branch does not exist. Continuing with preparation..." + echo "release-branch-name=${release_branch_name}" >> $GITHUB_OUTPUT + fi + + - name: Get default branch + id: get-default-branch + run: | + DEFAULT_BRANCH=$(curl --silent --show-error --header "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}" | jq .default_branch --raw-output) + echo "Default branch is $DEFAULT_BRANCH" + echo "default-branch=${DEFAULT_BRANCH}" >> $GITHUB_OUTPUT + + - name: Increment Major version on default branch + run: | + git checkout ${{ steps.get-default-branch.outputs.default-branch }} + new_version_major=$((${{ steps.fetch-versions.outputs.major }} + 1)) + sed -i.bak "s/set(CPACK_PACKAGE_VERSION_MAJOR \"[0-9]*\")/set(CPACK_PACKAGE_VERSION_MAJOR \"$new_version_major\")/g" CMakeLists.txt + rm CMakeLists.txt.bak + git add CMakeLists.txt + git commit -m "Update CPACK_PACKAGE_VERSION_MAJOR to $new_version_major" + git push origin ${{ steps.get-default-branch.outputs.default-branch }} + # Reset CPACK_PACKAGE_VERSION_MAJOR to its original value for the release branch + git reset --hard HEAD~1 + + - name: Prepare release branch and set pre-release to 0 + run: | + git checkout -b ${{ steps.check-release-branch.outputs.release-branch-name }} + sed -i.bak "s/set(CPACK_PACKAGE_VERSION_PRE_RELEASE \"[0-9]*\")/set(CPACK_PACKAGE_VERSION_PRE_RELEASE \"0\")/g" CMakeLists.txt + rm CMakeLists.txt.bak + git add CMakeLists.txt + git commit -m "Update CPACK_PACKAGE_VERSION_PRE_RELEASE to 0" + git push origin ${{ steps.check-release-branch.outputs.release-branch-name }} + shell: bash + env: + GITHUB_ACTOR: ${{ github.actor }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From b7e979ac9c6f03689a6cf0df3fc3c7e577c6e0ed Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Tue, 11 Jul 2023 17:56:21 +0200 Subject: [PATCH 28/32] Rename workflow to something more meaningful --- .github/workflows/artifacts_build_deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/artifacts_build_deploy.yml b/.github/workflows/artifacts_build_deploy.yml index f464f85993..4a3ca6b0ec 100644 --- a/.github/workflows/artifacts_build_deploy.yml +++ b/.github/workflows/artifacts_build_deploy.yml @@ -1,4 +1,4 @@ -name: All (Live Beta Test) +name: Build & Deploy (Live Beta Test) on: schedule: - cron: "0 0 * * 3,6" From 2a4fed74f6ac109dab2d832092c62a991ac1fbb0 Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Tue, 11 Jul 2023 17:54:27 +0200 Subject: [PATCH 29/32] Remove increment input from workflow - Autodetect if we need to increment the version or not on the release branch Expected behaviour : - Running the workflow multiple times without a new commit will rebuild and republish the same artifacts - Running the workflow after a new commit was made to the releases branch will increment version_minor by 1 - the version_minor is updated in CMakeLists.txt and committed to the release branch - a new tag is created and pushed with the incremented version_minor - Make logic for both release and other branches more obvious --> TODO?: instead of force pushing, we could remove -f option if branch or tag already exist --- .github/workflows/artifacts_build_deploy.yml | 8 +-- ci/actions/generate_next_git_tag.sh | 66 ++++++++++++-------- 2 files changed, 43 insertions(+), 31 deletions(-) diff --git a/.github/workflows/artifacts_build_deploy.yml b/.github/workflows/artifacts_build_deploy.yml index 4a3ca6b0ec..af93e9b824 100644 --- a/.github/workflows/artifacts_build_deploy.yml +++ b/.github/workflows/artifacts_build_deploy.yml @@ -3,11 +3,7 @@ on: schedule: - cron: "0 0 * * 3,6" workflow_dispatch: - inputs: - increment: - description: "increment version_minor (releases/v{} branch) or version_pre_release (all other branches)" - default: "1" - required: true + env: artifact: 1 @@ -25,7 +21,7 @@ jobs: id: tag_set run: | output_var_file="variable_list.txt" - ci/actions/generate_next_git_tag.sh -c -o "${output_var_file}" -i ${{ github.event.inputs.increment }} + ci/actions/generate_next_git_tag.sh -c -o "${output_var_file}" CI_TAG=$(grep 'build_tag' ${output_var_file} | cut -d= -f2) echo "CI_TAG=${CI_TAG}" >> $GITHUB_OUTPUT TAG_CREATED=$(grep 'tag_created' ${output_var_file} | cut -d= -f2) diff --git a/ci/actions/generate_next_git_tag.sh b/ci/actions/generate_next_git_tag.sh index c3f704ffc5..436e4dcbc7 100755 --- a/ci/actions/generate_next_git_tag.sh +++ b/ci/actions/generate_next_git_tag.sh @@ -6,8 +6,9 @@ # ${branch_name} is converted to "DB" if the script operates on develop branch. (e.g first tag for V26: V26.0DB1) # if -c flag is provided, version_pre_release in CMakeLists.txt is incremented and a new tag is created and pushed to origin # if -o is provided, "build_tag" , "version_pre_release" and "tag_created" are written to file -# -i flag defines the incrementing. If the script runs on a "releases/v{Major}" branch, it increments minor_version. -# for all other non release branches it increments pre_release_vesrion. +# If it executes on a release-branch : +# --> if there is no new commit, the same tag is generated again +# --> If there is a new commit compared to the previous tag, we would increment the minor version by 1 and build the new binaries & docker images #!/bin/bash @@ -16,9 +17,8 @@ set -x output="" create=false tag_created="false" -increment=1 -while getopts ":o:ci:" opt; do +while getopts ":o:c" opt; do case ${opt} in o ) output=$OPTARG @@ -26,9 +26,6 @@ while getopts ":o:ci:" opt; do c ) create=true ;; - i ) - increment=$OPTARG - ;; \? ) echo "Invalid Option: -$OPTARG" 1>&2 exit 1 @@ -132,15 +129,20 @@ current_commit_hash=$(git rev-parse HEAD) # Fetch branch name branch_name=$(git rev-parse --abbrev-ref HEAD) +# Determine if it's a release branch or not +is_release_branch=$(echo "$branch_name" | grep -q "releases/v$current_version_major" && echo true || echo false) + + # Fetch major and minor version numbers from CMakeLists.txt current_version_major=$(grep "CPACK_PACKAGE_VERSION_MAJOR" CMakeLists.txt | grep -o "[0-9]\+") current_version_minor=$(grep "CPACK_PACKAGE_VERSION_MINOR" CMakeLists.txt | grep -o "[0-9]\+") -# Initialize tag suffix and next number +# Initialize tag suffix and next number and increment tag_suffix="" next_number=0 +increment=1 -if [[ "$branch_name" == "releases/v$current_version_major" ]]; then +if [[ $is_release_branch == true ]]; then tag_type="version_minor" # Find existing tags for the release branch @@ -150,13 +152,26 @@ if [[ "$branch_name" == "releases/v$current_version_major" ]]; then if [[ -z "$existing_release_tags" ]]; then # No tag exists yet, use current minor version without incrementing tag_created="true" - new_tag=$(get_new_release_tag $current_version_major $current_version_minor) + increment=0 else - # Some tags already exist, increment the minor version with the defined $increment - tag_created="true" - next_number=$(get_next_minor_version $current_version_minor $increment) - new_tag=$(get_new_release_tag $current_version_major $next_number) + # Some tags already exist + # Get the commit hash of the latest tag + last_tag=$(echo "$existing_release_tags" | sort -V | tail -n1) + last_tag_commit_hash=$(git rev-list -n 1 $last_tag) + + if [[ "$current_commit_hash" == "$last_tag_commit_hash" ]]; then + # The commit hash of the HEAD is the same as the last tag, hence no new commits. No need to increment + tag_created="true" + increment=0 + else + # There is a new commit, hence increment the minor version by 1 + tag_created="true" + increment=1 + fi fi + next_number=$(get_next_minor_version $current_version_minor $increment) + new_tag=$(get_new_release_tag $current_version_major $next_number) + else # Non-release branches handling tag_type="version_pre_release" @@ -164,12 +179,11 @@ else tag_suffix=$(get_tag_suffix $branch_name $current_version_major) base_version="V${current_version_major}.${current_version_minor}${tag_suffix}" existing_tags=$(git tag --list "${base_version}*" | grep -E "${base_version}[0-9]+$" || true) - last_tag_number=0 if [[ -n "$existing_tags" ]]; then last_tag=$(echo "$existing_tags" | sort -V | tail -n1) last_tag_number=$(echo "$last_tag" | awk -F"${tag_suffix}" '{print $2}') - last_tag_commit_hash=$(git rev-list -n 2 $last_tag | tail -n 1) + last_tag_commit_hash=$(git rev-list -n 2 $last_tag | tail -n 1) #ignore the commit that updates the version_pre_release if [[ "$current_commit_hash" == "$last_tag_commit_hash" ]]; then echo "No new commits since the last tag. No new tag will be created." @@ -177,17 +191,14 @@ else else tag_created="true" next_number=$(get_next_tag_number $last_tag_number $increment) - new_tag=$(get_new_other_tag $base_version $next_number) fi else tag_created="true" - next_number=1 - new_tag=$(get_new_other_tag $base_version $next_number) + next_number=1 #replace the default 99 fi + new_tag=$(get_new_other_tag $base_version $next_number) fi - - update_output_file $new_tag $next_number $tag_created $tag_type # Skip tag creation if no new commits @@ -205,15 +216,20 @@ if [[ $create == true ]]; then # Update variable in CMakeLists.txt update_cmake_lists "$tag_type" "$next_number" - # Create commit in case of changes. Return "false" if no changes are detected. commit_made=$(create_commit) - git tag -a "$new_tag" -m "This tag was created with generate_next_git_tag.sh" + git tag -fa "$new_tag" -m "This tag was created with generate_next_git_tag.sh" git push origin "$new_tag" -f echo "The tag $new_tag has been created and pushed." - #Only reset local branch if a commit was made - if [[ "$commit_made" == "true" ]]; then + # If it's a release branch, also push the commit to the branch + if [[ $is_release_branch == true ]]; then + git push origin "$branch_name" -f + echo "The commit has been pushed to the $branch_name branch." + fi + + # Only reset local branch if a commit was made and it's not a "releases" branch. + if [[ "$commit_made" == "true" && $is_release_branch == false ]]; then git reset --hard HEAD~1 echo "The commit used for the tag does not exist on any branch." fi From e6d115ecf854a3d2bfdc9274480deac08d4068d2 Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Sat, 1 Jul 2023 20:41:55 +0200 Subject: [PATCH 30/32] Retry "brew update" up to 5 times with 15s interval --- ci/prepare/macos/prepare.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ci/prepare/macos/prepare.sh b/ci/prepare/macos/prepare.sh index 5ca21a9b82..b66fedaac7 100755 --- a/ci/prepare/macos/prepare.sh +++ b/ci/prepare/macos/prepare.sh @@ -1,7 +1,9 @@ #!/bin/bash set -euox pipefail -brew update +#Homebrew randomly fails to update. Retry 5 times with 15s interval +for i in {1..5}; do brew update && break || { echo "Update failed, retrying..."; sleep 15; }; done + brew install coreutils brew install qt@5 From e61ea84ebd7bc7e6a0af6a245eff21a9685c43f8 Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Sun, 16 Jul 2023 09:43:25 +0200 Subject: [PATCH 31/32] Apply suggestions from PR review (1/2) --- .github/workflows/artifacts_build_deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/artifacts_build_deploy.yml b/.github/workflows/artifacts_build_deploy.yml index af93e9b824..ce748f2075 100644 --- a/.github/workflows/artifacts_build_deploy.yml +++ b/.github/workflows/artifacts_build_deploy.yml @@ -1,4 +1,4 @@ -name: Build & Deploy (Live Beta Test) +name: Build & Deploy on: schedule: - cron: "0 0 * * 3,6" @@ -9,7 +9,7 @@ env: jobs: prepare_build: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 outputs: CI_TAG: ${{ steps.tag_set.outputs.CI_TAG }} TAG_CREATED: ${{ steps.tag_set.outputs.tag_created }} From 148ec836afaa8b8fa90e67bd7e0c63ed2774dbf4 Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Sun, 16 Jul 2023 09:52:28 +0200 Subject: [PATCH 32/32] Apply suggestions from PR review (2/2) Convert if/else into case..in --- ci/actions/deploy.sh | 18 +++++++++++------- ci/build-deploy.sh | 20 ++++++++++++-------- ci/build-gitlab.sh | 24 ++++++++++++++---------- ci/build-rhel.sh | 24 ++++++++++++++---------- 4 files changed, 51 insertions(+), 35 deletions(-) diff --git a/ci/actions/deploy.sh b/ci/actions/deploy.sh index ac4b74c8d0..cc6f754fe4 100755 --- a/ci/actions/deploy.sh +++ b/ci/actions/deploy.sh @@ -7,13 +7,17 @@ OS=$(uname) IS_RPM_DEPLOY="${LINUX_RPM:-0}" S3_BUCKET_NAME="${S3_BUCKET_NAME:-repo.nano.org}" -if [[ "${NETWORK}" == "BETA" ]]; then - BUILD="beta" -elif [[ "${NETWORK}" == "TEST" ]]; then - BUILD="test" -else - BUILD="live" -fi +case "${NETWORK}" in + "BETA") + BUILD="beta" + ;; + "TEST") + BUILD="test" + ;; + *) + BUILD="live" + ;; +esac if [[ -n "${S3_BUILD_DIRECTORY}" ]]; then diff --git a/ci/build-deploy.sh b/ci/build-deploy.sh index c520a3a718..335d0f488e 100755 --- a/ci/build-deploy.sh +++ b/ci/build-deploy.sh @@ -15,14 +15,18 @@ mkdir build pushd build CONFIGURATION="Release" -if [[ "${NETWORK}" == "BETA" ]]; then - NETWORK_CFG="beta" - CONFIGURATION="RelWithDebInfo" -elif [[ "${NETWORK}" == "TEST" ]]; then - NETWORK_CFG="test" -else - NETWORK_CFG="live" -fi +case "${NETWORK}" in + "BETA") + NETWORK_CFG="beta" + CONFIGURATION="RelWithDebInfo" + ;; + "TEST") + NETWORK_CFG="test" + ;; + *) + NETWORK_CFG="live" + ;; +esac cmake \ -G'Unix Makefiles' \ diff --git a/ci/build-gitlab.sh b/ci/build-gitlab.sh index 7eb8894e6a..b303ff36b4 100755 --- a/ci/build-gitlab.sh +++ b/ci/build-gitlab.sh @@ -52,16 +52,20 @@ if [[ ${FLAVOR-_} == "_" ]]; then FLAVOR="" fi -if [[ "${NETWORK}" == "TEST" ]]; then - NETWORK_CFG="-DACTIVE_NETWORK=nano_test_network" - CONFIGURATION="RelWithDebInfo" -elif [[ "${NETWORK}" == "BETA" ]]; then - NETWORK_CFG="-DACTIVE_NETWORK=nano_beta_network" - CONFIGURATION="RelWithDebInfo" -else - NETWORK_CFG="-DACTIVE_NETWORK=nano_live_network" - CONFIGURATION="Release" -fi +case "${NETWORK}" in + "TEST") + NETWORK_CFG="-DACTIVE_NETWORK=nano_test_network" + CONFIGURATION="RelWithDebInfo" + ;; + "BETA") + NETWORK_CFG="-DACTIVE_NETWORK=nano_beta_network" + CONFIGURATION="RelWithDebInfo" + ;; + *) + NETWORK_CFG="-DACTIVE_NETWORK=nano_live_network" + CONFIGURATION="Release" + ;; +esac set -o nounset diff --git a/ci/build-rhel.sh b/ci/build-rhel.sh index 96c358ef09..e689133dae 100755 --- a/ci/build-rhel.sh +++ b/ci/build-rhel.sh @@ -9,16 +9,20 @@ run_source() { } run_build() { - mkdir -p ~/rpmbuild/SOURCES/ - mv -f ~/nano-${VERSION}.tar.gz ~/rpmbuild/SOURCES/. - if [[ "${NETWORK}" == "LIVE" ]]; then - scl enable gcc-toolset-12 'rpmbuild --nodebuginfo -ba nanocurrency.spec' - elif [[ "${NETWORK}" == "BETA" ]]; then - scl enable gcc-toolset-12 'rpmbuild -ba nanocurrency-beta.spec' - else - echo "Error: the node network was not defined." - exit 1 - fi + mkdir -p ~/rpmbuild/SOURCES/ + mv -f ~/nano-${VERSION}.tar.gz ~/rpmbuild/SOURCES/. + case "${NETWORK}" in + "LIVE") + scl enable gcc-toolset-12 'rpmbuild --nodebuginfo -ba nanocurrency.spec' + ;; + "BETA") + scl enable gcc-toolset-12 'rpmbuild -ba nanocurrency-beta.spec' + ;; + *) + echo "Error: the node network was not defined." + exit 1 + ;; + esac } run_update() {