Skip to content

Commit

Permalink
Tatum C# SDK v2 - initial implementation with ETH and BTC (#34)
Browse files Browse the repository at this point in the history
Initial implementation of Tatum C# SDK v2 with support for ETH and BTC blockchains.
  • Loading branch information
Smrecz authored Oct 18, 2022
1 parent 353e874 commit 57b3c90
Show file tree
Hide file tree
Showing 254 changed files with 2,153 additions and 39,296 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/calculateBuildVersion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Calculate Build Version

on:
workflow_call:
outputs:
version:
description: "New build version number"
value: ${{ jobs.calculate_version.outputs.output1 }}

jobs:
calculate_version:
name: Calculate Build Version
runs-on: ubuntu-latest
outputs:
output1: ${{steps.versionStep.outputs.version}}
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
- name: Generate build version
id: versionStep
shell: bash
run: echo "version=2.0.0-alpha${{ github.run_id }}" >> $GITHUB_OUTPUT
42 changes: 42 additions & 0 deletions .github/workflows/deployReleaseCandidatePackage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Deploy RC Package

on:
workflow_call:
inputs:
name:
required: true
type: string
version:
required: true
type: string
dependsOn:
required: true
type: string

env:
PROJECT_PATH: ./Tatum.CSharp.${{ inputs.name }}/Tatum.CSharp.${{ inputs.name }}.csproj
PACKAGE_SOURCE: https://nuget.pkg.github.com/tatumio/index.json

jobs:
preparePackage:
name: Build and Publish package
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
- name: Add package source
run: dotnet nuget add source --username tatumio --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "${{ env.PACKAGE_SOURCE }}"
- name: ${{ inputs.name }} - Bump Dependencies Version
run: dotnet add ${{ env.PROJECT_PATH }} package Tatum.CSharp.${{ inputs.dependsOn }} --prerelease --no-restore
- name: ${{ inputs.name }} - Restore dependencies
run: dotnet restore ${{ env.PROJECT_PATH }}
- name: ${{ inputs.name }} - Build
run: dotnet build ${{ env.PROJECT_PATH }} --no-restore --configuration Release
- name: ${{ inputs.name }} - Pack
run: dotnet pack ${{ env.PROJECT_PATH }} --no-build --no-restore --configuration Release /p:Version=${{ inputs.version }} --output .
- name: ${{ inputs.name }} - Push to Github Packages
run: dotnet nuget push "./Tatum.CSharp.${{ inputs.name }}.${{ inputs.version }}.nupkg" --skip-duplicate --api-key ${{ secrets.ACTIONS_PACKAGE_SOURCE_PAT }} --source "github"
80 changes: 80 additions & 0 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Tatum.CSharp RC Packages
run-name: ${{ inputs.source }}

on:
push:
branches: [ "develop" ]
pull_request:
branches: [ "develop" ]
workflow_dispatch:
inputs:
source:
description: 'Source of event'
required: false
default: ''

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:

Build_Version:
name: Get Version
uses: ./.github/workflows/calculateBuildVersion.yml

EVM_Pack_RC:
name: EVM - Pack Local
uses: ./.github/workflows/deployReleaseCandidatePackage.yml
with:
name: Evm.Local
version: ${{ needs.Build_Version.outputs.version }}
dependsOn: Core
secrets: inherit
needs: Build_Version

ETH_Pack_RC:
name: ETH - Pack
uses: ./.github/workflows/deployReleaseCandidatePackage.yml
with:
name: Ethereum
version: ${{ needs.Build_Version.outputs.version }}
dependsOn: Evm.Local
secrets: inherit
needs: [Build_Version, EVM_Pack_RC]

ETH_Integration_Tests:
name: ETH - Test
uses: ./.github/workflows/integrationTests.yml
with:
name: Ethereum
secrets: inherit
needs: ETH_Pack_RC

BTC_Local_Pack_RC:
name: BTC - Pack Local
uses: ./.github/workflows/deployReleaseCandidatePackage.yml
with:
name: Bitcoin.Local
version: ${{ needs.Build_Version.outputs.version }}
dependsOn: Core
secrets: inherit
needs: Build_Version

BTC_Pack_RC:
name: BTC - Pack
uses: ./.github/workflows/deployReleaseCandidatePackage.yml
with:
name: Bitcoin
version: ${{ needs.Build_Version.outputs.version }}
dependsOn: Bitcoin.Local
secrets: inherit
needs: [Build_Version, BTC_Local_Pack_RC]

BTC_Integration_Tests:
name: BTC - Test
uses: ./.github/workflows/integrationTests.yml
with:
name: Bitcoin
secrets: inherit
needs: BTC_Pack_RC
37 changes: 37 additions & 0 deletions .github/workflows/integrationTests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Run Integration Tests

on:
workflow_call:
inputs:
name:
required: true
type: string

env:
PROJECT_PATH: ./Tatum.CSharp.${{ inputs.name }}.Tests.Integration/Tatum.CSharp.${{ inputs.name }}.Tests.Integration.csproj
PACKAGE_SOURCE: https://nuget.pkg.github.com/tatumio/index.json

jobs:
integration_tests:
name: Run Integration Tests
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
- name: Add package source
run: dotnet nuget add source --username tatumio --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "${{ env.PACKAGE_SOURCE }}"
- name: ${{ inputs.name }} - Bump Version
run: dotnet add ${{ env.PROJECT_PATH }} package Tatum.CSharp.${{ inputs.name }} --prerelease --no-restore
- name: ${{ inputs.name }} Integration Test - Restore dependencies
run: dotnet restore ${{ env.PROJECT_PATH }}
- name: ${{ inputs.name }} Integration Test - Build
run: dotnet build ${{ env.PROJECT_PATH }} --no-restore --configuration Release
- name: ${{ inputs.name }} Integration Test - Run Test
run: dotnet test ${{ env.PROJECT_PATH }} --no-build --verbosity normal --configuration Release
env:
TEST_DATA: ${{ secrets.TEST_DATA }}
INTEGRATION_TEST_APIKEY: ${{ secrets.INTEGRATION_TEST_APIKEY }}
35 changes: 35 additions & 0 deletions .github/workflows/postRelease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Tatum.CSharp Latest Packages
run-name: ${{ inputs.source }}

on:
workflow_dispatch:
inputs:
source:
description: 'Source of event'
required: false
default: ''
version:
description: 'Version to test'
required: true

jobs:

Build_Version:
name: Get Version
uses: ./.github/workflows/calculateBuildVersion.yml

ETH_Integration_Tests:
name: ETH - Test
uses: ./.github/workflows/integrationTests.yml
with:
name: Ethereum
version: ${{ inputs.version }}
secrets: inherit

BTC_Integration_Tests:
name: BTC - Test
uses: ./.github/workflows/integrationTests.yml
with:
name: Bitcoin
version: ${{ inputs.version }}
secrets: inherit
79 changes: 79 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Tatum.CSharp Nuget Release

on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"

env:
DOWNSTREAM_DISPATCH_ADDRESS: https://api.github.com/repos/tatumio/tatum-csharp/actions/workflows/postRelease.yml/dispatches

jobs:

Verify_Origin:
name: Verify commit exists in master
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Verify commit exists in origin/main
run: |
git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/*
git branch --remote --contains | grep origin/main
Release_Version:
name: Get Version from Tag
steps:
- name: Set VERSION variable from tag
run: echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_ENV

EVM_Release:
name: EVM - Release Local
uses: ./.github/workflows/releaseNugetPackage.yml
with:
name: Evm.Local
version: ${VERSION}
dependsOn: Core
secrets: inherit
needs: Release_Version

ETH_Release:
name: ETH - Release
uses: ./.github/workflows/releaseNugetPackage.yml
with:
name: Ethereum
version: ${VERSION}
dependsOn: Evm.Local
secrets: inherit
needs: [Release_Version, EVM_Release]

BTC_Local_Release:
name: BTC - Release Local
uses: ./.github/workflows/releaseNugetPackage.yml
with:
name: Bitcoin.Local
version: ${VERSION}
dependsOn: Core
secrets: inherit
needs: Release_Version

BTC_Release:
name: BTC - Release
uses: ./.github/workflows/releaseNugetPackage.yml
with:
name: Bitcoin
version: ${VERSION}
dependsOn: Bitcoin.Local
secrets: inherit
needs: [Release_Version, BTC_Local_Release]

Post_Release_Tests:
steps:
- name: Trigger Post Release Tests
run: |
curl -X POST \
-H "Authorization: Bearer ${{secrets.DISPATCH_TOKEN}}" \
-H "Accept: application/vnd.github.v3+json" \
'${{ env.DOWNSTREAM_DISPATCH_ADDRESS }}' \
-d '{"ref": "develop", "inputs": {"source": "New Tatum.CSharp version ${VERSION} released", "version": "${VERSION}"}}'
37 changes: 37 additions & 0 deletions .github/workflows/releaseIntegrationTests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Run Release Integration Tests

on:
workflow_call:
inputs:
name:
required: true
type: string
version:
required: true
type: string

env:
PROJECT_PATH: ./Tatum.CSharp.${{ inputs.name }}.Tests.Integration/Tatum.CSharp.${{ inputs.name }}.Tests.Integration.csproj

jobs:
integration_tests:
name: Run Integration Tests
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
- name: ${{ inputs.name }} - Bump Version
run: dotnet add ${{ env.PROJECT_PATH }} package Tatum.CSharp.${{ inputs.name }} --version ${{ inputs.version }} --no-restore
- name: ${{ inputs.name }} Integration Test - Restore dependencies
run: dotnet restore ${{ env.PROJECT_PATH }}
- name: ${{ inputs.name }} Integration Test - Build
run: dotnet build ${{ env.PROJECT_PATH }} --no-restore --configuration Release
- name: ${{ inputs.name }} Integration Test - Run Test
run: dotnet test ${{ env.PROJECT_PATH }} --no-build --verbosity normal --configuration Release
env:
TEST_DATA: ${{ secrets.TEST_DATA }}
INTEGRATION_TEST_APIKEY: ${{ secrets.INTEGRATION_TEST_APIKEY }}
38 changes: 38 additions & 0 deletions .github/workflows/releaseNugetPackage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Release Nuget Package

on:
workflow_call:
inputs:
name:
required: true
type: string
version:
required: true
type: string

env:
PROJECT_PATH: ./Tatum.CSharp.${{ inputs.name }}/Tatum.CSharp.${{ inputs.name }}.csproj
PACKAGE_SOURCE: https://api.nuget.org/v3/index.json

jobs:

preparePackage:
name: Build and Publish package
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
- name: ${{ inputs.name }} - Bump Dependencies Version
run: dotnet add ${{ env.PROJECT_PATH }} package Tatum.CSharp.${{ inputs.dependsOn }} --no-restore
- name: ${{ inputs.name }} - Restore dependencies
run: dotnet restore ${{ env.PROJECT_PATH }}
- name: ${{ inputs.name }} - Build
run: dotnet build ${{ env.PROJECT_PATH }} --no-restore --configuration Release
- name: ${{ inputs.name }} - Pack
run: dotnet pack ${{ env.PROJECT_PATH }} --no-build --no-restore --configuration Release /p:Version=${{ inputs.version }} --output .
- name: ${{ inputs.name }} - Push to Nuget
run: echo "otnet nuget push "./Tatum.CSharp.${{ inputs.name }}.${{ inputs.version }}.nupkg" --skip-duplicate --api-key ${{ secrets.NUGET_PUBLISH_KEY }} --source ${{ env.PACKAGE_SOURCE }}"
Loading

0 comments on commit 57b3c90

Please sign in to comment.