mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-07-27 17:27:43 +00:00
148 lines
4.6 KiB
YAML
148 lines
4.6 KiB
YAML
name: Release Workflow
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
|
|
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: Resolve version
|
|
id: version
|
|
run: |
|
|
VERSION="$(tr -d '[:space:]' < lib/VERSION)"
|
|
if [ -z "$VERSION" ]; then
|
|
echo "lib/VERSION is empty"
|
|
exit 1
|
|
fi
|
|
echo "value=$VERSION" >> "$GITHUB_OUTPUT"
|
|
echo "Using version: $VERSION"
|
|
|
|
- name: Restore dependencies
|
|
run: dotnet restore
|
|
|
|
- name: Build (warnings as errors)
|
|
run: dotnet build ./QuanTAlib.slnx --configuration Release --no-restore --nologo /warnaserror
|
|
|
|
- name: Test (core)
|
|
run: dotnet test ./lib/QuanTAlib.Tests.csproj --configuration Release --no-build --nologo
|
|
|
|
- name: Test (quantower)
|
|
run: dotnet test ./quantower/Quantower.Tests.csproj --configuration Release --no-build --nologo
|
|
|
|
- name: Pack NuGet
|
|
run: |
|
|
dotnet pack ./lib/quantalib.csproj \
|
|
--configuration Release \
|
|
--no-build \
|
|
-p:ContinuousIntegrationBuild=true \
|
|
-p:PackageVersion=${{ steps.version.outputs.value }}
|
|
|
|
ls -lh lib/bin/Release/*.nupkg || true
|
|
|
|
- name: Detect release type
|
|
id: release_type
|
|
run: |
|
|
BRANCH="${GITHUB_REF_NAME}"
|
|
|
|
echo "Branch: $BRANCH"
|
|
|
|
if [ "$BRANCH" = "main" ]; then
|
|
echo "type=production" >> $GITHUB_OUTPUT
|
|
echo "Detected: PRODUCTION release (main branch)"
|
|
else
|
|
echo "type=development" >> $GITHUB_OUTPUT
|
|
echo "Detected: DEVELOPMENT release (branch=$BRANCH)"
|
|
fi
|
|
|
|
- name: Create Development Release
|
|
if: steps.release_type.outputs.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 \
|
|
quantower/bin/Release/*.dll
|
|
|
|
- name: Push to MyGet
|
|
if: steps.release_type.outputs.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 Production Release
|
|
if: steps.release_type.outputs.type == 'production'
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
gh release create "v${{ steps.version.outputs.value }}" \
|
|
--title "Release ${{ steps.version.outputs.value }}" \
|
|
--generate-notes \
|
|
lib/bin/Release/*.nupkg \
|
|
quantower/bin/Release/*.dll
|
|
|
|
- name: Push to NuGet
|
|
if: steps.release_type.outputs.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"
|