diff --git a/.github/workflows/artifacts_build_deploy.yml b/.github/workflows/artifacts_build_deploy.yml new file mode 100644 index 0000000000..ce748f2075 --- /dev/null +++ b/.github/workflows/artifacts_build_deploy.yml @@ -0,0 +1,217 @@ +name: Build & Deploy +on: + schedule: + - cron: "0 0 * * 3,6" + workflow_dispatch: + +env: + artifact: 1 + +jobs: + prepare_build: + runs-on: ubuntu-22.04 + outputs: + CI_TAG: ${{ steps.tag_set.outputs.CI_TAG }} + TAG_CREATED: ${{ steps.tag_set.outputs.tag_created }} + steps: + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0 + with: + ref: ${{ github.ref }} + - name: Set the tag and version + id: tag_set + run: | + 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 + 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: + 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.repository }} + - name: Prepare + run: ci/prepare/macos/prepare.sh + - name: Build Artifact + run: ci/build-deploy.sh "/tmp/qt/lib/cmake/Qt5"; + env: + NETWORK: ${{ matrix.network }} + CI_TAG: ${{ needs.prepare_build.outputs.CI_TAG }} + - name: Deploy Artifact + run: ci/actions/deploy.sh + env: + NETWORK: ${{ matrix.network }} + TAG: ${{ needs.prepare_build.outputs.CI_TAG }} + 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 + + + linux_job: + needs: prepare_build + if: ${{ needs.prepare_build.outputs.TAG_CREATED == 'true' }} + 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.repository }} + - name: Prepare + run: sudo -E ci/prepare/linux/prepare.sh + - name: Build Artifact + 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: + NETWORK: ${{ matrix.network }} + TAG: ${{ needs.prepare_build.outputs.CI_TAG }} + 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 + + + linux_rpm_job: + needs: prepare_build + if: ${{ needs.prepare_build.outputs.TAG_CREATED == 'true' }} + 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.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 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 \ + local/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: + 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: ${{ 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 + + + linux_docker_job: + needs: prepare_build + if: ${{ needs.prepare_build.outputs.TAG_CREATED == 'true' }} + 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.repository }} + - name: Build Docker + run: ci/actions/linux/docker-build.sh + env: + NETWORK: ${{ matrix.network }} + 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 + - name: Deploy Docker Hub + if: env.DOCKER_PASSWORD_EXISTS == 'true' + run: ci/actions/linux/docker-deploy.sh + env: + CI_TAG: ${{ needs.prepare_build.outputs.CI_TAG }} + NETWORK: ${{ matrix.network }} + 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 + 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 + if: ${{ needs.prepare_build.outputs.TAG_CREATED == 'true' }} + 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.repository }} + - name: Prepare + run: ci/prepare/windows/prepare.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: ${{ needs.prepare_build.outputs.CI_TAG }} + 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 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/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 diff --git a/.github/workflows/develop_branch_dockers_deploy.yml b/.github/workflows/develop_branch_dockers_deploy.yml index a0109415fb..f69ee795be 100644 --- a/.github/workflows/develop_branch_dockers_deploy.yml +++ b/.github/workflows/develop_branch_dockers_deploy.yml @@ -7,22 +7,25 @@ on: jobs: linux_job: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0 with: 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_push.sh + 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) - 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/.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/prepare_release.yml b/.github/workflows/prepare_release.yml new file mode 100644 index 0000000000..57d01eecff --- /dev/null +++ b/.github/workflows/prepare_release.yml @@ -0,0 +1,71 @@ +name: Prepare Release +on: + workflow_dispatch: + +jobs: + promote_reference: + runs-on: ubuntu-22.04 + steps: + - name: Checkout repository + uses: actions/checkout@v3.1.0 + with: + ref: ${{ github.ref }} + fetch-depth: 0 + - name: Confifigure git user and email + run: | + git config --global user.name "${GITHUB_ACTOR}" + git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" + + - name: Fetch Major and Minor versions + id: fetch-versions + run: | + current_version_major=$(grep "CPACK_PACKAGE_VERSION_MAJOR" CMakeLists.txt | grep -o "[0-9]\+") + current_version_minor=$(grep "CPACK_PACKAGE_VERSION_MINOR" CMakeLists.txt | grep -o "[0-9]\+") + echo "Current major version: $current_version_major" + echo "Current minor version: $current_version_minor" + echo "major=${current_version_major}" >> $GITHUB_OUTPUT + echo "minor=${current_version_minor}" >> $GITHUB_OUTPUT + + - name: Check for existence of release branch + id: check-release-branch + run: | + release_branch_name="releases/v${{ steps.fetch-versions.outputs.major }}" + if git show-ref --verify --quiet refs/remotes/origin/$release_branch_name; then + echo "Release branch $release_branch_name already exists. Aborting..." + exit 1 + else + echo "Release branch does not exist. Continuing with preparation..." + echo "release-branch-name=${release_branch_name}" >> $GITHUB_OUTPUT + fi + + - name: Get default branch + id: get-default-branch + run: | + DEFAULT_BRANCH=$(curl --silent --show-error --header "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}" | jq .default_branch --raw-output) + echo "Default branch is $DEFAULT_BRANCH" + echo "default-branch=${DEFAULT_BRANCH}" >> $GITHUB_OUTPUT + + - name: Increment Major version on default branch + run: | + git checkout ${{ steps.get-default-branch.outputs.default-branch }} + new_version_major=$((${{ steps.fetch-versions.outputs.major }} + 1)) + sed -i.bak "s/set(CPACK_PACKAGE_VERSION_MAJOR \"[0-9]*\")/set(CPACK_PACKAGE_VERSION_MAJOR \"$new_version_major\")/g" CMakeLists.txt + rm CMakeLists.txt.bak + git add CMakeLists.txt + git commit -m "Update CPACK_PACKAGE_VERSION_MAJOR to $new_version_major" + git push origin ${{ steps.get-default-branch.outputs.default-branch }} + # Reset CPACK_PACKAGE_VERSION_MAJOR to its original value for the release branch + git reset --hard HEAD~1 + + - name: Prepare release branch and set pre-release to 0 + run: | + git checkout -b ${{ steps.check-release-branch.outputs.release-branch-name }} + sed -i.bak "s/set(CPACK_PACKAGE_VERSION_PRE_RELEASE \"[0-9]*\")/set(CPACK_PACKAGE_VERSION_PRE_RELEASE \"0\")/g" CMakeLists.txt + rm CMakeLists.txt.bak + git add CMakeLists.txt + git commit -m "Update CPACK_PACKAGE_VERSION_PRE_RELEASE to 0" + git push origin ${{ steps.check-release-branch.outputs.release-branch-name }} + shell: bash + env: + GITHUB_ACTOR: ${{ github.actor }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file 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 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}") diff --git a/ci/actions/deploy.sh b/ci/actions/deploy.sh index eed405e585..cc6f754fe4 100755 --- a/ci/actions/deploy.sh +++ b/ci/actions/deploy.sh @@ -5,19 +5,26 @@ set -o nounset set -o xtrace OS=$(uname) IS_RPM_DEPLOY="${LINUX_RPM:-0}" +S3_BUCKET_NAME="${S3_BUCKET_NAME:-repo.nano.org}" + +case "${NETWORK}" in + "BETA") + BUILD="beta" + ;; + "TEST") + BUILD="test" + ;; + *) + BUILD="live" + ;; +esac + +if [[ -n "${S3_BUILD_DIRECTORY}" ]]; then -if [[ "${BETA:-0}" -eq 1 ]]; then - BUILD="beta" -elif [[ "${TEST:-0}" -eq 1 ]]; then - BUILD="test" -else - BUILD="live" -fi -if [[ "${GITHUB_REPOSITORY:-}" == "nanocurrency/nano-node" ]]; then - DIRECTORY=$BUILD -else DIRECTORY="${S3_BUILD_DIRECTORY}/${BUILD}" +else + DIRECTORY=$BUILD fi if [[ "$OS" == 'Linux' && "$IS_RPM_DEPLOY" -eq "1" ]]; then @@ -29,8 +36,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 +45,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 +57,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/generate_next_git_tag.sh b/ci/actions/generate_next_git_tag.sh new file mode 100755 index 0000000000..436e4dcbc7 --- /dev/null +++ b/ci/actions/generate_next_git_tag.sh @@ -0,0 +1,236 @@ +#!/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 +# If it executes on a release-branch : +# --> if there is no new commit, the same tag is generated again +# --> If there is a new commit compared to the previous tag, we would increment the minor version by 1 and build the new binaries & docker images + +#!/bin/bash + +set -e +set -x +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)) + + +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 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 + 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 + echo "Update ${variable_to_update} to $next_number" + sed -i.bak "s/set(${variable_to_update} \"[0-9]*\")/set(${variable_to_update} \"${next_number}\")/g" CMakeLists.txt + rm CMakeLists.txt.bak + fi + git add CMakeLists.txt +} + +function create_commit() { + git diff --cached --quiet + local has_changes=$? # store exit status of the last command + if [[ $has_changes -eq 0 ]]; then # no changes + echo "No changes to commit" + echo "false" + else # changes detected + git commit -m "Update CMakeLists.txt" + echo "true" + fi +} + + +# Fetch all existing tags +git fetch --tags -f + +# 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) + +# Determine if it's a release branch or not +is_release_branch=$(echo "$branch_name" | grep -q "releases/v$current_version_major" && echo true || echo false) + + +# Fetch major and minor version numbers from CMakeLists.txt +current_version_major=$(grep "CPACK_PACKAGE_VERSION_MAJOR" CMakeLists.txt | grep -o "[0-9]\+") +current_version_minor=$(grep "CPACK_PACKAGE_VERSION_MINOR" CMakeLists.txt | grep -o "[0-9]\+") + +# Initialize tag suffix and next number and increment +tag_suffix="" +next_number=0 +increment=1 + +if [[ $is_release_branch == true ]]; 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]+$" || true) + + # 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" + increment=0 + else + # Some tags already exist + # Get the commit hash of the latest tag + last_tag=$(echo "$existing_release_tags" | sort -V | tail -n1) + last_tag_commit_hash=$(git rev-list -n 1 $last_tag) + + if [[ "$current_commit_hash" == "$last_tag_commit_hash" ]]; then + # The commit hash of the HEAD is the same as the last tag, hence no new commits. No need to increment + tag_created="true" + increment=0 + else + # There is a new commit, hence increment the minor version by 1 + tag_created="true" + increment=1 + fi + fi + next_number=$(get_next_minor_version $current_version_minor $increment) + new_tag=$(get_new_release_tag $current_version_major $next_number) + +else + # Non-release branches handling + tag_type="version_pre_release" + + tag_suffix=$(get_tag_suffix $branch_name $current_version_major) + base_version="V${current_version_major}.${current_version_minor}${tag_suffix}" + existing_tags=$(git tag --list "${base_version}*" | grep -E "${base_version}[0-9]+$" || true) + + 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) #ignore the commit that updates the version_pre_release + + if [[ "$current_commit_hash" == "$last_tag_commit_hash" ]]; then + echo "No new commits since the last tag. No new tag will be created." + tag_created="false" + else + tag_created="true" + next_number=$(get_next_tag_number $last_tag_number $increment) + fi + else + tag_created="true" + next_number=1 #replace the default 99 + fi + new_tag=$(get_new_other_tag $base_version $next_number) +fi + +update_output_file $new_tag $next_number $tag_created $tag_type + +# Skip tag creation if no new commits +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" + + # Update variable in CMakeLists.txt + update_cmake_lists "$tag_type" "$next_number" + + commit_made=$(create_commit) + + git tag -fa "$new_tag" -m "This tag was created with generate_next_git_tag.sh" + git push origin "$new_tag" -f + echo "The tag $new_tag has been created and pushed." + + # If it's a release branch, also push the commit to the branch + if [[ $is_release_branch == true ]]; then + git push origin "$branch_name" -f + echo "The commit has been pushed to the $branch_name branch." + fi + + # Only reset local branch if a commit was made and it's not a "releases" branch. + if [[ "$commit_made" == "true" && $is_release_branch == false ]]; then + git reset --hard HEAD~1 + echo "The commit used for the tag does not exist on any branch." + fi +fi \ No newline at end of file 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..bcda39fbbd 100755 --- a/ci/actions/linux/docker-impl/docker-common.sh +++ b/ci/actions/linux/docker-impl/docker-common.sh @@ -1,34 +1,37 @@ #!/bin/bash - set -e set -a scripts="$PWD/ci" -CI_BRANCH=$(git branch | cut -f2 -d' ') +CI_BRANCH=$(git rev-parse --abbrev-ref HEAD) +DOCKER_REGISTRY="${DOCKER_REGISTRY:-nanocurrency}" +DOCKER_USER="${DOCKER_USER:-nanoreleaseteam}" 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="${DOCKER_REGISTRY}/nano${network_tag_suffix}" +ghcr_image_name="ghcr.io/${GITHUB_REPOSITORY}/nano${network_tag_suffix}" docker_build() { @@ -37,44 +40,122 @@ 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 NANO_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 "$DOCKER_USER" "$DOCKER_PASSWORD" + if [[ "$NETWORK" = "LIVE" ]]; then + deploy_tags "${DOCKER_REGISTRY}" "env|ghcr.io|none|latest" else - echo "\$DOCKER_PASSWORD environment variable required" - exit 0 + deploy_tags "${DOCKER_REGISTRY}" "env|ghcr.io|none" fi } + +ghcr_deploy() +{ + docker_login "$DOCKER_USER" "$DOCKER_PASSWORD" "ghcr.io" + deploy_tags "${DOCKER_REGISTRY}/${GITHUB_REPOSITORY}" "env|none" +} + +docker_deploy_env() +{ + docker_login "$DOCKER_USER" "$DOCKER_PASSWORD" + local images=( + "${DOCKER_REGISTRY}/nano-env:base" + "${DOCKER_REGISTRY}/nano-env:gcc" + "${DOCKER_REGISTRY}/nano-env:clang" + ) + deploy_env_images "${images[@]}" +} + +ghcr_deploy_env() +{ + docker_login "$DOCKER_USER" "$DOCKER_PASSWORD" "ghcr.io" + local images=( + "${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[@]}" +} + +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 $registry -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") + + #Debug list all tags + docker images --format '{{.Repository}}:{{.Tag }}' + + 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 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" diff --git a/ci/actions/windows/build.ps1 b/ci/actions/windows/build.ps1 index af867129c5..45d05bea92 100644 --- a/ci/actions/windows/build.ps1 +++ b/ci/actions/windows/build.ps1 @@ -2,24 +2,23 @@ $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 { $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 { diff --git a/ci/actions/windows/deploy.ps1 b/ci/actions/windows/deploy.ps1 index 167756ec27..4a859ecebf 100644 --- a/ci/actions/windows/deploy.ps1 +++ b/ci/actions/windows/deploy.ps1 @@ -1,20 +1,21 @@ $ErrorActionPreference = "Continue" -if ( ${env:BETA} -eq 1 ) { +$env:S3_BUCKET_NAME = $env:S3_BUCKET_NAME ?? "repo.nano.org" +if ( "${env:NETWORK}" -eq "BETA" ) { $network_cfg = "beta" } -elseif ( ${env:TEST} -eq 1 ) { +elseif ( "${env:NETWORK}" -eq "TEST" ) { $network_cfg = "test" } 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 diff --git a/ci/build-deploy.sh b/ci/build-deploy.sh index 25f716e906..335d0f488e 100755 --- a/ci/build-deploy.sh +++ b/ci/build-deploy.sh @@ -15,14 +15,18 @@ mkdir build pushd build CONFIGURATION="Release" -if [[ "${BETA:-0}" -eq 1 ]]; then - NETWORK_CFG="beta" - CONFIGURATION="RelWithDebInfo" -elif [[ "${TEST:-0}" -eq 1 ]]; then - NETWORK_CFG="test" -else - NETWORK_CFG="live" -fi +case "${NETWORK}" in + "BETA") + NETWORK_CFG="beta" + CONFIGURATION="RelWithDebInfo" + ;; + "TEST") + NETWORK_CFG="test" + ;; + *) + NETWORK_CFG="live" + ;; +esac cmake \ -G'Unix Makefiles' \ diff --git a/ci/build-gitlab.sh b/ci/build-gitlab.sh index 83a62e15da..b303ff36b4 100755 --- a/ci/build-gitlab.sh +++ b/ci/build-gitlab.sh @@ -52,13 +52,20 @@ if [[ ${FLAVOR-_} == "_" ]]; then FLAVOR="" fi -if [[ "${BETA}" -eq 1 ]]; then - NETWORK_CFG="-DACTIVE_NETWORK=nano_beta_network" - CONFIGURATION="RelWithDebInfo" -else - NETWORK_CFG="-DACTIVE_NETWORK=nano_live_network" - CONFIGURATION="Release" -fi +case "${NETWORK}" in + "TEST") + NETWORK_CFG="-DACTIVE_NETWORK=nano_test_network" + CONFIGURATION="RelWithDebInfo" + ;; + "BETA") + NETWORK_CFG="-DACTIVE_NETWORK=nano_beta_network" + CONFIGURATION="RelWithDebInfo" + ;; + *) + NETWORK_CFG="-DACTIVE_NETWORK=nano_live_network" + CONFIGURATION="Release" + ;; +esac set -o nounset diff --git a/ci/build-rhel.sh b/ci/build-rhel.sh index 6726567504..e689133dae 100755 --- a/ci/build-rhel.sh +++ b/ci/build-rhel.sh @@ -9,16 +9,20 @@ run_source() { } run_build() { - mkdir -p ~/rpmbuild/SOURCES/ - mv -f ~/nano-${VERSION}.tar.gz ~/rpmbuild/SOURCES/. - if [ "${LIVE:-}" == "1" ]; then - scl enable gcc-toolset-12 'rpmbuild --nodebuginfo -ba nanocurrency.spec' - elif [ "${BETA:-}" == "1" ]; then - scl enable gcc-toolset-12 'rpmbuild -ba nanocurrency-beta.spec' - else - echo "Error: the node network was not defined." - exit 1 - fi + mkdir -p ~/rpmbuild/SOURCES/ + mv -f ~/nano-${VERSION}.tar.gz ~/rpmbuild/SOURCES/. + case "${NETWORK}" in + "LIVE") + scl enable gcc-toolset-12 'rpmbuild --nodebuginfo -ba nanocurrency.spec' + ;; + "BETA") + scl enable gcc-toolset-12 'rpmbuild -ba nanocurrency-beta.spec' + ;; + *) + echo "Error: the node network was not defined." + exit 1 + ;; + esac } run_update() { 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/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 diff --git a/docker/node/Dockerfile b/docker/node/Dockerfile index 53bd060df3..0c36f545c8 100644 --- a/docker/node/Dockerfile +++ b/docker/node/Dockerfile @@ -1,12 +1,7 @@ FROM ubuntu:22.04 as builder ARG COMPILER=gcc -ARG BUILD_TYPE=RelWithDebInfo -ARG SANITIZER ARG NANO_NETWORK=live -ARG CI_TAG=DEV_BUILD -ARG CI_BUILD=OFF -ARG CI_VERSION_PRE_RELEASE=OFF # Install build dependencies COPY ./ci/prepare/linux /tmp/prepare @@ -15,6 +10,15 @@ RUN /tmp/prepare/prepare.sh COPY ./ /tmp/src WORKDIR /tmp/src +#Define ARGs for ci/build-node.sh +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 RUN echo ${NANO_NETWORK} >/etc/nano-network