Improve: Consolidate artifact build process for all environments & Add Workflow for preparing release branch (#4256)

* 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

* 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

* Prepare WIndows for unified builds

- remove CI_BUILD
- convert DCI_TAG from ENV to CMake variable

* Convert TEST BETA and LIVE variable to NETWORK variable for easier workflow matrix usage

* 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)

* 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)

* 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

* Make workflow repository agnostic

Convert nanocurrency/nano-env image to self built ghcr.io/${{ github.repository }} image

* Fix CI_TAG usage

- convert ref to CI_TAG
- use CI_TAG in aws deploys

* Use same login for ghcr and hub.docker

* Fix docker login

- add possibility to specify registry
- use ghcr.io instead of variable for ghcr_image_name

* Fix nano network during build

* Use config variables instead of secrets for non secret variables

- vars.S3_BUCKET_NAME
- vars.S3_BUILD_DIRECTORY
- vars.DOCKER_REGISTRY
- vars.DOCKER_USER

* Fix: Make build process repository agnostic by specifying vars.DOCKER_REGISTRY

* 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.

* Remove CI_VERSION_PRE_RELEASE as it has been committed to CMakeLists.txt in the tag used to build the node

* Use the new prepare scripts

- use the new prepare scripts (Linux, MacOS & Windows)
- remove the need the dependency on nano-env:gcc

* Make usage of nano-env:rhel explicit

- Build the nano-env docker image in the current workflow
- Use the locally built image.

* Fix typo in default BUILD_TYPE

- Remove duplicate BUILD_TYPE
- move SANITIZER to ci/build-node.sh ARGs

* 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)

* Remove --global for git config

Prevent modification of global git settings on a developer machine

* Handling release branches differently.

- refactored script by making it more modular
- script expects releases to be made from a branch called `releases/v{Major}`
- add -i flag to indicate wether or not to increment the generated tag
- -i increments version_minor for release branches: tag --> V{Major}.{Minor + increment}
- -i increments version_pre_release for all other non-release branches: tag --> V{Major}.{Minor}{branch_name}{pre_release + increment}
- -o outputs either `version_pre_release` or `version_minor` depending on the branch

Prevent incrementing if no tag exists yet

- make sure V{Major}.0 is created even if the user forgets to set increment to 0

Make tag_created=true explicit

* 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

* prevent script exit from grep returning a non-zero exit status if it doesn't find anything

* Add increment input to the workflow and force push if tag is unchanged

- increment is 1 by default
- if increment is 0, an existing tag will be updated (origin push -f).

fixup! Add increment input to the workflow

* Allow tag creation without file changes

- the first tag of a releases/ branch creates no changes
- a tag run with increment=0 creates no changes
in both cases we want to create the tag (again)

* feat: implement workflow to prepare for a new major software release

- Checks out the repository based on github.ref.
- Extracts and sets current major and minor versions from CMakeLists.txt of github.ref.
- Fetches the default branch name and sets it as an output.
- Checks for existence of a corresponding release branch. If present, the workflow aborts, if not, it continues and sets the new release branch name.
- Increments the major version in CMakeLists.txt on the default branch, commits this change, and pushes it back.
- Checks out a new release branch, sets the pre-release version to 0 in CMakeLists.txt, commits this change, and pushes the new branch to the repository.

fix: Configure git and fix output variables

Change the order of steps to make the flow more natural

Fix curl DEFAULT_BRANCH

fix

fix

* Rename workflow to something more meaningful

* Remove increment input from workflow

- Autodetect if we need to increment the version or not on the release branch
Expected behaviour :
- Running the workflow multiple times without a new commit will rebuild and republish the same artifacts
- Running the workflow after a new commit was made to the releases branch will increment version_minor by 1
  - the version_minor is updated in CMakeLists.txt and committed to the release branch
  - a new tag is created and pushed with the incremented version_minor
- Make logic for both release and other branches more obvious

 --> TODO?: instead of force pushing, we could remove -f option if branch or tag already exist

* Retry "brew update" up to 5 times with 15s interval

* Apply suggestions from PR review (1/2)

* Apply suggestions from PR review (2/2)

Convert if/else into case..in

---------

Co-authored-by: gr0vity-dev <gr0vity-dev@users.noreply.github.com>
This commit is contained in:
gr0vity-dev 2023-07-20 19:37:15 +02:00 committed by GitHub
commit 47568010c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 795 additions and 823 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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
- name: Deploy Docker (nanocurrency/nano-env)
run: ci/actions/linux/docker-deploy.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)
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 }}

View file

@ -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

71
.github/workflows/prepare_release.yml vendored Normal file
View file

@ -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 }}

View file

@ -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

View file

@ -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}")

View file

@ -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

View file

@ -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

View file

@ -0,0 +1,8 @@
#!/bin/bash
set -e
set -x
source "$(dirname "$BASH_SOURCE")/docker-impl/docker-common.sh"
docker_deploy_env

View file

@ -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"
}

View file

@ -0,0 +1,8 @@
#!/bin/bash
set -e
set -x
source "$(dirname "$BASH_SOURCE")/docker-impl/docker-common.sh"
ghcr_deploy_env

View file

@ -0,0 +1,8 @@
#!/bin/bash
set -e
set -x
source "$(dirname "$BASH_SOURCE")/docker-impl/docker-common.sh"
ghcr_deploy

View file

@ -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

View file

@ -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"

View file

@ -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 {

View file

@ -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
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

View file

@ -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' \

View file

@ -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

View file

@ -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() {

View file

@ -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:-} \

View file

@ -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

View file

@ -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