From 1910f3b24a727fb68443db6f00f3bda37534d256 Mon Sep 17 00:00:00 2001 From: Christopher Schuchardt Date: Sat, 15 Jun 2024 05:31:32 -0400 Subject: [PATCH] Added macos leveldb --- .github/workflows/release.yml | 122 +++++++++++++++++++++++++--------- 1 file changed, 90 insertions(+), 32 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2ff816f697..5e507c0225 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,9 +1,11 @@ name: Release (neo-cli) +# Trigger the workflow on a release event when a new release is published on: release: types: [published] +# Define environment variables env: DOTNET_VERSION: 8.0.x CONFIGURATION: Release @@ -13,21 +15,24 @@ env: jobs: build-leveldb: name: Build leveldb (windows-latest) - runs-on: windows-latest + runs-on: ${{ matrix.os }} strategy: matrix: + os: [macos-latest, windows-latest] arch: [x64, arm64] steps: + # Step to lookup cache for the LevelDB build distribution - name: Lookup Cache Distribution id: cache-leveldb uses: actions/cache@v4 with: path: ./leveldb/build/Release/* - key: leveldb-windows-${{ matrix.arch }} + key: leveldb-${{ matrix.os }}-${{ matrix.arch }} enableCrossOsArchive: true lookup-only: true + # Conditionally checkout LevelDB repository if cache is not found - if: ${{ steps.cache-leveldb.outputs.cache-hit != 'true' }} name: Checkout Repository Code (leveldb) uses: actions/checkout@v4 @@ -37,31 +42,36 @@ jobs: submodules: true fetch-depth: 0 - - if: ${{ steps.cache-leveldb.outputs.cache-hit != 'true' }} + # Conditionally setup MSBuild if cache is not found + - if: ${{ matrix.os == 'windows-latest' && steps.cache-leveldb.outputs.cache-hit != 'true' }} name: Setup MSBuild uses: microsoft/setup-msbuild@v2 + # Conditionally setup LevelDB build directory if cache is not found - if: ${{ steps.cache-leveldb.outputs.cache-hit != 'true' }} name: Setup LevelDb working-directory: ./leveldb run: mkdir -p ./build/Release + # Conditionally create build files for LevelDB if cache is not found - if: ${{ steps.cache-leveldb.outputs.cache-hit != 'true' }} name: Create Build Files (win-${{ matrix.arch }}) working-directory: ./leveldb/build run: cmake -DBUILD_SHARED_LIBS=ON -A ${{ matrix.arch }} .. - - if: ${{ steps.cache-leveldb.outputs.cache-hit != 'true' }} + # Conditionally build LevelDB using MSBuild if cache is not found + - if: ${{ matrix.os == 'windows-latest' && steps.cache-leveldb.outputs.cache-hit != 'true' }} name: Build (MSBuild) working-directory: ./leveldb/build run: msbuild ./leveldb.sln /p:Configuration=Release + # Conditionally cache the LevelDB distribution if it was built - if: ${{ steps.cache-leveldb.outputs.cache-hit != 'true' }} name: Cache Distribution uses: actions/cache/save@v4 with: path: ./leveldb/build/Release/* - key: leveldb-windows-${{ matrix.arch }} + key: leveldb-${{ matrix.os }}-${{ matrix.arch }} enableCrossOsArchive: true build-neo-cli: @@ -73,52 +83,58 @@ jobs: runtime: [linux-x64, linux-arm64, win-x64, win-arm64, osx-x64, osx-arm64] steps: + # Step to set the application version from the release tag - name: Set Application Version (Environment Variable) run: | APP_VERSION=$(echo '${{ github.event.release.tag_name }}' | cut -d 'v' -f 2) echo "APP_VERSION=$APP_VERSION" >> $GITHUB_ENV + # Checkout the neo-cli repository code - name: Checkout Repository Code uses: actions/checkout@v4 with: fetch-depth: 0 + # Setup .NET environment - name: Setup .NET uses: actions/setup-dotnet@v4 with: dotnet-version: ${{ env.DOTNET_VERSION }} + # Publish the neo-cli project - name: .NET Publish (neo-cli) run: | dotnet publish ./src/Neo.CLI \ - --version-suffix ${{ matrix.runtime }} \ - --framework net8.0 \ - --configuration ${{ env.CONFIGURATION }} \ - --runtime ${{ matrix.runtime }} \ - --self-contained true \ - --output ${{ env.OUTPUT_PATH }}/${{ matrix.runtime }} \ - --verbosity normal \ - -p:VersionPrefix=${{ env.APP_VERSION }} \ - -p:RuntimeIdentifier=${{ matrix.runtime }} \ - -p:SelfContained=true \ - -p:IncludeNativeLibrariesForSelfExtract=false \ - -p:PublishTrimmed=false \ - -p:PublishSingleFile=true \ - -p:PublishReadyToRun=true \ - -p:EnableCompressionInSingleFile=true \ - -p:DebugType=embedded \ - -p:ServerGarbageCollection=true - + --version-suffix ${{ matrix.runtime }} \ # Append runtime identifier to version + --framework net8.0 \ # Target .NET 8.0 framework + --configuration ${{ env.CONFIGURATION }} \ # Use Release configuration + --runtime ${{ matrix.runtime }} \ # Specify runtime identifier (e.g., win-x64, linux-arm64) + --self-contained true \ # Include the .NET runtime with the application + --output ${{ env.OUTPUT_PATH }}/${{ matrix.runtime }} \ # Output path for the published application + --verbosity normal \ # Normal verbosity level + -p:VersionPrefix=${{ env.APP_VERSION }} \ # Set the version prefix to the application version + -p:RuntimeIdentifier=${{ matrix.runtime }} \ # Set the runtime identifier property + -p:SelfContained=true \ # Ensure the application is self-contained + -p:IncludeNativeLibrariesForSelfExtract=false \ # Do not include native libraries for self-extraction + -p:PublishTrimmed=false \ # Do not trim unused code + -p:PublishSingleFile=true \ # Publish as a single file + -p:PublishReadyToRun=true \ # Enable ReadyToRun compilation + -p:EnableCompressionInSingleFile=true \ # Enable compression in the single file + -p:DebugType=embedded \ # Embed debug information + -p:ServerGarbageCollection=true # Enable server garbage collection + + # Build the LevelDBStore plugin - name: .NET Build (LevelDBStore) run: | dotnet build ./src/Plugins/LevelDBStore \ - --version-suffix ${{ matrix.runtime }} \ - --framework net8.0 \ - --configuration ${{ env.CONFIGURATION }} \ - --output ${{ env.OUTPUT_PATH }}/${{ matrix.runtime }}/Plugins/LevelDBStore \ - --verbosity normal \ - -p:VersionPrefix=${{ env.APP_VERSION }} - + --version-suffix ${{ matrix.runtime }} \ # Append runtime identifier to version + --framework net8.0 \ # Target .NET 8.0 framework + --configuration ${{ env.CONFIGURATION }} \ # Use Release configuration + --output ${{ env.OUTPUT_PATH }}/${{ matrix.runtime }}/Plugins/LevelDBStore \ # Output path for the built plugin + --verbosity normal \ # Normal verbosity level + -p:VersionPrefix=${{ env.APP_VERSION }} # Set the version prefix to the application version + + # Remove unnecessary files from the LevelDBStore plugin output - name: Remove files (junk) working-directory: ${{ env.OUTPUT_PATH }}/${{ matrix.runtime }}/Plugins/LevelDBStore run: | @@ -126,50 +142,84 @@ jobs: rm -v *.pdb rm -v *.xml + # Remove XML comment files from the neo-cli output - name: Remove Xml Comment Files working-directory: ${{ env.OUTPUT_PATH }}/${{ matrix.runtime }} run: rm -v *.xml + # Get cached LevelDB distribution for Windows x64 if applicable - if: ${{ startsWith(matrix.runtime, 'win-x64') }} name: Get Distribution Caches (win-x64) uses: actions/cache@v4 with: path: ./leveldb/build/Release/* - key: leveldb-windows-x64 + key: leveldb-windows-latest-x64 enableCrossOsArchive: true fail-on-cache-miss: true + # Get cached LevelDB distribution for Windows arm64 if applicable - if: ${{ startsWith(matrix.runtime, 'win-arm64') }} name: Get Distribution Caches (win-arm64) uses: actions/cache@v4 with: path: ./leveldb/build/Release/* - key: leveldb-windows-arm64 + key: leveldb-windows-latest-arm64 + enableCrossOsArchive: true + fail-on-cache-miss: true + + # Get cached LevelDB distribution for OSX x64 if applicable + - if: ${{ startsWith(matrix.runtime, 'osx-x64') }} + name: Get Distribution Caches (win-arm64) + uses: actions/cache@v4 + with: + path: ./leveldb/build/Release/* + key: leveldb-macos-latest-x64 + enableCrossOsArchive: true + fail-on-cache-miss: true + + # Get cached LevelDB distribution for OSX arm64 if applicable + - if: ${{ startsWith(matrix.runtime, 'osx-arm64') }} + name: Get Distribution Caches (win-arm64) + uses: actions/cache@v4 + with: + path: ./leveldb/build/Release/* + key: leveldb-macos-latest-arm64 enableCrossOsArchive: true fail-on-cache-miss: true + # Copy LevelDB files to the output directory for Windows - if: ${{ startsWith(matrix.runtime, 'win') }} name: Copy Files (leveldb) (win) run: cp -v ./leveldb/build/Release/leveldb.dll ${{ env.OUTPUT_PATH }}/${{ matrix.runtime }}/libleveldb.dll + # Copy LevelDB files to the output directory for MacOS + - if: ${{ startsWith(matrix.runtime, 'osx') }} + name: Copy Files (leveldb) (win) + run: cp -v ./leveldb/build/Release/leveldb.dylib ${{ env.OUTPUT_PATH }}/${{ matrix.runtime }}/libleveldb.dylib + + # Create the distribution directory - name: Create Distribution Directory run: mkdir -p ${{ env.DIST_PATH }} + # Create a tarball file for Linux distributions - name: Create Tarball File (linux) if: ${{ startsWith(matrix.runtime, 'linux') }} working-directory: ${{ env.OUTPUT_PATH }}/${{ matrix.runtime }} run: tar -czvf ${{ env.DIST_PATH }}/neo-cli.v${{ env.APP_VERSION }}-${{ matrix.runtime }}.tar.gz . + # Create a tarball file for macOS distributions - name: Create Tarball File (osx) if: ${{ startsWith(matrix.runtime, 'osx') }} working-directory: ${{ env.OUTPUT_PATH }}/${{ matrix.runtime }} run: tar -cJf ${{ env.DIST_PATH }}/neo-cli.v${{ env.APP_VERSION }}-${{ matrix.runtime }}.tar.xz . + # Create a zip file for Windows distributions - name: Create Zip File (win) if: ${{ startsWith(matrix.runtime, 'win') }} working-directory: ${{ env.OUTPUT_PATH }}/${{ matrix.runtime }} run: zip ${{ env.DIST_PATH }}/neo-cli.v${{ env.APP_VERSION }}-${{ matrix.runtime }}.zip -r * + # Create checksum files for Linux distributions - name: Create Checksum Files (linux) if: ${{ startsWith(matrix.runtime, 'linux') }} working-directory: ${{ env.DIST_PATH }} @@ -178,6 +228,7 @@ jobs: run: | sha256sum ${{ env.FILENAME }}.tar.gz > ${{ env.FILENAME }}.sha256 + # Create checksum files for macOS distributions - name: Create Checksum Files (osx) if: ${{ startsWith(matrix.runtime, 'osx') }} working-directory: ${{ env.DIST_PATH }} @@ -186,6 +237,7 @@ jobs: run: | sha256sum ${{ env.FILENAME }}.tar.xz > ${{ env.FILENAME }}.sha256 + # Create checksum files for Windows distributions - name: Create Checksum Files (win) if: ${{ startsWith(matrix.runtime, 'win') }} working-directory: ${{ env.DIST_PATH }} @@ -194,11 +246,13 @@ jobs: run: | sha256sum ${{ env.FILENAME }}.zip > ${{ env.FILENAME }}.sha256 + # List the contents of the distribution and output directories - name: Output/Distribution Directory Contents run: | ls -la ${{ env.DIST_PATH }} ls -la ${{ env.OUTPUT_PATH }}/${{ matrix.runtime }} + # Upload tarball files for Linux distributions - name: Upload Tarball File (linux) if: ${{ startsWith(matrix.runtime, 'linux') }} uses: actions/upload-release-asset@latest @@ -210,6 +264,7 @@ jobs: asset_name: neo-cli.v${{ env.APP_VERSION }}-${{ matrix.runtime }}.tar.gz asset_content_type: application/x-gtar + # Upload tarball files for macOS distributions - name: Upload Tarball File (osx) if: ${{ startsWith(matrix.runtime, 'osx') }} uses: actions/upload-release-asset@latest @@ -221,6 +276,7 @@ jobs: asset_name: neo-cli.v${{ env.APP_VERSION }}-${{ matrix.runtime }}.tar.xz asset_content_type: application/x-gtar + # Upload zip files for Windows distributions - name: Upload Zip File (win) if: ${{ startsWith(matrix.runtime, 'win') }} uses: actions/upload-release-asset@latest @@ -232,6 +288,7 @@ jobs: asset_name: neo-cli.v${{ env.APP_VERSION }}-${{ matrix.runtime }}.zip asset_content_type: application/zip + # Upload checksum files for all distributions - name: Upload Checksum File (all) uses: actions/upload-release-asset@latest env: @@ -246,6 +303,7 @@ jobs: needs: [build-neo-cli] runs-on: ubuntu-latest steps: + # Cleanup step to delete old caches - name: Cleanup run: | gh extension install actions/gh-actions-cache