name: Publish on: [push, pull_request] jobs: lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Install python requirements run: pip install beautifulsoup4 requests # Can be found on: https://github.com/terminusdb-labs/swipl-lint/ - name: Download script run: curl -L 'https://raw.githubusercontent.com/terminusdb-labs/swipl-lint/v0.1/lint_modules.py' > lint_modules.py - name: Run linter run: python3 lint_modules.py docker: runs-on: ubuntu-latest env: IMAGE_NAME: terminusdb/terminus_store_prolog RUST_BACKTRACE: 1 steps: - uses: actions/checkout@v2 - name: Build image run: docker build -t terminusdb/terminus_store_prolog:latest . - name: Run tests run: docker run -e RUST_BACKTRACE=$RUST_BACKTRACE --rm terminusdb/terminus_store_prolog:latest bash -c "./script/test" - name: Log into Docker Container Registry if: github.event_name != 'pull_request' && (contains(github.ref, 'tag') || contains(github.ref, 'main')) run: echo '${{ secrets.DOCKER_PASS }}' | docker login -u terminusdb --password-stdin - name: Push to the Docker registry if: github.event_name != 'pull_request' && (contains(github.ref, 'tag') || contains(github.ref, 'main')) run: | IMAGE_ID=$IMAGE_NAME # Change all uppercase to lowercase IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') # Strip git ref prefix from version VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') # Use Docker `latest` tag convention [ "$VERSION" == "main" ] && VERSION=latest echo IMAGE_ID=$IMAGE_ID echo VERSION=$VERSION docker tag $IMAGE_NAME $IMAGE_ID:$VERSION docker push $IMAGE_ID:$VERSION windows: runs-on: windows-latest steps: - uses: actions/checkout@v2 - name: Install Rust uses: actions-rs/toolchain@v1 with: profile: minimal toolchain: stable - name: Cache Rust build files uses: Swatinem/rust-cache@v1 with: working-directory: ./rust - name: Install LLVM and SWI Prolog run: | # Install the latest stable LLVM and SWI Prolog using Chocolatey. choco install llvm swi-prolog --no-progress # Abort early since it doesn't seem that failure causes an exit here. if ($lastExitCode -ne 0) { throw "choco install failed: $lastExitCode" } # Update the $PATH to include the new packages. See # Import-Module "$env:ProgramData\chocolatey\helpers\chocolateyInstaller.psm1" Update-SessionEnvironment # Display versions for debugging swipl --version clang --version # The following commands update GitHub files to make the environment # variables persistent across steps. See # # Append the `swipl` path to the $PATH. echo (Split-Path -Path (Get-Command swipl).Source) ` | Out-File -Encoding utf8 -Append -FilePath $env:GITHUB_PATH # Set $LIBCLANG_PATH with the `clang` path. echo "LIBCLANG_PATH=$(Split-Path -Path (Get-Command clang).Source)" ` | Out-File -Encoding utf8 -Append -FilePath $env:GITHUB_ENV - name: Build # Use Git Bash because the Makefile does not work in other shells. shell: bash run: make - name: Test shell: bash run: ./script/test - name: Upload Windows artifact DLL uses: actions/upload-artifact@v1 with: name: libterminus_store.dll path: lib/x64-win64/libterminus_store.dll mac: runs-on: macos-latest steps: - uses: actions/checkout@v2 - name: Install Rust uses: actions-rs/toolchain@v1 with: profile: minimal toolchain: stable - name: Cache Rust build files uses: Swatinem/rust-cache@v1 with: working-directory: ./rust - name: Install SWI Prolog run: | brew install swi-prolog # Display version for debugging swipl --version - name: Build run: make - name: Test run: ./script/test - name: Upload macOS artifact dylib uses: actions/upload-artifact@v1 with: name: libterminus_store.dylib path: lib/x86_64-darwin/libterminus_store.dylib pack: runs-on: ubuntu-latest if: github.event_name != 'pull_request' && contains(github.ref, 'tag') steps: - name: Install SWI Prolog run: | sudo apt-add-repository ppa:swi-prolog/stable sudo apt update sudo apt install swi-prolog-nox - name: Install Rust uses: actions-rs/toolchain@v1 with: profile: minimal toolchain: stable - name: Install pack run: | VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') swipl -g "pack_install('https://github.com/terminusdb/terminus_store_prolog/archive/$VERSION.zip', [interactive(false)])" -g halt deploy: runs-on: ubuntu-latest if: github.event_name != 'pull_request' && contains(github.ref, 'tag') needs: [docker, windows, mac, pack] steps: - name: Set release name id: release_name run: | TAG=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') echo "::set-output name=tag::$TAG" - uses: actions/download-artifact@v2 - name: Create a Release id: create_release uses: softprops/action-gh-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tag_name: ${{ steps.release_name.outputs.tag }} files: | libterminus_store.dylib/libterminus_store.dylib libterminus_store.dll/libterminus_store.dll