From 70465071dcdc92b3a38a6fc007b7d191adc10e2a Mon Sep 17 00:00:00 2001 From: Brennan Beam Date: Fri, 28 Nov 2025 12:37:41 -0800 Subject: [PATCH] updates to use reusable workflows --- .github/workflows/Integration.yml | 22 ++--------- .github/workflows/Release.yml | 46 +++++---------------- .github/workflows/Snapshot.yml | 66 ++++--------------------------- 3 files changed, 20 insertions(+), 114 deletions(-) diff --git a/.github/workflows/Integration.yml b/.github/workflows/Integration.yml index 8a7d6ba..dfd4d9a 100644 --- a/.github/workflows/Integration.yml +++ b/.github/workflows/Integration.yml @@ -4,25 +4,9 @@ on: pull_request: branches: [ main ] -env: - dotnet-version: '9.0.x' - jobs: CI: - runs-on: windows-latest - env: + uses: HydrologicEngineeringCenter/dotnet-workflows/.github/workflows/integration.yml@main + with: dotnet-version: '9.0.x' - - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Setup .NET Core SDK ${{ env.dotnet-version }} - uses: actions/setup-dotnet@v4 - with: - dotnet-version: ${{ env.dotnet-version }} - - - name: Test Solution - run: dotnet test --nologo -c Release \ No newline at end of file + run-tests: true diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml index 0f17dc5..53627e2 100644 --- a/.github/workflows/Release.yml +++ b/.github/workflows/Release.yml @@ -1,4 +1,4 @@ -name: Snapshot +name: Release on: push: @@ -7,39 +7,11 @@ on: jobs: build: - runs-on: windows-latest - - env: - dotnet-version: '9.0.x' - - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Setup .NET Core SDK ${{ env.dotnet-version }} - uses: actions/setup-dotnet@v4 - with: - dotnet-version: ${{ env.dotnet-version }} - - - name: Test - run: dotnet test -c Release - - - name: Create version number - shell: pwsh - run: | - $TAG = $env:GITHUB_REF -replace 'refs/tags/', '' - $VERSION = $TAG -replace '^v', '' - echo "VERSION=$VERSION" >> $env:GITHUB_ENV - - - name: Pack - shell: pwsh - run: | - # Use the snapshot version from the previous step - dotnet pack --configuration Release /p:PackageVersion=${{ env.VERSION }} - - - name: Publish - shell: pwsh - run: dotnet nuget push "**/*.nupkg" --api-key ${{ secrets.NEXUS_NUGET_APIKEY }} --source "https://www.hec.usace.army.mil/nexus/repository/consequences-nuget-public/" --skip-duplicate - \ No newline at end of file + uses: HydrologicEngineeringCenter/dotnet-workflows/.github/workflows/release.yml@main + with: + dotnet-version: '9.0.x' + project-names: 'Numerics' + run-tests: true + nuget-source: 'https://www.hec.usace.army.mil/nexus/repository/consequences-nuget-public/' + secrets: + NUGET_API_KEY: ${{ secrets.NEXUS_NUGET_APIKEY }} diff --git a/.github/workflows/Snapshot.yml b/.github/workflows/Snapshot.yml index 5b1306c..c172bf9 100644 --- a/.github/workflows/Snapshot.yml +++ b/.github/workflows/Snapshot.yml @@ -6,61 +6,11 @@ on: jobs: build: - runs-on: windows-latest - - env: - dotnet-version: '9.0.x' - - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Setup .NET Core SDK ${{ env.dotnet-version }} - uses: actions/setup-dotnet@v4 - with: - dotnet-version: ${{ env.dotnet-version }} - - - name: Test - run: dotnet test -c Release - - - name: Get version from built assembly and set snapshot version - id: set-version - shell: powershell - run: | - # Get the assembly version from the built DLL. It's already built from the test step. - $assemblyPath = "Numerics/bin/Release/net8.0/Numerics.dll" - - # Load the assembly and get its version - $assembly = [System.Reflection.Assembly]::LoadFrom((Resolve-Path $assemblyPath).Path) - $assemblyVersion = $assembly.GetName().Version - - # Extract major.minor.patch from assembly version - $baseVersion = "$($assemblyVersion.Major).$($assemblyVersion.Minor).$($assemblyVersion.Build)" - - # Create snapshot version with GitHub run number - $snapshotVersion = "${baseVersion}.${{ github.run_number }}-dev" - - # Output the version for use in next steps - echo "SNAPSHOT_VERSION=$snapshotVersion" | Out-File -FilePath $env:GITHUB_ENV -Append - echo "BASE_VERSION=$baseVersion" | Out-File -FilePath $env:GITHUB_ENV -Append - - # Also set as step output - echo "version=$snapshotVersion" >> $env:GITHUB_OUTPUT - echo "base_version=$baseVersion" >> $env:GITHUB_OUTPUT - - # Display the version - Write-Host "Assembly Version: $assemblyVersion" - Write-Host "Base Version: $baseVersion" - Write-Host "Snapshot Version: $snapshotVersion" - - - name: Pack - run: | - # Use the snapshot version from the previous step - dotnet pack --configuration Release /p:PackageVersion=$env:SNAPSHOT_VERSION - Write-Host "Created package with version: $env:SNAPSHOT_VERSION" - shell: powershell - - - name: Publish - run: dotnet nuget push "**/*.nupkg" --api-key ${{ secrets.NEXUS_NUGET_APIKEY }} --source "https://www.hec.usace.army.mil/nexus/repository/consequences-nuget-public/" --skip-duplicate \ No newline at end of file + uses: HydrologicEngineeringCenter/dotnet-workflows/.github/workflows/snapshot.yml@main + with: + dotnet-version: '9.0.x' + project-names: 'Numerics' + run-tests: true + nuget-source: 'https://www.hec.usace.army.mil/nexus/repository/consequences-nuget-public/' + secrets: + NUGET_API_KEY: ${{ secrets.NEXUS_NUGET_APIKEY }}