Skip to content

Commit

Permalink
set up GitHub
Browse files Browse the repository at this point in the history
  • Loading branch information
PrimeEagle committed Dec 5, 2023
1 parent 0cb6b99 commit de2fb1e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 6 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/build-dotnet.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: .NET Build and Version

on: [push, pull_request]
on:
push:
pull_request:
workflow_dispatch:

jobs:
build:
Expand All @@ -23,9 +26,15 @@ jobs:
with:
dotnet-version: ${{ secrets.DOTNET_VERSION }}

- name: Add GitHub Packages source
run: |
nuget sources Add -Name "GitHub" -Source "https://nuget.pkg.github.com/PrimeEagle/index.json" -Username PrimeEagle -Password ${{ secrets.NUGET_TOKEN }}
- name: Restore NuGet packages
run: dotnet restore ${{ secrets.DOTNET_SOLUTION }}

env:
NUGET_AUTH_TOKEN: ${{ secrets.NUGET_TOKEN }}

- name: Build with version
run: dotnet build ${{ secrets.DOTNET_SOLUTION }} /p:BuildNumber=${{ github.run_number }}

Expand Down
27 changes: 23 additions & 4 deletions .github/workflows/create-nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,20 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Check for version.json changes
id: check
run: |
$versionChanged = git diff --name-only ${{ github.event.before }} ${{ github.sha }} | Select-String -Pattern 'version.json' -Quiet
echo "version_changed=$versionChanged" | Out-File -Append -FilePath $Env:GITHUB_ENV
echo "::set-output name=version_changed::$versionChanged"
if ($versionChanged) {
echo "VERSION_CHANGED=true" | Out-File -Append -FilePath $Env:GITHUB_ENV
} else {
echo "VERSION_CHANGED=false" | Out-File -Append -FilePath $Env:GITHUB_ENV
}
echo "version_changed=$versionChanged" >> $GITHUB_ENV
- name: Add GitHub Packages source
run: |
nuget sources Add -Name "GitHub" -Source "https://nuget.pkg.github.com/PrimeEagle/index.json" -Username PrimeEagle -Password ${{ secrets.NUGET_TOKEN }}
create-package:
needs: check-version-change
Expand All @@ -36,9 +44,20 @@ jobs:
with:
dotnet-version: ${{ secrets.DOTNET_VERSION }}

- name: Pack
- name: Add GitHub Packages source
run: |
nuget sources Add -Name "GitHub" -Source "https://nuget.pkg.github.com/PrimeEagle/index.json" -Username PrimeEagle -Password ${{ secrets.NUGET_TOKEN }}
- name: Read Version from version.json
run: |
dotnet pack ${{ secrets.DOTNET_SOLUTION }} --configuration Release -o nupkgs
$versionJson = Get-Content version.json -Raw | ConvertFrom-Json
echo "VERSION_NUMBER=$($versionJson.version)" | Out-File -Append -FilePath $Env:GITHUB_ENV
- name: Print Version Number
run: echo "Version number is $env:VERSION_NUMBER"

- name: Pack
run: dotnet pack ${{ secrets.DOTNET_SOLUTION }} --configuration Release -o nupkgs /p:Version=${{ env.VERSION_NUMBER }}

- name: Upload Artifacts
uses: actions/upload-artifact@v2
Expand Down
3 changes: 3 additions & 0 deletions version.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"version": "1.0.0"
}

0 comments on commit de2fb1e

Please sign in to comment.