Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split GitHub workflows out into build and release #30

Merged
merged 1 commit into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Build

on:
push:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume that push doesn't include merges? Do we want to build on merge too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't see an alternative which would seem to include merges. I would have thought that a merge is just a merge commit, which is then pushed, and then the push would trigger this workflow. Or perhaps my understanding is lacking?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A merge wouldn't have to be pushed if it was done directly within the GitHub repo

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does trigger on merge to main.

branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- name: Check out
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/[email protected]

- name: Restore tools
run: dotnet tool restore

- name: Restore dependencies
run: dotnet restore
working-directory: ./src

- name: Build
run: dotnet build --configuration Release --no-restore
working-directory: ./src
25 changes: 14 additions & 11 deletions .github/workflows/deployment.yml → .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,39 @@
name: Nuget-Publish
name: Release Package

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
release:
types: [ published ]

jobs:
build:

runs-on: ubuntu-latest

permissions:
contents: write

steps:
- name: Check out
uses: actions/[email protected]
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/[email protected]
with:
dotnet-version: 6.0.300

- name: Restore tools
run: dotnet tool restore

- name: Restore dependencies
run: dotnet restore
working-directory: ./src

- name: Build
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we do run on every push/merge to master, can we reuse the artifact somehow rather than building from scratch?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. Let's make this an investigation task for another day!

run: dotnet build --configuration Release --no-restore
working-directory: ./src

- name: Pack
run: dotnet pack --configuration Release --no-build --output .
run: dotnet pack --no-build -p:PackageVersion=${{ github.ref_name }} -p:PackageReleaseNotes=${{ github.event.release.html_url }} --output .
working-directory: ./src
if: ${{ github.ref == 'refs/heads/main' }}

- name: Publish
run: dotnet nuget push "*.nupkg" --api-key ${{secrets.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json
working-directory: ./src
if: ${{ github.ref == 'refs/heads/main' }}