From af1e5bf5358aedb907873e6f9abc0b4ca9e3d15e Mon Sep 17 00:00:00 2001 From: Nick Volynkin Date: Wed, 15 Nov 2023 19:46:31 +0200 Subject: [PATCH] ci: build deb always, push on tags * Build .deb packages on every CI run. * Push them only when tags are pushed. Note: CI doesn't check that tagged commit belongs to a stable branch. Check it yourself. * Update readme.md with info about .deb releases. Remove the auto-tagging CI. We don't need that many tags, because not every commit in master gets a proper integration testing. --- .github/workflows/build.yml | 49 ++++++++++- .github/workflows/linux_release.yml | 124 ---------------------------- .github/workflows/set_version.yml | 29 ------- README.md | 21 +++++ 4 files changed, 68 insertions(+), 155 deletions(-) delete mode 100644 .github/workflows/linux_release.yml delete mode 100644 .github/workflows/set_version.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 57c2df4b..f9c8ccd7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,8 +1,12 @@ name: Build on: + pull_request: push: - branches: [ 8-add-ci ] + branches: + - 'master' + tags: + - '**' jobs: build-linux: @@ -83,4 +87,45 @@ jobs: run: | cd build make - \ No newline at end of file + cd .. + + - name: Create .deb package + # always build deb packages to check that they're buildable + # although, push them only on tags (see later) + run: | + mkdir -p .debpkg/usr/bin + cp ./build/bin/proof-generator/proof-generator .debpkg/usr/bin + + chmod +x .debpkg/usr/bin/proof-generator + mkdir -p .debpkg/DEBIAN + + - uses: jiro4989/build-deb-action@v3 + with: + package: proof-generator + package_root: .debpkg + maintainer: =nil; Foundation + version: 0.1 + 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: 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` + 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/ + diff --git a/.github/workflows/linux_release.yml b/.github/workflows/linux_release.yml deleted file mode 100644 index 226ce48d..00000000 --- a/.github/workflows/linux_release.yml +++ /dev/null @@ -1,124 +0,0 @@ -name: Build .deb package - -on: - push: - branches: [ 8-add-ci ] - -jobs: - build-linux: - runs-on: [ "self-hosted", "aws_autoscaling"] - - env: - CONTAINER_TMP: /opt/ - HOST_TMP: /home/runner/work/_temp/ - DEBIAN_FRONTEND: noninteractive - BOOST_VERSION: "1.80.0" - - container: - image: ubuntu:22.04 - volumes: - - /home/runner/work/_temp/:/opt/ - - steps: - - name: Install dependencies - run: | - env && \ - apt update && \ - apt install -y \ - build-essential \ - libssl-dev \ - cmake \ - git \ - unzip \ - libicu-dev \ - curl \ - pkg-config \ - libspdlog-dev - - - name: Print toolchain information - run: | - git --version - cc --version - cmake --version - - - name: Checkout sources - uses: actions/checkout@v3 - with: - submodules: 'recursive' - fetch-depth: 0 - - - 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: | - git config --system --add safe.directory $PWD - - - name: Install boost - uses: MarkusJx/install-boost@v2.4.1 - id: install-boost - with: - # A list of supported versions can be found here: - # https://github.com/MarkusJx/prebuilt-boost/blob/main/versions-manifest.json - boost_version: ${{ env.BOOST_VERSION }} - boost_install_dir: ${{ env.CONTAINER_TMP }} - platform_version: 22.04 - toolset: gcc - arch: x86 - - - name: Configure CMake - env: - BOOST_ROOT: "${{ steps.install-boost.outputs.BOOST_ROOT }}" - run: | - cmake -G "Unix Makefiles" \ - -B build \ - -DCMAKE_BUILD_TYPE=Release - - - name: Build proof-producer - env: - BOOST_ROOT: "${{ steps.install-boost.outputs.BOOST_ROOT }}" - run: | - cd build - make - cd .. - - - name: Create .deb package - run: | - mkdir -p .debpkg/usr/bin - cp ./build/bin/proof-generator/proof-generator .debpkg/usr/bin - - chmod +x .debpkg/usr/bin/proof-generator - mkdir -p .debpkg/DEBIAN - - - uses: jiro4989/build-deb-action@v3 - with: - package: proof-generator - package_root: .debpkg - maintainer: =nil; Foundation - version: 0.1 - arch: 'amd64' - desc: 'zkllvm proof-generator' - - - 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 - - - name: Upload packages to repository - 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` - 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/ - - - diff --git a/.github/workflows/set_version.yml b/.github/workflows/set_version.yml deleted file mode 100644 index 8e3c6a67..00000000 --- a/.github/workflows/set_version.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Set version tag - -on: - # Triggers the workflow on push to master branch - push: - branches: [ none ] - -jobs: - set_version: - name: Set and tag version - runs-on: [ubuntu-latest] - env: - VERSION_FILE_NAME: VERSION - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Set version - id: set_version - run: | - version=$(cat ${{ env.VERSION_FILE_NAME }} | tr -d '\r').$GITHUB_RUN_NUMBER - echo "VERSION=$version" >> $GITHUB_ENV - - name: Tag new version - run: git tag v${{ env.VERSION }} - - - name: Push tags - uses: ad-m/github-push-action@master - with: - tags: true diff --git a/README.md b/README.md index c1691aa4..3552b62c 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,27 @@ ${ZKLLVM_BUILD:-build}/bin/assigner/assigner -b ${ZKLLVM_BUILD:-build}/examples/ ./bin/proof-generator/proof-generator --circuit=./merkle_tree_sha2_256_circuit.crt --assignment-table=/balances_tree.tbl --proof=./proof.txt ``` +# Releases + +## DEB packages + +Building DEB packages is tested on every CI run. +This way developers can be sure that their code can be built to a package +before they merge it. + +To make a DEB release: + +1. Update the version in the `VERSION` file, for example, `v0.42.0`. +2. Push this commit to the `master` branch. +3. Push a tag on this commit, named same as the version: + + ``` + git tag v0.42.0 + git push origin v0.42.0 + ``` + +4. Wait for CI to build and publish the package. + ## Toolchain Docker image Build an image: