From 415410754987666384118c0bfa969e7723e5d094 Mon Sep 17 00:00:00 2001 From: nkaskov Date: Tue, 2 Jan 2024 09:36:55 +0000 Subject: [PATCH] Package versioning updated to be the same with zkLLVM packages. --- .../{build.yml => release_linux.yml} | 146 +++++++++--------- CMakeLists.txt | 37 ++++- 2 files changed, 108 insertions(+), 75 deletions(-) rename .github/workflows/{build.yml => release_linux.yml} (54%) diff --git a/.github/workflows/build.yml b/.github/workflows/release_linux.yml similarity index 54% rename from .github/workflows/build.yml rename to .github/workflows/release_linux.yml index 5161873d..10689083 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/release_linux.yml @@ -1,12 +1,16 @@ -name: Build +name: Make release on: - pull_request: - push: - branches: - - 'master' - tags: - - '**' + workflow_dispatch: + inputs: + release_type: + type: choice + description: Release type + options: + - major + - minor + - patch + default: minor jobs: handle-syncwith: @@ -18,14 +22,8 @@ jobs: secrets: inherit - build-linux: - runs-on: [ "self-hosted", "aws_autoscaling"] - - needs: - - handle-syncwith - - # skipped status occurs on push event - if: ${{ needs.handle-syncwith.result == 'success' || needs.handle-syncwith.result == 'skipped' }} + make-release-linux: + runs-on: [ "self-hosted", Linux, X64, "aws_autoscaling"] env: CONTAINER_TMP: /opt/ @@ -78,21 +76,6 @@ jobs: submodules: 'recursive' fetch-depth: 0 - - name: Checkout modules to specified refs - if: needs.handle-syncwith.outputs.prs-refs != '' - uses: NilFoundation/ci-cd/actions/recursive-checkout@v1.1.2 - # TODO: figure out the mapping of volumes and use variable here, not hardcoded path - with: - paths: | - /__w/proof-producer/proof-producer/** - !/__w/proof-producer/proof-producer/**/.git/** - refs: ${{ needs.handle-syncwith.outputs.prs-refs }} - - - name: Install Python - uses: actions/setup-python@v4 - with: - python-version: '3.10' - # Workaround: https://github.com/actions/checkout/issues/1169 - name: Mark directory as safe run: | @@ -110,10 +93,53 @@ jobs: toolset: gcc arch: x86 - - name: Set VERSION variable - # required for building deb packages - # TODO: replace with getting version from git tag or commit SHA1 - run: echo "VERSION=$(cat VERSION)" >> $GITHUB_ENV + - name: Install Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: Install aws tools + run: | + curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" + unzip awscliv2.zip + ./aws/install + pip3 install mkrepo + + # Workaround: https://github.com/actions/checkout/issues/1169 + - name: Mark directory as safe + run: | + git config --system --add safe.directory $PWD + + - name: Compute release number + env: + RELEASE_TYPE: ${{ inputs.release_type }} + run: | + LATEST_TAG=`git describe --tags | cut -d'-' -f1 | tr -d v` + MAJOR=`echo $LATEST_TAG | cut -d'.' -f1` + MINOR=`echo $LATEST_TAG | cut -d'.' -f2` + PATCH=`echo $LATEST_TAG | cut -d'.' -f3` + + case $RELEASE_TYPE in + + major) + MAJOR=$((MAJOR+1)) + MINOR=0 + PATCH=0 + ;; + minor) + MINOR=$((MINOR+1)) + PATCH=0 + ;; + patch) + PATCH=$((PATCH+1)) + ;; + *) + echo "Unknown release type" + exit 1 + ;; + esac + echo "VERSION=$MAJOR.$MINOR.$PATCH" >> $GITHUB_ENV + echo "VERSION=$MAJOR.$MINOR.$PATCH" - name: Configure CMake env: @@ -121,56 +147,28 @@ jobs: run: | cmake -G "Unix Makefiles" \ -B build \ - -DCMAKE_BUILD_TYPE=Release + -DCMAKE_BUILD_TYPE=Release \ + -DPROOF_PRODUCER_VERSION=${{ env.VERSION }} . - - name: Build proof-producers (single- and multithreaded) - # working-directory: build - env: - BOOST_ROOT: "${{ steps.install-boost.outputs.BOOST_ROOT }}" - run: | - cd build - make - cd .. - # make -j $(nproc) -k - - - name: Create .deb package - # always build deb packages to check that they're buildable - # although, push them only on tags (see later) + - name: Build packages run: | - mkdir -p .debpkg/usr/bin - cp ./build/bin/proof-generator/proof-generator .debpkg/usr/bin - cp ./build/bin/proof-generator-multithreaded/proof-generator-multithreaded .debpkg/usr/bin + make -C build package -j$(nproc) - chmod +x .debpkg/usr/bin/proof-generator - chmod +x .debpkg/usr/bin/proof-generator-multithreaded - mkdir -p .debpkg/DEBIAN - - uses: jiro4989/build-deb-action@v3 + - name: Create release + uses: ncipollo/release-action@v1 with: - package: proof-generator - package_root: .debpkg - maintainer: =nil; Foundation - version: ${{ env.VERSION }} - arch: 'amd64' - desc: 'zkllvm proof-generator' - - - name: Install aws tools - # these steps run only on tag push => deb package release - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') - run: | - curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" - unzip awscliv2.zip - ./aws/install - pip3 install mkrepo + name: "proof-producer_-v${{ env.VERSION }}" + tag: "v${{ env.VERSION }}" + artifacts: "build/proof-producer_*.deb" - name: Upload packages to repository - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') env: AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }} run: | - PROOF_GENERATOR_PACKAGE=`ls proof-generator*.deb | cut -d'/' -f2` + PROOF_PRODUCER_PACKAGE=`ls build/proof-producer_*.deb | cut -d'/' -f2` POOL="ubuntu/pool/main/p/proof-generator" - aws s3api put-object --bucket deb.nil.foundation --key $POOL/$PROOF_GENERATOR_PACKAGE --body $PROOF_GENERATOR_PACKAGE - mkrepo s3://deb.nil.foundation/ubuntu/ + aws s3api put-object --bucket deb.nil.foundation --key $POOL/$PROOF_PRODUCER_PACKAGE --body $PROOF_PRODUCER_PACKAGE + mkrepo s3://deb.nil.foundation/ubuntu/ \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 591842c7..03523cc3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,13 +53,48 @@ add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/libs/module") add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/libs/plugin") add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/libs/application") +if(NOT PROOF_PRODUCER_VERSION) + execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags HEAD + OUTPUT_VARIABLE DESCRIBE_OUTBUT + OUTPUT_STRIP_TRAILING_WHITESPACE + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) + + if(NOT ("${DESCRIBE_OUTBUT}" STREQUAL "${PROOF_PRODUCER_VERSION}")) + set(PROOF_PRODUCER_VERSION "${DESCRIBE_OUTBUT}") + endif() + + if(NOT PROOF_PRODUCER_VERSION) + message(FATAL_ERROR + "Unable to retrive version from git or ${VERSION_FILE} file.") + endif() +endif() + +# Remove preceding 'v' from tag +string(REGEX REPLACE "^v" "" PROOF_PRODUCER_VERSION ${PROOF_PRODUCER_VERSION}) +# Split numbers +string(REPLACE "-" "." PROOF_PRODUCER_VERSION_LIST ${PROOF_PRODUCER_VERSION}) +string(REPLACE "." ";" PROOF_PRODUCER_VERSION_LIST ${PROOF_PRODUCER_VERSION_LIST}) + +list(LENGTH PROOF_PRODUCER_VERSION_LIST VERSION_LIST_LENGHT) + +list(GET PROOF_PRODUCER_VERSION_LIST 0 PROOF_PRODUCER_VERSION_MAJOR) +list(GET PROOF_PRODUCER_VERSION_LIST 1 PROOF_PRODUCER_VERSION_MINOR) +list(GET PROOF_PRODUCER_VERSION_LIST 2 PROOF_PRODUCER_VERSION_PATCH) +if(VERSION_LIST_LENGHT GREATER 3) + list(GET PROOF_PRODUCER_VERSION_LIST 3 PROOF_PRODUCER_VERSION_INCREMENT) +endif() + set(CPACK_GENERATOR DEB) set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT) set(CPACK_DEBIAN_PACKAGE_MAINTAINER "=nil; Foundation") set(CPACK_DEBIAN_PACKAGE_DEPENDENCIES_MULTITHREADED_VERSION "libhwloc-dev, libyaml-cpp-dev") set(CPACK_DEBIAN_PACKAGE_DEPENDS ${CPACK_DEBIAN_PACKAGE_DEPENDENCIES_MULTITHREADED_VERSION}) -set(CPACK_PACKAGE_VERSION "0.1.1") + +set(CPACK_PACKAGE_VERSION "${PROOF_PRODUCER_VERSION_MAJOR}.${PROOF_PRODUCER_VERSION_MINOR}.${PROOF_PRODUCER_VERSION_PATCH}") +if(PROOF_PRODUCER_VERSION_INCREMENT) + string(APPEND CPACK_PACKAGE_VERSION "-${PROOF_PRODUCER_VERSION_INCREMENT}") +endif() set(CPACK_PACKAGING_INSTALL_PREFIX "/usr/lib/zkllvm")