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

🤖 We haz GitHub Actions ⚡ #1

Merged
merged 2 commits into from
Nov 9, 2023
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
74 changes: 74 additions & 0 deletions .github/workflows/MergeToMain.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Merge Pull Requests into 'main'

on:
push:
branches: [main]

permissions:
packages: write

env:
DOTNET_NOLOGO: true

jobs:
build_and_create_a_nuget:
name: Build and create a NuGet (RELEASE)
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Build version prefix/suffix
run: |
echo "VERSION_PREFIX=$(( 100 + ${{ github.run_number }} )).0.0" >> $GITHUB_ENV
echo "VERSION_SUFFIX=beta" >> $GITHUB_ENV

- name: Setup .NET
uses: actions/setup-dotnet@v3

- run: dotnet restore --verbosity minimal

- run: dotnet build --configuration Release -p:ContinuousIntegrationBuild=true -p:DebugType=Embedded -p:VersionPrefix=$VERSION_PREFIX --version-suffix $VERSION_SUFFIX

- run: dotnet test --configuration Release --no-build

- run: dotnet pack --configuration Release --no-build --output ./artifacts -p:DebugType=Embedded -p:VersionPrefix=$VERSION_PREFIX --version-suffix $VERSION_SUFFIX

- name: Publish artifacts
uses: actions/upload-artifact@v3
with:
name: NuGetPackage.${{ env.VERSION_PREFIX }}-${{ env.VERSION_SUFFIX }}
path: ./artifacts/

- name: Publish to GPR
run: |
dotnet nuget push "./artifacts/*.nupkg" \
--no-symbols \
--api-key ${{ secrets.GITHUB_TOKEN }} \
--source https://nuget.pkg.github.com/${{ github.repository_owner }}

test:
name: Build and Test with CodeCov (DEBUG)
runs-on: ubuntu-latest


steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Setup .NET
uses: actions/setup-dotnet@v3

- run: dotnet restore --verbosity minimal

- run: dotnet build --configuration Debug

- run: dotnet test --configuration Debug --verbosity minimal --no-build --collect:"XPlat Code Coverage" --results-directory "./.codecoverage"

- name: Code coverage
uses: codecov/codecov-action@v3
with:
token: "${{ secrets.CODECOV_TOKEN }}"
directory: "./.codecoverage"
fail_ci_if_error: true
60 changes: 60 additions & 0 deletions .github/workflows/PullRequest.yml
Original file line number Diff line number Diff line change
@@ -1 +1,61 @@
name: Pull Request

on: pull_request

env:
DOTNET_NOLOGO: true

jobs:

build_and_test_debug:
name: Build and test with CodeCov (DEBUG)
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup .NET
uses: actions/setup-dotnet@v3

- run: dotnet restore --verbosity minimal

- run: dotnet build --configuration Debug /p:ContinuousIntegrationBuild=true

- run: dotnet test --configuration Debug --verbosity minimal --no-build --collect:"XPlat Code Coverage" --results-directory "./.codecoverage"

- name: Code coverage
uses: codecov/codecov-action@v3
with:
directory: "./.codecoverage"
fail_ci_if_error: true

build_and_test_release:
name: Build and test (RELEASE)
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Build version prefix/suffix
run: |
echo "VERSION_PREFIX=$(( 100 + ${{ github.run_number }} )).0.0" >> $GITHUB_ENV
echo "VERSION_SUFFIX=alpha" >> $GITHUB_ENV

- name: Setup .NET
uses: actions/setup-dotnet@v3

- run: dotnet restore --verbosity minimal

- run: dotnet build --configuration Release -p:ContinuousIntegrationBuild=true -p:DebugType=Embedded -p:VersionPrefix=$VERSION_PREFIX --version-suffix $VERSION_SUFFIX

- run: dotnet test --configuration Release --no-build

- run: dotnet pack --configuration Release --no-build --output ./artifacts -p:DebugType=Embedded -p:VersionPrefix=$VERSION_PREFIX --version-suffix $VERSION_SUFFIX

- name: Publish artifacts
uses: actions/upload-artifact@v3
with:
name: NuGetPackage.${{ env.VERSION_PREFIX }}-${{ env.VERSION_SUFFIX }}
path: ./artifacts/
63 changes: 63 additions & 0 deletions .github/workflows/Release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Publish to Nuget.org and GPR

on:
push:
tags:
- "v*.*.*"
- "*.*.*"

permissions:
contents: write
packages: write

env:
DOTNET_NOLOGO: true

jobs:
build_and_create_a_nuget_publish:
name: Build, Create a NuGet and Publish
runs-on: ubuntu-latest

steps:

- name: Calculate version from the Commit Tag
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

- name: Checkout repository
uses: actions/checkout@v3

- name: Setup .NET
uses: actions/setup-dotnet@v3

- run: dotnet restore --verbosity minimal

- run: dotnet build --configuration Release -p:ContinuousIntegrationBuild=true -p:DebugType=Embedded -p:version=${{ env.RELEASE_VERSION }}

- run: dotnet pack --configuration Release --no-build --output ./artifacts -p:DebugType=Embedded -p:version=${{ env.RELEASE_VERSION }}

- name: Publish artifacts
uses: actions/upload-artifact@v3
with:
name: NuGetPackage.${{ env.RELEASE_VERSION }}
path: ./artifacts/

- name: Upload release assets
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: NuGetPackage.${{ env.RELEASE_VERSION }}
files: ./artifacts/*

- name: Publish to GPR
run: |
dotnet nuget push "./artifacts/*.nupkg" \
--no-symbols \
--api-key ${{ secrets.GITHUB_TOKEN }} \
--source https://nuget.pkg.github.com/${{ github.repository_owner }}

- name: Publish to nuget.org
run: |
dotnet nuget push "./artifacts/*.nupkg" \
--api-key ${{ secrets.NUGET_TOKEN }} \
--source https://api.nuget.org/v3/index.json
Loading