Skip to content

Commit

Permalink
Used re-usable workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
droyad committed Mar 19, 2024
1 parent d364c9f commit e0a89da
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 64 deletions.
66 changes: 2 additions & 64 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,68 +7,6 @@ on:

jobs:
build:
runs-on: ubuntu-latest
name: Build
uses: DbUp/Universe/ReusableWorkflows/build.yml

env:
DOTNET_NOLOGO: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true # Avoid pre-populating the NuGet package cache
ASSENTNONINTERACTIVE: true

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # all

- name: Setup .NET 8.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: 8.0.x

- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0
with:
versionSpec: '5.x'

- name: Run GitVersion
id: gitversion
uses: gittools/actions/gitversion/execute@v0

- name: Display SemVer
run: |
echo "SemVer: $GitVersion_SemVer"
- name: Add DbUp NuGet Source
run: dotnet nuget add source --name DbUp --username DbUp --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text https://nuget.pkg.github.com/DbUp/index.json

- name: Restore
run: dotnet restore
working-directory: src

- name: Build
run: dotnet build -c Release --no-restore /p:Version=$GitVersion_SemVer
working-directory: src

- name: Test
run: dotnet test --no-build -c Release --logger trx --logger "console;verbosity=detailed" --results-directory ../artifacts
working-directory: src

- name: Pack
run: dotnet pack --no-build -c Release -o ../artifacts /p:Version=$GitVersion_SemVer
working-directory: src

- name: Push NuGet packages to GitHub Packages ⬆️
working-directory: artifacts
run: dotnet nuget push *.nupkg --api-key ${{ secrets.GITHUB_TOKEN }} --source "https://nuget.pkg.github.com/DbUp/index.json"

- name: Push NuGet packages to NuGet ⬆️
if: ${{ steps.gitversion.outputs.preReleaseLabel == '' }}
working-directory: artifacts
run: dotnet nuget push *.nupkg --api-key ${{ secrets.NUGET_APIKEY }} --source https://api.nuget.org/v3/index.json

- name: Test Report 🧪
uses: dorny/test-reporter@v1
if: ${{ always() }}
with:
name: Tests
path: artifacts/*.trx
reporter: dotnet-trx
11 changes: 11 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Publish DbUp Packages to NuGet

on:
release:
types: [ published ]
workflow_dispatch:

jobs:
publish:
name: Publish Package
uses: DbUp/Universe/ReusableWorkflows/publish-release.yml
13 changes: 13 additions & 0 deletions .github/workflows/test-report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Test Report
run-name: Generate Test Report for workflow ${{ github.event.workflow_run.name }} run ${{ github.event.workflow_run.run_number }} branch ${{ github.event.workflow_run.head_branch }}

on:
workflow_run:
workflows: [ "CI" ]
types:
- completed

jobs:
report:
name: Test Report 🧪
uses: DbUp/Universe/ReusableWorkflows/test-report.yml
2 changes: 2 additions & 0 deletions src/dbup-mysql.sln
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{62E5FE92-E288-4E09-964D-F92AF0E49131}"
ProjectSection(SolutionItems) = preProject
..\.github\workflows\main.yml = ..\.github\workflows\main.yml
..\.github\workflows\publish-release.yml = ..\.github\workflows\publish-release.yml
..\.github\workflows\test-report.yml = ..\.github\workflows\test-report.yml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{5DA19CA9-8039-46D6-B474-021943582785}"
Expand Down

0 comments on commit e0a89da

Please sign in to comment.