Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Merged

Conversation

gr0vity-dev
Copy link
Contributor

@gr0vity-dev gr0vity-dev commented Jul 3, 2023

What will the build pipeline look like ?

  • Twice per week the new “Build all artifacts” workflow runs automatically and creates a new V{Major}.0DBX build for Test, Beta and Live, where X is incremented by 1 if a new commit exists compared to the previous tag.
  • We could also run the “Build all artifacts” workflow manually
    • to create a new DB build in case we don’t want to wait for the automated execution
    • recreate a previous DB build (by setting increment to 0 for example)

What will the release process look like ?

  • We run the “Prepare release” workflow on the tag (or branch) which we want to use as starting point for the newly created release branch.

    • Usually this would be a V{Major}.0DBX tag that creates a releases/v{Major} branch
  • After the release branch has been successfully created we can run the “Build all artifacts” workflow manually to generate the release builds.

    • On its first execution it will create a tag V{Major}.0 (the increment which is 1 by default is ignored, to make sure that we have the correct tag even if we forget to set increment 0)
    • We can execute the build process again by setting increment=0 in case the build failed for whatever reason
    • We can create the next minor version V{Major}.1 by leaving the default (increment=1)

Improvements :

  • repository and branch agnostic
  • single workflow to build artifacts for all environments
  • new workflow to prepare the next releases branch from an existing branch or tag

Possible simplification

We could get rid of the “increment” input in the workflow by adopting a similar behaviour as DB builds.
When “Build all artifacts” runs on a release branch,

  • if there is no new commit, the workflow builds binaries & docker images for the current tag
  • If there is a new commit compared to the previous tag, the workflow increments version_minor by 1, creates a new tag and builds the new binaries & docker images

Prerequisits before merge

Required secrets:

AWS_ACCESS_KEY_ID 
AWS_SECRET_ACCESS_KEY

Optional secrets

DOCKER_PASSWORD (required to upload images to hub.docker.com)

Optional Repository variables:

DOCKER_REGISTRY (default = "nanocurrency")
DOCKER_USER  (default = "nanoreleaseteam")
S3_BUCKET_NAME (default = "repo.nano.org")
S3_BUILD_DIRECTORY (default = "")

How was the PR tested ?

docker pull gr0vity/nano-test:V26.0
docker pull gr0vity/nano-beta:V26.0
docker pull gr0vity/nano:V26.0

Creates binaries:

Test:
https://gr0vity-nanonode.s3.us-east-2.amazonaws.com/test/binaries/nano-node-V26.0-win64.zip
https://gr0vity-nanonode.s3.us-east-2.amazonaws.com/test/binaries/nano-node-V26.0-win64.exe
https://gr0vity-nanonode.s3.us-east-2.amazonaws.com/test/binaries/nano-node-V26.0-Darwin.dmg
https://gr0vity-nanonode.s3.us-east-2.amazonaws.com/test/binaries/nano-node-V26.0-Linux.deb
https://gr0vity-nanonode.s3.us-east-2.amazonaws.com/test/binaries/nano-node-V26.0-Linux.tar.bz2


Beta:
https://gr0vity-nanonode.s3.us-east-2.amazonaws.com/beta/binaries/nano-node-V26.0-Linux.deb
https://gr0vity-nanonode.s3.us-east-2.amazonaws.com/beta/binaries/nano-node-V26.0-Darwin.dmg
https://gr0vity-nanonode.s3.us-east-2.amazonaws.com/beta/binaries/nano-node-V26.0-Linux.tar.bz2
https://gr0vity-nanonode.s3.us-east-2.amazonaws.com/beta/binaries/nano-node-V26.0-win64.exe
https://gr0vity-nanonode.s3.us-east-2.amazonaws.com/beta/binaries/nano-node-V26.0-win64.zip
https://gr0vity-nanonode.s3.us-east-2.amazonaws.com/beta/source/nanocurrency-beta-26.0-1.el8.src.rpm


Live:
https://gr0vity-nanonode.s3.us-east-2.amazonaws.com/live/binaries/nano-node-V26.0-Linux.deb
https://gr0vity-nanonode.s3.us-east-2.amazonaws.com/live/binaries/nano-node-V26.0-Darwin.dmg
https://gr0vity-nanonode.s3.us-east-2.amazonaws.com/live/binaries/nano-node-V26.0-Linux.tar.bz2
https://gr0vity-nanonode.s3.us-east-2.amazonaws.com/live/binaries/nano-node-V26.0-win64.exe
https://gr0vity-nanonode.s3.us-east-2.amazonaws.com/live/binaries/nano-node-V26.0-win64.zip
https://gr0vity-nanonode.s3.us-east-2.amazonaws.com/live/source/nanocurrency-beta-26.0-1.el8.src.rpm

What needs to be tested ?

  • cron execution on develop branch
  • increment= 0 on a DB build
  • increment with values other than 0 or 1

Flowcharts of the intended behaviour for “Build all artifacts” workflow

Consolidate_workflow_part1
Consolidate_workflow_part2

Flowcharts of the intended behaviour for “Prepare release” workflow

Prepare_release

gr0vity-dev and others added 27 commits July 3, 2023 11:50
- 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
- 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
- remove CI_BUILD
- convert DCI_TAG from ENV to CMake variable
- 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)
- Remove old workflows
- Create 1 workflow for all environments (Network Matrix)
- Keep current build logic (build scripts still differ per OS)
- 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
Convert nanocurrency/nano-env image to self built ghcr.io/${{ github.repository }} image
- convert ref to CI_TAG
- use CI_TAG in aws deploys
- add possibility to specify registry
- use ghcr.io instead of variable for ghcr_image_name
- vars.S3_BUCKET_NAME
- vars.S3_BUILD_DIRECTORY
- vars.DOCKER_REGISTRY
- vars.DOCKER_USER
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.
- use the new prepare scripts (Linux, MacOS & Windows)
- remove the need the dependency on nano-env:gcc
- Build the nano-env docker image in the current workflow
- Use the locally built image.
- Remove duplicate BUILD_TYPE
- move SANITIZER to ci/build-node.sh ARGs
- fixes a bug when we have 2 similar branches with tags (e.g. some-branch and some-branch-2)
Prevent modification of global git settings on a developer machine
- 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
- by redefining local output=$1 it is set to 0 instead of "" and a file called 0 was created
- 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
- 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)
- 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
@gr0vity-dev gr0vity-dev changed the title Improve: Consolidate artifact build process for all environmentsWorkflow for preparing and managing release branch Improve: Consolidate artifact build process for all environments & Add Workflow for preparing release branch Jul 3, 2023
@gr0vity-dev gr0vity-dev marked this pull request as ready for review July 3, 2023 18:59
@gr0vity-dev gr0vity-dev force-pushed the prs/unified_artifacts_worflow branch 2 times, most recently from 3b11874 to 6877a57 Compare July 11, 2023 20:33
gr0vity-dev and others added 2 commits July 11, 2023 22:41
- 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
@gr0vity-dev gr0vity-dev force-pushed the prs/unified_artifacts_worflow branch from 6877a57 to e6d115e Compare July 11, 2023 20:41
pwojcikdev
pwojcikdev previously approved these changes Jul 15, 2023
.github/workflows/artifacts_build_deploy.yml Outdated Show resolved Hide resolved
.github/workflows/artifacts_build_deploy.yml Outdated Show resolved Hide resolved
.github/workflows/artifacts_build_deploy.yml Show resolved Hide resolved
ci/actions/deploy.sh Outdated Show resolved Hide resolved
docker/node/Dockerfile Show resolved Hide resolved
.github/workflows/artifacts_build_deploy.yml Show resolved Hide resolved
@pwojcikdev
Copy link
Contributor

I only have a few cosmetic comments, feel free to ignore those. Generally the PR looks well organized and will be a significant improvement.

@clemahieu clemahieu merged commit 4756801 into nanocurrency:develop Jul 20, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants