From 1aefc23ab43201c2cfbd34cc48dd1d86f22d93fa Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Mon, 19 Jun 2023 14:30:01 +0200 Subject: [PATCH 01/27] 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 c8b93b25b1c8b3ec72a9ca4654ed52cfe6efcf7f Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Thu, 22 Jun 2023 10:34:35 +0200 Subject: [PATCH 02/27] 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 ec0ea85663..0ec644794e 100644 --- a/docker/node/Dockerfile +++ b/docker/node/Dockerfile @@ -2,9 +2,6 @@ FROM ubuntu:22.04 as builder ARG COMPILER=gcc 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 @@ -13,6 +10,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 805d540dc8f00b97c8b149884af5ff04bbcb2fe4 Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Mon, 19 Jun 2023 14:45:37 +0200 Subject: [PATCH 03/27] 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 e9a65448a12100a4a1ad9690a5ef29ef3022e4d5 Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Mon, 19 Jun 2023 14:40:10 +0200 Subject: [PATCH 04/27] 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 5e3da11b84bb4e5f1d3fa97bdbea4f52b2d21fe4 Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Mon, 19 Jun 2023 16:55:56 +0200 Subject: [PATCH 05/27] 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 1eabd6be2c4c771a4628ea7c757e8b39763143d2 Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Thu, 22 Jun 2023 10:58:33 +0200 Subject: [PATCH 06/27] 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 58c2af92dae62d46ce3a0594918bc02df866f90f Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Thu, 22 Jun 2023 11:07:42 +0200 Subject: [PATCH 07/27] 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 58377bcb6ecfb1a170d32b8c434a8f47ba1a5383 Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Thu, 22 Jun 2023 11:18:08 +0200 Subject: [PATCH 08/27] 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 230fcf143cf0b23bb89af87173d3d67990b15bb2 Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Thu, 22 Jun 2023 15:56:45 +0200 Subject: [PATCH 09/27] 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 174df3470de56c6fc0a1881fed917a0bb46c1f2f Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Thu, 22 Jun 2023 17:20:50 +0200 Subject: [PATCH 10/27] 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 01f8bca3f3224df1ea8440047b2c845c9cf1941d Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Thu, 29 Jun 2023 16:56:23 +0200 Subject: [PATCH 11/27] 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 515f3f139444d439742765dee27f0226e01e92bc Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Thu, 29 Jun 2023 17:00:17 +0200 Subject: [PATCH 12/27] 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 31df164b5f51370c616c87f2ad492bdca8014fe3 Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Thu, 29 Jun 2023 17:03:45 +0200 Subject: [PATCH 13/27] 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 8c07a94bf3796f171d82eece983cccb1c5464aa2 Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Thu, 29 Jun 2023 17:05:20 +0200 Subject: [PATCH 14/27] 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 e19736f00f3dedfe8b8682a668fd9422f6619e06 Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Thu, 29 Jun 2023 17:30:03 +0200 Subject: [PATCH 15/27] 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 e6f454e589c556d4a95451249c49d45eb1079405 Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Thu, 29 Jun 2023 17:49:15 +0200 Subject: [PATCH 16/27] 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 36de70b2cb9d277c968a719fcba7d6e62fea64f1 Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Fri, 30 Jun 2023 13:32:08 +0200 Subject: [PATCH 17/27] 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 64b697f33eec750da4850de6dc0ec90cebad4ffe Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Sat, 1 Jul 2023 10:47:13 +0200 Subject: [PATCH 18/27] 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 5183a3e80bd7b5aeafc75220727f6c8ad02900da Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Sat, 1 Jul 2023 15:28:28 +0200 Subject: [PATCH 19/27] 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 1a5577283395ca894d0971a1a5a4759b3b34eddc Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Sat, 1 Jul 2023 20:41:55 +0200 Subject: [PATCH 20/27] 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 a1fd6436080dc98770ed829e1490241a852d4161 Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Sat, 1 Jul 2023 22:25:50 +0200 Subject: [PATCH 21/27] 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 30d6b4ddc339bfc3b04e35442c3b30b466ccb6ab Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Sat, 1 Jul 2023 22:27:59 +0200 Subject: [PATCH 22/27] 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 a0ba5b14dc61e3b083b1278b65cbdb87fa1034d0 Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Sun, 2 Jul 2023 10:54:55 +0200 Subject: [PATCH 23/27] 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 --- ci/actions/generate_next_git_tag.sh | 163 ++++++++++++++++++++-------- 1 file changed, 118 insertions(+), 45 deletions(-) diff --git a/ci/actions/generate_next_git_tag.sh b/ci/actions/generate_next_git_tag.sh index 181c5295d5..632185c1cf 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,69 @@ 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}" +# Initialize tag suffix and next number +tag_suffix="" +next_number=0 +tag_created="true" -# Fetch the existing tags -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 - new_tag="${base_version}1" - tag_created="true" +if [[ "$branch_name" == "releases/v$current_version_major" ]]; then + # Releases branch handling + next_number=$(get_next_minor_version $current_version_minor $increment) + new_tag=$(get_new_release_tag $current_version_major $next_number) + tag_type="version_minor" 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." + # Non-release branches handling + 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 + next_number=$(get_next_tag_number $last_tag_number $increment) + new_tag=$(get_new_other_tag $base_version $next_number) + tag_type="version_pre_release" + 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) + tag_type="version_pre_release" 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 796ae86c70eff9f92b32262e03786df490e73fa5 Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Mon, 3 Jul 2023 08:48:30 +0200 Subject: [PATCH 24/27] Prevent incrementing if no tag exists yet - make sure V{Major}.0 is created even if the user forgets to set increment to 0 --- ci/actions/generate_next_git_tag.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/ci/actions/generate_next_git_tag.sh b/ci/actions/generate_next_git_tag.sh index 632185c1cf..9f14948c8e 100755 --- a/ci/actions/generate_next_git_tag.sh +++ b/ci/actions/generate_next_git_tag.sh @@ -129,9 +129,19 @@ next_number=0 tag_created="true" if [[ "$branch_name" == "releases/v$current_version_major" ]]; then - # Releases branch handling - next_number=$(get_next_minor_version $current_version_minor $increment) - new_tag=$(get_new_release_tag $current_version_major $next_number) + # 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]+$") + + # 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 + 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 + next_number=$(get_next_minor_version $current_version_minor $increment) + new_tag=$(get_new_release_tag $current_version_major $next_number) + fi + tag_type="version_minor" else # Non-release branches handling From acfc749040a61cb9f51108e1633a296d64afab97 Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Mon, 3 Jul 2023 08:49:38 +0200 Subject: [PATCH 25/27] 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 9f14948c8e..58dd0fc59b 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 @@ -170,7 +169,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 33165ea57fbd2aa652309cf14bde9a52ea611bc8 Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Mon, 3 Jul 2023 09:03:24 +0200 Subject: [PATCH 26/27] Add increment input to the workflow - increment is 1 by default - if increment is 0, an existing tag will be updated (origin push -f). --- .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..ae10aa4835 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 58dd0fc59b..5880d1c69c 100755 --- a/ci/actions/generate_next_git_tag.sh +++ b/ci/actions/generate_next_git_tag.sh @@ -188,7 +188,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 d03357c8cbcda1acfadb0a65c95e351402c990a9 Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Mon, 3 Jul 2023 09:09:30 +0200 Subject: [PATCH 27/27] Make tag_created=true explicit --- ci/actions/generate_next_git_tag.sh | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/ci/actions/generate_next_git_tag.sh b/ci/actions/generate_next_git_tag.sh index 5880d1c69c..503a4eaa03 100755 --- a/ci/actions/generate_next_git_tag.sh +++ b/ci/actions/generate_next_git_tag.sh @@ -125,25 +125,28 @@ current_version_minor=$(grep "CPACK_PACKAGE_VERSION_MINOR" CMakeLists.txt | grep # Initialize tag suffix and next number tag_suffix="" next_number=0 -tag_created="true" -if [[ "$branch_name" == "releases/v$current_version_major" ]]; then +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]+$") # 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 - - tag_type="version_minor" + 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]+$") @@ -158,14 +161,14 @@ else 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) - tag_type="version_pre_release" + 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) - tag_type="version_pre_release" + new_tag=$(get_new_other_tag $base_version $next_number) fi fi