name: Release Workflow on: workflow_dispatch: # inputs: # release_type: # description: "Release type" # type: choice # options: # - development # - production # default: development permissions: {} defaults: run: shell: bash env: DOTNET_VERSION: "10.x" DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true DOTNET_CLI_TELEMETRY_OPTOUT: true DOTNET_NOLOGO: true jobs: # ============================================================================== # Publish Package (manual trigger only) # ============================================================================== Publish_Package: runs-on: ubuntu-latest timeout-minutes: 15 permissions: contents: write steps: - name: Checkout code uses: actions/checkout@v4 with: fetch-depth: 0 - name: Setup .NET SDK uses: actions/setup-dotnet@v4 with: dotnet-version: ${{ env.DOTNET_VERSION }} cache: true cache-dependency-path: | **/packages.lock.json **/*.csproj **/*.sln - name: Install GitVersion uses: gittools/actions/gitversion/setup@v4.2.0 with: versionSpec: "6.x" includePrerelease: true - name: Determine Version id: gitversion uses: gittools/actions/gitversion/execute@v4.2.0 with: updateAssemblyInfo: false - name: Restore dependencies run: dotnet restore - name: Build run: | dotnet build ./lib/quantalib.csproj --configuration Release --no-restore --nologo dotnet build ./quantower/Momentum.csproj --configuration Release --no-restore --nologo dotnet build ./quantower/Trends.csproj --configuration Release --no-restore --nologo dotnet build ./quantower/Volume.csproj --configuration Release --no-restore --nologo - name: Pack NuGet run: | dotnet pack ./lib/quantalib.csproj \ --configuration Release \ --no-build \ -p:ContinuousIntegrationBuild=true \ -p:PackageVersion=${{ steps.gitversion.outputs.SemVer }} ls -lh lib/bin/Release/*.nupkg || true - name: Create Development Release if: inputs.release_type == 'development' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | gh release delete development --yes 2>/dev/null || true git push --delete origin refs/tags/development 2>/dev/null || true gh release create development \ --title "Development Build" \ --notes "Latest development build from commit ${{ github.sha }}" \ --prerelease \ --target ${{ github.sha }} \ lib/bin/Release/*.nupkg \ lib/bin/Release/**/QuanTAlib.dll \ quantower/bin/Release/**/*.dll - name: Push to MyGet if: inputs.release_type == 'development' continue-on-error: true env: MYGET_API_KEY: ${{ secrets.MYGET_DEPLOY_KEY_QUANTALIB }} run: | if [ -z "${MYGET_API_KEY:-}" ]; then echo "MYGET_DEPLOY_KEY_QUANTALIB not set. Skipping." exit 0 fi dotnet nuget push 'lib/bin/Release/*.nupkg' \ --source https://www.myget.org/F/quantalib/api/v3/index.json \ --skip-duplicate \ --api-key "$MYGET_API_KEY" - name: Create GitHub Release if: inputs.release_type == 'production' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | gh release create "v${{ steps.gitversion.outputs.MajorMinorPatch }}" \ --title "Release ${{ steps.gitversion.outputs.MajorMinorPatch }}" \ --generate-notes \ lib/bin/Release/*.nupkg \ quantower/bin/Release/**/*.dll - name: Push to NuGet if: inputs.release_type == 'production' env: NUGET_API_KEY: ${{ secrets.NUGET_DEPLOY_KEY_QUANTLIB }} run: | if [ -z "${NUGET_API_KEY:-}" ]; then echo "NUGET_DEPLOY_KEY_QUANTLIB not set. Failing publish." exit 1 fi dotnet nuget push 'lib/bin/Release/*.nupkg' \ --source https://api.nuget.org/v3/index.json \ --skip-duplicate \ --api-key "$NUGET_API_KEY"