Skip to content

Commit

Permalink
Update build.yaml to support usage of NuGet packages from other repos…
Browse files Browse the repository at this point in the history
…itories (#263)
  • Loading branch information
masesdevelopers authored Jul 3, 2024
1 parent 434910b commit a03c756
Showing 1 changed file with 55 additions and 2 deletions.
57 changes: 55 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,19 @@ on:
push:
# only trigger on branches, not on tags
branches: '**'

workflow_dispatch:
inputs:
UseLastRepositoryBuildJNet:
description: 'Use latest NuGet packages from JNet'
required: true
default: false
type: boolean
UseLastRepositoryBuildKNet:
description: 'Use latest NuGet packages from KNet'
required: true
default: false
type: boolean

# This workflow contains two jobs called "check_changes", "build_windows"
jobs:
# Verify if a build is needed
Expand Down Expand Up @@ -65,6 +77,47 @@ jobs:
fetch-depth: '1'
submodules: 'true'

- name: Get last workflow run of JNet
if: ${{ inputs.UseLastRepositoryBuildJNet == true }}
shell: bash
run: echo "JNET_LAST_RUN=$(curl -sL https://api.github.com/repos/masesgroup/JNet/actions/workflows/build.yaml/runs | jq -r '.workflow_runs[0].id?')" >> $GITHUB_ENV

- name: Download artifact
if: ${{ inputs.UseLastRepositoryBuildJNet == true }}
run: gh run download ${{ env.JNET_LAST_RUN }} --name JNetNuGet --repo masesgroup/JNet --dir JNetNuGet
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: List NuGet packages downloaded
continue-on-error: true
shell: cmd
run: dir .\JNetNuGet\*nupkg

- name: Add local repo
if: ${{ success() && inputs.UseLastRepositoryBuildJNet == true }}
run: dotnet nuget add source --name localJNetNuGet "${{ github.workspace }}\JNetNuGet\"

- name: Get last workflow run of KNet
if: ${{ inputs.UseLastRepositoryBuildKNet == true }}
shell: bash
run: echo "KNET_LAST_RUN=$(curl -sL https://api.github.com/repos/masesgroup/KNet/actions/workflows/build.yaml/runs | jq -r '.workflow_runs[0].id?')" >> $GITHUB_ENV

- name: Download KNetNuGet artifact
if: ${{ inputs.UseLastRepositoryBuildKNet == true }}
run: gh run download ${{ env.KNET_LAST_RUN }} --name KNetNuGet --repo masesgroup/KNet --dir KNetNuGet
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: List KNetNuGet packages downloaded
if: ${{ inputs.UseLastRepositoryBuildKNet == true }}
continue-on-error: true
shell: cmd
run: dir .\KNetNuGet\*nupkg

- name: Add local repo
if: ${{ success() && inputs.UseLastRepositoryBuildKNet == true }}
run: dotnet nuget add source --name localKNetNuGet "${{ github.workspace }}\KNetNuGet\"

- name: Recompile to create nuget packages
run: dotnet build --no-incremental --configuration Release /p:Platform="Any CPU" src\net\KEFCore.sln

Expand All @@ -74,7 +127,7 @@ jobs:

- uses: actions/upload-artifact@v4
with:
name: KEFCore
name: KEFCoreNuGet
path: .\bin\*nupkg

- name: Compile tests
Expand Down

0 comments on commit a03c756

Please sign in to comment.