Add beta build workflow for the release branch (#4025)

* Add beta build workflow for the release branch
* Improves the dev-build-tag-gen.sh script
This commit is contained in:
Thiago Silva 2022-12-12 14:16:24 -03:00 committed by GitHub
commit a1ff89ba10
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 278 additions and 29 deletions

View file

@ -34,11 +34,10 @@ jobs:
- name: Generate the new tag
id: tag_gen
run: |
(
source ci/actions/dev-build-tag-gen.sh
echo "::set-output name=build_tag::$build_tag"
echo "::set-output name=build_number::$build_number"
)
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

View file

@ -0,0 +1,161 @@
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-11
timeout-minutes: 90
env:
BOOST_ROOT: /tmp/boost
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_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

@ -1,8 +1,10 @@
#!/bin/bash
# This script gets the last DB tag for the next release version and checks whether the develop branch contains new
# commits since the last develop build. If so, it sets and exports the variable $build_tag with the correct numbering
# for the next DB build.
# This script gets the last DB tag for the current release version and checks whether the develop branch contains new
# commits since the last develop build. If so, it sets and outputs the variable $build_tag with the correct numbering
# for the next DB build, and the build number used for it as $build_number variable.
# If the option -r is set, then it looks for the latest release branch, numbered as '<current major version>-1'.
# The -r option also outputs the release branch name as $release_branch.
# Error exit codes:
# 0: success, the build tag was generated!
# 1: branch error or invalid usage of the script.
@ -10,16 +12,27 @@
source_dir="$(pwd)"
git_upstream="origin"
previous_release_gen=false
output_file=""
print_usage() {
echo "$(basename ${0}) [OPTIONS]"
function print_short_usage {
echo "$(basename ${0}) -o <output_file> [OPTIONS]"
echo "Specify -h to see the options."
}
function print_usage {
echo "$(basename ${0}) -o <output_file> [OPTIONS]"
echo "ARGUMENTS:"
echo " -o <output_file> Export the variables to an output file (sourcing this script is deprecated)."
echo
echo "OPTIONS:"
echo " [-h] Print this help info."
echo " [-s <source_dir>] Directory that contains the source-code. Default is \$PWD."
echo " [-u <git_upstream>] Name of the git repository upstream. Default is \"${git_upstream}\"."
echo " [-r] Generates build tag for the latest release branch."
}
while getopts 'hs:u:' OPT; do
while getopts 'hs:u:ro:' OPT; do
case "${OPT}" in
h)
print_usage
@ -28,14 +41,24 @@ while getopts 'hs:u:' OPT; do
s)
source_dir="${OPTARG}"
if [[ ! -d "$source_dir" ]]; then
echo "Invalid source directory"
echo "error: invalid source directory"
exit 1
fi
;;
u)
git_upstream="${OPTARG}"
if [[ -z "$git_upstream" ]]; then
echo "Invalid git upstream"
echo "error: invalid git upstream"
exit 1
fi
;;
r)
previous_release_gen=true
;;
o)
output_file="${OPTARG}"
if [[ -f "$output_file" ]]; then
echo "error: the provided output_file already exists"
exit 1
fi
;;
@ -46,6 +69,34 @@ while getopts 'hs:u:' OPT; do
esac
done
if [[ -z "$output_file" ]]; then
echo "error: invalid file name for exporting the variables"
print_short_usage >&2
exit 1
fi
function get_first_item {
local list="$1"
for item in $list; do
if [[ -n "$item" ]]; then
echo "$item"
break
fi
done
}
function output_variable {
if [[ $# -ne 1 ]]; then
echo "illegal number of parameters"
exit 1
fi
local var_name="$1"
local var_value=${!var_name}
if [[ -n "$output_file" ]]; then
echo "${var_name}=${var_value}" >> "$output_file"
fi
}
set -o nounset
set -o xtrace
@ -53,43 +104,81 @@ current_version_major=$(grep -P "(set)(.)*(CPACK_PACKAGE_VERSION_MAJOR)" "${sour
current_version_minor=$(grep -P "(set)(.)*(CPACK_PACKAGE_VERSION_MINOR)" "${source_dir}/CMakeLists.txt" | grep -oP "([0-9]+)")
current_version_pre_release=$(grep -P "(set)(.)*(CPACK_PACKAGE_VERSION_PRE_RELEASE)" "${source_dir}/CMakeLists.txt" | grep -oP "([0-9]+)")
version_tags=$(git tag | sort -V -r | grep -E "^(V([0-9]+).([0-9]+)(RC[0-9]+)?)$")
last_tag=$(get_first_item "$version_tags")
tag_version_major=$(echo "$last_tag" | grep -oP "\V([0-9]+)\." | grep -oP "[0-9]+")
if [[ ${tag_version_major} -ge ${current_version_major} ]]; then
echo "error: this is not the develop branch or your higher tag version is not equivalent to the current major version."
exit 1
fi
if [[ ${current_version_minor} != "0" ]]; then
echo "error: this is not the develop branch or the version-minor number is not properly set."
exit 1
fi
if [[ ${current_version_pre_release} != "99" ]]; then
echo "This is not the develop branch or the pre-release version is not properly set."
echo "error this is not the develop branch or the pre-release version is not properly set."
exit 1
fi
pushd "$source_dir"
last_tag=""
version_tags=$(git tag | sort -V -r | grep -E "^(V(${current_version_major}).(${current_version_minor})(DB[0-9]+))$")
for tag in $version_tags; do
if [[ -n "$tag" ]]; then
last_tag=$tag
echo "Found tag: $tag"
break
fi
done
version_tags=""
previous_release_major=0
previous_release_minor=0
if [[ $previous_release_gen == false ]]; then
version_tags=$(git tag | sort -V -r | grep -E "^(V(${current_version_major}).(${current_version_minor})(DB[0-9]+))$" || true)
last_tag=$(get_first_item "$version_tags")
else
previous_release_major=$(( current_version_major - 1 ))
version_tags=$(git tag | sort -V -r | grep -E "^(V(${previous_release_major}).([0-9]+)(DB[0-9]+)?)$" || true)
last_tag=$(get_first_item "$version_tags")
previous_release_minor=$(echo "$last_tag" | grep -oP "\.([0-9]+)" | grep -oP "[0-9]+")
release_branch="releases/v${previous_release_major}"
output_variable release_branch
fi
popd
build_tag=""
if [[ -z "$last_tag" ]]; then
echo "No tag found"
export build_number=1
export build_tag="V${current_version_major}.${current_version_minor}DB${build_number}"
build_number=1
echo "info: no tag found, build_number=${build_number}"
if [[ $previous_release_gen == false ]]; then
build_tag="V${current_version_major}.${current_version_minor}DB${build_number}"
else
build_tag="V${previous_release_major}.${previous_release_minor}DB${build_number}"
fi
output_variable build_number
output_variable build_tag
exit 0
fi
pushd "$source_dir"
develop_head=$(git rev-parse "${git_upstream}/develop")
develop_head=""
if [[ $previous_release_gen == false ]]; then
develop_head=$(git rev-parse "${git_upstream}/develop")
else
develop_head=$(git rev-parse "${git_upstream}/${release_branch}")
fi
tag_head=$(git rev-list "$last_tag" | head -n 1)
popd
if [[ "$develop_head" == "$tag_head" ]]; then
echo "No new commits for the develop build, the develop branch head matches the latest DB tag head!"
echo "error: no new commits for the develop build, the develop (or release) branch head matches the latest DB tag head!"
exit 2
fi
latest_build_number=$(echo "$last_tag" | grep -oP "(DB[0-9]+)" | grep -oP "[0-9]+")
export build_number=$(( latest_build_number + 1 ))
export build_tag="V${current_version_major}.${current_version_minor}DB${build_number}"
build_number=$(( latest_build_number + 1 ))
if [[ $previous_release_gen == false ]]; then
build_tag="V${current_version_major}.${current_version_minor}DB${build_number}"
else
build_tag="V${previous_release_major}.${previous_release_minor}DB${build_number}"
fi
output_variable build_number
output_variable build_tag
set +o nounset
set +o xtrace