docs: add scenarios README (#405) #328
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: Build Binaries | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - ci | |
| - supervised | |
| - feat/surfpool-studio | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| get_release_info: | |
| name: Get Release Info | |
| runs-on: ubuntu-latest | |
| outputs: | |
| tag: ${{ steps.new_release_tag.outputs.TAG }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Get latest release | |
| if: startsWith(github.ref, 'refs/heads/main') | |
| id: release | |
| uses: pozetroninc/github-action-get-latest-release@master | |
| with: | |
| repository: ${{ github.repository }} | |
| excludes: prerelease, draft | |
| - name: Determine if release build | |
| if: startsWith(github.ref, 'refs/heads/main') | |
| id: new_release_tag | |
| env: | |
| LATEST_RELEASE: ${{ steps.release.outputs.release }} | |
| run: | | |
| CARGO_VERSION=v$(grep "version" Cargo.toml | head -n 1 | cut -d\" -f2) | |
| if [[ "${CARGO_VERSION}" != "${LATEST_RELEASE}" ]]; then | |
| echo "::set-output name=TAG::${CARGO_VERSION}" | |
| echo "::warning::Will create release for version: ${CARGO_VERSION}" | |
| else | |
| echo "::warning::Will not create a release" | |
| fi | |
| dist_surfpool: | |
| name: Build Surfpool Distributions | |
| runs-on: ${{ matrix.os }} | |
| outputs: | |
| LINUX_X64_SHA: ${{ steps.linux_x64_sha.outputs.LINUX_X64_SHA }} | |
| MACOS_X64_SHA: ${{ steps.macos_x64_sha.outputs.MACOS_X64_SHA }} | |
| MACOS_ARM64_SHA: ${{ steps.macos_arm64_sha.outputs.MACOS_ARM64_SHA }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-22.04 | |
| platform: linux | |
| target: x86_64-unknown-linux-gnu | |
| architecture: x64 | |
| - os: windows-latest | |
| platform: windows | |
| target: x86_64-pc-windows-msvc | |
| architecture: x64 | |
| - os: macos-latest | |
| platform: darwin | |
| target: x86_64-apple-darwin | |
| architecture: x64 | |
| - os: macos-latest | |
| platform: darwin | |
| target: aarch64-apple-darwin | |
| architecture: arm64 | |
| steps: | |
| # pre-build for windows | |
| - name: Configure git to use LF (Windows) | |
| if: matrix.os == 'windows-latest' | |
| run: | | |
| git config --global core.autocrlf false | |
| git config --global core.eol lf | |
| # pre-build for all OS | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| # set up rust for all envs | |
| - name: Install Rust toolchain | |
| run: rustup toolchain install 1.86.0 --profile minimal --target ${{ matrix.target }} | |
| - name: Install Rust Target | |
| run: rustup target add ${{ matrix.target }} | |
| # env vars unix | |
| - name: Get Rust version (unix) | |
| if: matrix.os != 'windows-latest' | |
| run: echo "RUST_VERSION_HASH=$(rustc --version | shasum -a 256 | awk '{print $1}')" >> $GITHUB_ENV | |
| # env vars windows | |
| - name: "Get Rust version (windows)" | |
| if: matrix.os == 'windows-latest' | |
| shell: bash | |
| run: echo "RUST_VERSION_HASH=$(rustc --version | sha256sum | awk '{print $1}')" >> $GITHUB_ENV | |
| - name: Cache cargo | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ~/.cargo/ | |
| ./target/${{ matrix.target }}/release/ | |
| key: ${{ runner.os }}-rust-${{ env.RUST_VERSION_HASH }}-cargo-${{ hashFiles('./Cargo.lock') }} | |
| # Set environment variables required from cross compiling from macos-x86_64 to macos-arm64 | |
| - name: Configure macos-arm64 cross compile config | |
| if: matrix.target == 'aarch64-apple-darwin' | |
| run: | | |
| echo "SDKROOT=$(xcrun -sdk macosx --show-sdk-path)" >> $GITHUB_ENV | |
| echo "MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx --show-sdk-platform-version)" >> $GITHUB_ENV | |
| - name: Configure openssl (macos x64) | |
| if: matrix.os == 'macos-latest' && matrix.architecture == 'x64' | |
| run: | | |
| brew install [email protected] | |
| echo "OPENSSL_DIR=$(brew --prefix [email protected])" >> $GITHUB_ENV | |
| echo "OPENSSL_INCLUDE_DIR=$(brew --prefix [email protected])/include" >> $GITHUB_ENV | |
| echo "OPENSSL_LIB_DIR=$(brew --prefix [email protected])/lib" >> $GITHUB_ENV | |
| - name: Configure openssl (macos arm64) | |
| if: matrix.os == 'macos-latest' && matrix.architecture == 'arm64' | |
| run: | | |
| brew install [email protected] | |
| echo "OPENSSL_DIR=$(brew --prefix [email protected])" >> $GITHUB_ENV | |
| echo "OPENSSL_INCLUDE_DIR=$(brew --prefix [email protected])/include" >> $GITHUB_ENV | |
| echo "OPENSSL_LIB_DIR=$(brew --prefix [email protected])/lib" >> $GITHUB_ENV | |
| - name: Install LLVM (macOS) | |
| if: matrix.os == 'macos-latest' | |
| run: | | |
| brew install llvm | |
| echo "LIBCLANG_PATH=$(brew --prefix llvm)/lib" >> $GITHUB_ENV | |
| echo "BINDGEN_EXTRA_CLANG_ARGS=-I$(xcrun --show-sdk-path)/usr/include" >> $GITHUB_ENV | |
| echo "LLVM_CONFIG_PATH=$(brew --prefix llvm)/bin/llvm-config" >> $GITHUB_ENV | |
| - name: Install LLVM/Clang (Linux) | |
| if: matrix.os == 'ubuntu-22.04' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y clang llvm-dev libclang-dev pkg-config | |
| echo "LIBCLANG_PATH=/usr/lib/llvm-14/lib" >> $GITHUB_ENV | |
| # - name: Download OpenSSL (windows) | |
| # if: matrix.os == 'windows-latest' | |
| # run: | | |
| # Invoke-WebRequest -Uri https://slproweb.com/download/Win64OpenSSL-3_0_16.exe -OutFile openssl-installer.exe | |
| # Start-Process -Wait -FilePath .\openssl-installer.exe -ArgumentList "/silent", "/verysilent", "/dir=C:\OpenSSL" | |
| # - name: Set Env Vars for OpenSSL (windows) | |
| # if: matrix.os == 'windows-latest' | |
| # run: | | |
| # echo "OPENSSL_DIR=C:\OpenSSL" >> $env:GITHUB_ENV | |
| # echo "OPENSSL_LIB_DIR=C:\OpenSSL\lib\VC" >> $env:GITHUB_ENV | |
| # echo "OPENSSL_NO_VENDOR=1" >> $env:GITHUB_ENV | |
| - name: Cache vcpkg (windows) | |
| if: matrix.os == 'windows-latest' | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| C:\vcpkg | |
| key: ${{ runner.os }}-vcpkg-openssl | |
| - name: Setup vcpkg and install OpenSSL (windows) | |
| if: matrix.os == 'windows-latest' | |
| run: | | |
| git clone https://github.com/microsoft/vcpkg C:\vcpkg | |
| cd C:\vcpkg | |
| .\bootstrap-vcpkg.bat | |
| .\vcpkg install openssl:x64-windows | |
| echo "OPENSSL_DIR=C:\vcpkg\installed\x64-windows" >> $env:GITHUB_ENV | |
| echo "OPENSSL_NO_VENDOR=1" >> $env:GITHUB_ENV | |
| - name: Configure artifact names | |
| shell: bash | |
| run: | | |
| echo "SHORT_TARGET_NAME=${{ matrix.platform }}-${{ matrix.architecture }}" >> $GITHUB_ENV | |
| echo "PRE_GYP_TARGET_NAME=${{ matrix.platform }}-${{ matrix.architecture }}-unknown" >> $GITHUB_ENV | |
| - name: Install dependencies | |
| if: matrix.os == 'ubuntu-22.04' | |
| run: sudo apt-get update && sudo apt-get install -y libudev-dev | |
| - name: Build - Cargo (Windows) | |
| if: matrix.os == 'windows-latest' | |
| run: | |
| cargo build --release --locked --target ${{ matrix.target }} --features supervisor_ui --features version_check --features subgraph | |
| - name: Build - Cargo (macOS x64) | |
| if: matrix.os == 'macos-latest' && matrix.architecture == 'x64' | |
| run: | |
| cargo build --release --locked --target ${{ matrix.target }} --features supervisor_ui --features version_check --features subgraph | |
| - name: Build - Cargo (macOS ARM64) | |
| if: matrix.os == 'macos-latest' && matrix.architecture == 'arm64' | |
| run: | |
| cargo build --release --locked --target ${{ matrix.target }} --features supervisor_ui --features version_check --features subgraph | |
| - name: Build - Cargo (Linux) | |
| if: matrix.os == 'ubuntu-22.04' | |
| run: | |
| cargo build --release --locked --target ${{ matrix.target }} --features supervisor_ui --features version_check --features subgraph --features geyser_plugin | |
| # Don't compress for Windows because winget can't yet unzip files | |
| - name: Compress cargo artifact (not windows) | |
| if: matrix.os != 'windows-latest' | |
| run: tar -C target/${{ matrix.target }}/release -zcvf surfpool-${{ env.SHORT_TARGET_NAME }}.tar.gz surfpool | |
| - name: Compress artifact (Windows) | |
| if: matrix.os == 'windows-latest' | |
| shell: bash | |
| run: | |
| tar -czf surfpool-${{ env.SHORT_TARGET_NAME }}.tar.gz -C target/${{ matrix.target }}/release surfpool.exe | |
| - name: Store SHA256 Hash of Tar (Linux x64) | |
| if: matrix.platform == 'linux' | |
| id: linux_x64_sha | |
| run: | | |
| echo "LINUX_X64_SHA=$(sha256sum surfpool-${{ env.SHORT_TARGET_NAME }}.tar.gz | awk '{ print $1 }')" >> "$GITHUB_OUTPUT" | |
| - name: Store SHA256 Hash of Tar (Mac x64) | |
| if: matrix.os == 'macos-latest' && matrix.architecture == 'x64' | |
| id: macos_x64_sha | |
| run: | | |
| echo "MACOS_X64_SHA=$(shasum -a 256 surfpool-${{ env.SHORT_TARGET_NAME }}.tar.gz | awk '{ print $1 }')" >> "$GITHUB_OUTPUT" | |
| - name: Store SHA256 Hash of Tar (Mac arm64) | |
| if: matrix.os == 'macos-latest' && matrix.architecture == 'arm64' | |
| id: macos_arm64_sha | |
| run: | | |
| echo "MACOS_ARM64_SHA=$(shasum -a 256 surfpool-${{ env.SHORT_TARGET_NAME }}.tar.gz | awk '{ print $1 }')" >> "$GITHUB_OUTPUT" | |
| # Separate uploads to prevent paths from being preserved | |
| - name: Upload cargo artifacts (not windows) | |
| if: matrix.os != 'windows-latest' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: surfpool-${{ env.SHORT_TARGET_NAME }} | |
| path: surfpool-${{ env.SHORT_TARGET_NAME }}.tar.gz | |
| - name: Upload tar archive (Windows) | |
| if: matrix.os == 'windows-latest' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: surfpool-${{ env.SHORT_TARGET_NAME }} | |
| path: surfpool-${{ env.SHORT_TARGET_NAME }}.tar.gz | |
| release: | |
| name: Release | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/heads/main') && needs.get_release_info.outputs.tag != '' | |
| needs: | |
| - dist_surfpool | |
| - get_release_info | |
| permissions: | |
| actions: write | |
| contents: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Download pre-built dists | |
| uses: actions/download-artifact@v4 | |
| - name: Tag and Release | |
| uses: ncipollo/release-action@v1 | |
| with: | |
| artifacts: "**/*.tar.gz,**/*.msi" | |
| tag: ${{ needs.get_release_info.outputs.tag }} | |
| commit: ${{ env.GITHUB_SHA }} | |
| - name: Pack artifacts | |
| run: | | |
| tar -czvf surfpool-linux-x64.tar.gz surfpool-linux-x64 | |
| tar -czvf surfpool-darwin-arm64.tar.gz surfpool-darwin-arm64 | |
| homebrew: | |
| name: Update Homebrew | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/heads/main') && needs.get_release_info.outputs.tag != '' | |
| needs: | |
| - dist_surfpool | |
| - get_release_info | |
| - release | |
| permissions: | |
| actions: write | |
| contents: write | |
| steps: | |
| - name: Checkout the repository | |
| uses: actions/checkout@v2 | |
| - name: Set up Git | |
| run: | | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Clone the tap repository | |
| run: | | |
| git clone https://github.com/txtx/homebrew-taps.git | |
| cd homebrew-taps | |
| - name: Update the formula with new version and SHA256 values | |
| run: | | |
| pwd | |
| ls | |
| cd homebrew-taps | |
| pwd | |
| ls | |
| # Define the new version | |
| NEW_VERSION="${{ needs.get_release_info.outputs.tag }}" | |
| # Update the version in all url fields, matching on any valid semver version | |
| sed -i.bak "s/v[0-9]\+\.[0-9]\+\.[0-9]\+\(-[a-zA-Z0-9\.-]\+\)\?\(\+[a-zA-Z0-9\.-]\+\)\?/$(echo $NEW_VERSION)/g" Formula/surfpool.rb | |
| # Update macOS x64 SHA256 | |
| sed -i.bak '/# sha for macos_x64/!b;n;c\ sha256 "'${{ needs.dist_surfpool.outputs.MACOS_X64_SHA }}'"' Formula/surfpool.rb | |
| # Update macOS arm64 SHA256 | |
| sed -i.bak '/# sha for macos_arm64/!b;n;c\ sha256 "'${{ needs.dist_surfpool.outputs.MACOS_ARM64_SHA }}'"' Formula/surfpool.rb | |
| # Update Linux x64 SHA256 | |
| sed -i.bak '/# sha for linux_x64/!b;n;c\ sha256 "'${{ needs.dist_surfpool.outputs.LINUX_X64_SHA }}'"' Formula/surfpool.rb | |
| # Uncomment and update Linux ARM SHA256 when needed | |
| # sed -i.bak '/# sha for linux_arm64/!b;n;c\ sha256 "'$SHA256_LINUX_ARM'"' Formula/surfpool.rb | |
| # Remove backup file | |
| rm Formula/surfpool.rb.bak | |
| - name: Commit and push changes | |
| run: | | |
| pwd | |
| ls | |
| cd homebrew-taps | |
| pwd | |
| ls | |
| git add Formula/surfpool.rb | |
| git commit -m "Update to version ${{ needs.get_release_info.outputs.tag }}" | |
| git push https://txtx:${{ secrets.TXTX_ACCESS_TOKEN }}@github.com/txtx/homebrew-taps.git | |
| snapcraft: | |
| name: Update Snapcraft | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/heads/main') && needs.get_release_info.outputs.tag != '' | |
| needs: | |
| - dist_surfpool | |
| - get_release_info | |
| - release | |
| permissions: | |
| actions: write | |
| contents: write | |
| steps: | |
| - name: Checkout the repository | |
| uses: actions/checkout@v2 | |
| - name: Set up Git | |
| run: | | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Clone the tap repository | |
| run: | | |
| git clone https://github.com/txtx/snapcraft-surfpool.git | |
| cd snapcraft-surfpool | |
| - name: Update snapcraft.yaml | |
| run: | | |
| cd snapcraft-surfpool | |
| NEW_VERSION="${{ needs.get_release_info.outputs.tag }}" | |
| SOURCE_URL="https://github.com/txtx/surfpool/releases/download/${NEW_VERSION}/surfpool-linux-x64.tar.gz" | |
| # Update the version and source URL in the snapcraft.yaml file | |
| sed -i "s/^version:.*/version: '${NEW_VERSION}'/" snapcraft.yaml | |
| sed -i "s|^ source: .*| source: ${SOURCE_URL}|" snapcraft.yaml | |
| - name: Commit and push changes | |
| run: | | |
| cd snapcraft-surfpool | |
| git add snapcraft.yaml | |
| git commit -m "Update to version ${{ needs.get_release_info.outputs.tag }}" | |
| git push https://txtx:${{ secrets.TXTX_ACCESS_TOKEN }}@github.com/txtx/snapcraft-surfpool.git |