refactor!: move merkletree to own repo (#1390) #154
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*.*.*' | |
| branches: | |
| - master | |
| workflow_dispatch: | |
| env: | |
| cache_nonce: 0 # Allows for easily busting actions/cache caches | |
| nim_version: pinned | |
| storage_binary_base: logos-storage | |
| build_dir: build | |
| nim_flags: '' | |
| windows_libs: 'libstdc++-6.dll libgomp-1.dll libgcc_s_seh-1.dll libwinpthread-1.dll' | |
| jobs: | |
| # Matrix | |
| matrix: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| matrix: ${{ steps.matrix.outputs.matrix }} | |
| steps: | |
| - name: Compute matrix | |
| id: matrix | |
| uses: fabiocaccamo/create-matrix-action@v5 | |
| with: | |
| matrix: | | |
| os {linux}, cpu {amd64}, builder {ubuntu-22.04}, nim_version {${{ env.nim_version }}}, shell {bash --noprofile --norc -e -o pipefail} | |
| os {linux}, cpu {arm64}, builder {ubuntu-22.04-arm}, nim_version {${{ env.nim_version }}}, shell {bash --noprofile --norc -e -o pipefail} | |
| os {macos}, cpu {arm64}, builder {macos-14}, nim_version {${{ env.nim_version }}}, shell {bash --noprofile --norc -e -o pipefail} | |
| os {windows}, cpu {amd64}, builder {windows-latest}, nim_version {${{ env.nim_version }}}, shell {msys2} | |
| # Build | |
| build: | |
| needs: matrix | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: ${{fromJson(needs.matrix.outputs.matrix)}} | |
| defaults: | |
| run: | |
| shell: ${{ matrix.shell }} {0} | |
| name: ${{ matrix.os }}-${{ matrix.cpu }}-${{ matrix.nim_version }} | |
| runs-on: ${{ matrix.builder }} | |
| timeout-minutes: 80 | |
| steps: | |
| - name: Set version variable | |
| shell: bash | |
| run: | | |
| if [[ "${{ github.ref_type }}" == "tag" ]]; then | |
| echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV | |
| echo "TAGGED_RELEASE=true" >> $GITHUB_ENV | |
| else | |
| echo "VERSION=${GITHUB_SHA::7}" >> $GITHUB_ENV | |
| echo "TAGGED_RELEASE=false" >> $GITHUB_ENV | |
| fi | |
| - name: Release - Checkout sources | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Release - Setup Nimbus Build System | |
| uses: ./.github/actions/nimbus-build-system | |
| with: | |
| os: ${{ matrix.os }} | |
| cpu: ${{ matrix.cpu }} | |
| shell: ${{ matrix.shell }} | |
| nim_version: ${{ matrix.nim_version }} | |
| - name: Release - Compute binary name | |
| run: | | |
| case ${{ matrix.os }} in | |
| linux*) os_name="linux" ;; | |
| macos*) os_name="darwin" ;; | |
| windows*) os_name="windows" ;; | |
| esac | |
| storage_binary="${{ env.storage_binary_base }}-${os_name}-${{ matrix.cpu }}-${{ env.VERSION }}" | |
| if [[ ${os_name} == "windows" ]]; then | |
| storage_binary="${storage_binary}.exe" | |
| fi | |
| echo "storage_binary=${storage_binary}" >>$GITHUB_ENV | |
| - name: Release - Build | |
| run: | | |
| make NIMFLAGS="--out:${{ env.build_dir }}/${{ env.storage_binary }} ${{ env.nim_flags }}" | |
| - name: Release - Build libstorage (Linux) | |
| if: matrix.os == 'linux' | |
| run: | | |
| make -j${ncpu} update | |
| make -j${ncpu} libstorage | |
| - name: Release - Build libstorage (MacOS) | |
| if: matrix.os == 'macos' | |
| run: | | |
| make -j${ncpu} update | |
| STORAGE_LIB_PARAMS="--passL:\"-Wl,-install_name,@rpath/libstorage.dylib\"" make -j${ncpu} libstorage | |
| - name: Release - Build libstorage (Windows) | |
| if: matrix.os == 'windows' | |
| shell: msys2 {0} | |
| run: | | |
| make -j${ncpu} update | |
| make -j${ncpu} libstorage | |
| - name: Release - Libraries | |
| run: | | |
| if [[ "${{ matrix.os }}" == "windows" ]]; then | |
| for lib in ${{ env.windows_libs }}; do | |
| cp -v "${MINGW_PREFIX}/bin/${lib}" "${{ env.build_dir }}" | |
| done | |
| fi | |
| - name: Release - Upload Logos Storage build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ env.storage_binary }} | |
| path: ${{ env.build_dir }}/${{ env.storage_binary_base }}* | |
| retention-days: 30 | |
| - name: Release - Upload Windows libs | |
| if: matrix.os == 'windows' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ env.storage_binary }}-dlls | |
| path: ${{ env.build_dir }}/*.dll | |
| retention-days: 30 | |
| - name: Release - Package artifacts Linux | |
| if: matrix.os == 'linux' | |
| run: | | |
| sudo apt-get update && sudo apt-get install -y zip | |
| github_ref_name="${GITHUB_REF_NAME/\//-}" | |
| ZIPFILE=libstorage-linux-${{ matrix.cpu }}-${{ env.VERSION }}.zip | |
| zip -j $ZIPFILE ./build/libstorage.so ./library/libstorage.h | |
| echo "ZIPFILE=$ZIPFILE" >> $GITHUB_ENV | |
| - name: Package artifacts MacOS | |
| if: matrix.os == 'macos' | |
| run: | | |
| github_ref_name="${GITHUB_REF_NAME/\//-}" | |
| ZIPFILE=libstorage-macos-${{ matrix.cpu }}-${{ env.VERSION }}.zip | |
| zip -j $ZIPFILE ./build/libstorage.dylib ./library/libstorage.h | |
| echo "ZIPFILE=$ZIPFILE" >> $GITHUB_ENV | |
| - name: Release - Package artifacts (Windows) | |
| if: matrix.os == 'windows' | |
| shell: msys2 {0} | |
| run: | | |
| ZIPFILE=libstorage-windows-${{ matrix.cpu }}-${{ env.VERSION }}.zip | |
| (cd ./build && 7z a -tzip "${GITHUB_WORKSPACE}/${ZIPFILE}" libstorage.dll) | |
| (cd ./library && 7z a -tzip "${GITHUB_WORKSPACE}/${ZIPFILE}" libstorage.h) | |
| echo "ZIPFILE=$ZIPFILE" >> $GITHUB_ENV | |
| - name: Release - Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ env.ZIPFILE }} | |
| path: ${{ env.ZIPFILE }} | |
| if-no-files-found: error | |
| # Release | |
| release: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| if: success() || failure() | |
| steps: | |
| - name: Set version variable | |
| shell: bash | |
| run: | | |
| if [[ "${{ github.ref_type }}" == "tag" ]]; then | |
| echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV | |
| echo "TAGGED_RELEASE=true" >> $GITHUB_ENV | |
| else | |
| echo "VERSION=${GITHUB_SHA::7}" >> $GITHUB_ENV | |
| echo "TAGGED_RELEASE=false" >> $GITHUB_ENV | |
| fi | |
| - name: Release - Download binaries | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: ${{ env.storage_binary_base }}* | |
| merge-multiple: true | |
| path: /tmp/release | |
| - name: Release - Download artifacts | |
| uses: actions/download-artifact@v5 | |
| with: | |
| pattern: libstorage* | |
| path: /tmp/release | |
| - name: Release - Compress and checksum | |
| run: | | |
| cd /tmp/release | |
| checksum() { | |
| arc="${1}" | |
| sha256sum "${arc}" >"${arc}.sha256" | |
| } | |
| # Compress and prepare | |
| for file in ${{ env.storage_binary_base }}*; do | |
| if [[ "${file}" == *".exe"* ]]; then | |
| # Windows - binary only | |
| arc="${file%.*}.zip" | |
| zip "${arc}" "${file}" | |
| checksum "${arc}" | |
| # Windows - binary and libs | |
| arc="${file%.*}-libs.zip" | |
| zip "${arc}" "${file}" ${{ env.windows_libs }} | |
| rm -f "${file}" | |
| checksum "${arc}" | |
| else | |
| # Linux/macOS | |
| arc="${file}.tar.gz" | |
| chmod 755 "${file}" | |
| tar cfz "${arc}" "${file}" | |
| rm -f "${file}" | |
| checksum "${arc}" | |
| fi | |
| done | |
| rm -f ${{ env.windows_libs }} | |
| - name: Release - Upload compressed artifacts and checksums | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: archives-and-checksums | |
| path: /tmp/release/ | |
| retention-days: 30 | |
| - name: Release - Upload to the cloud | |
| env: | |
| s3_endpoint: ${{ secrets.S3_ENDPOINT }} | |
| s3_bucket: ${{ secrets.S3_BUCKET }} | |
| AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }} | |
| run: | | |
| # Variables | |
| branch="${GITHUB_REF_NAME/\//-}" | |
| folder="/tmp/release" | |
| # Tagged releases | |
| if [[ "${{ env.TAGGED_RELEASE }}" == "true" ]]; then | |
| aws s3 cp --recursive "${folder}" s3://${{ env.s3_bucket }}/releases/${branch} --endpoint-url ${{ env.s3_endpoint }} | |
| echo "${branch}" > "${folder}"/latest | |
| aws s3 cp "${folder}"/latest s3://${{ env.s3_bucket }}/releases/latest --endpoint-url ${{ env.s3_endpoint }} | |
| rm -f "${folder}"/latest | |
| # master branch | |
| elif [[ "${branch}" == "${{ github.event.repository.default_branch }}" ]]; then | |
| aws s3 cp --recursive "${folder}" s3://${{ env.s3_bucket }}/${branch} --endpoint-url ${{ env.s3_endpoint }} | |
| # Custom branch | |
| else | |
| aws s3 cp --recursive "${folder}" s3://${{ env.s3_bucket }}/branches/${branch} --endpoint-url ${{ env.s3_endpoint }} | |
| fi | |
| - name: Release | |
| uses: softprops/action-gh-release@v2 | |
| if: env.TAGGED_RELEASE == 'true' | |
| with: | |
| files: | | |
| /tmp/release/* | |
| make_latest: true | |
| - name: Generate Python SDK | |
| uses: peter-evans/repository-dispatch@v3 | |
| if: env.TAGGED_RELEASE == 'true' | |
| with: | |
| token: ${{ secrets.DISPATCH_PAT }} | |
| repository: logos-storage/logos-storage-py-api-client | |
| event-type: generate | |
| client-payload: '{"openapi_url": "https://raw.githubusercontent.com/logos-storage/logos-storage-nim/${{ github.ref }}/openapi.yaml"}' |