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

Add Workflows #154

Closed
wants to merge 6 commits into from
Closed
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
363 changes: 356 additions & 7 deletions .editorconfig

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# For more information on how to configure a CODEOWNERS file, see
# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners

# These owners will be the default owners for everything in the repo. Unless a
# later match takes precedence, these users will be requested for review when
# someone opens a pull request.
* @scottoffen @sdoffen
163 changes: 163 additions & 0 deletions .github/workflows/main-pr-build-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
# GitHub Workflow to build and test the code on a pull request
name: PR Build and Test

# The workflow_dispatch event allows you to run the workflow manually
# The pull_request event triggers the workflow on pull requests to the main branch
on:
workflow_dispatch:
pull_request:
branches:
- main

jobs:
# This job will build and run the tests for the project
build:
name: Build and Test
runs-on: ubuntu-latest

# These permissions are required to restore from GitHub Packages
permissions:
contents: read
packages: read

# The matrix strategy allows you to run the same steps on multiple operating systems
# The library should be compatible with all the operating systems in the matrix
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]

# The steps below will run in order for each of strategies defined in the matrix
steps:

# Installs the most recent versions of the .NET SDKs
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
3.1.x
5.0.x
6.0.x
7.0.x
8.0.x

# Displays the available .NET SDKs for verification
- name: Display Available .NET SDKs
run: dotnet --list-sdks

# Checks out the code from the repository using a deep clone
# The deep close in necessary to access the full history of the repository
# so that the NerdBank.GitVersioning tool can determine the version number
- name: Checkout code (Deep Clone)
uses: actions/checkout@v4
with:
fetch-depth: 0

# Configure NuGet to use GitHub Packages as a source
- name: Configure NuGet for GitHub Packages
run: |
dotnet nuget add source https://nuget.pkg.github.com/scottoffen/index.json \
--name GitHub \
--username ${{ github.actor }} \
--password ${{ secrets.GITHUB_TOKEN }} \
--store-password-in-clear-text

# Restores the dependencies for the project
- name: Restore dependencies
run: dotnet restore ./src/Grapevine

# Builds the project without restoring the dependencies
- name: Build
run: dotnet build ./src/Grapevine --no-restore

# Runs all the tests in the project except the integration tests
# without rebuilding the project
- name: Test
run: dotnet test ./src/Grapevine --no-build --verbosity normal --filter "Category!=Integration"

# This job will determine if a pre-release package should be published
check:
name: Check for Source Code Changes
needs: build
runs-on: ubuntu-latest

outputs:
has_changes: ${{ steps.changed_files.outputs.any_changed }}

# The steps below will only run once
steps:

# Checks out the code from the repository using a deep clone
# The deep close in necessary to access the full history of the repository
# so that the NerdBank.GitVersioning tool can determine the version number
- name: Checkout code (Deep Clone)
uses: actions/checkout@v4
with:
fetch-depth: 0

# Checks for changes in the ./src directory that are not markdown files
# this step outpus a boolean value named any_changed that can be used in
# conditional steps.
- name: Check for source code changes
id: changed_files
uses: tj-actions/changed-files@v45
with:
files: 'src/**'
files_ignore: '**/*.md'

# This job will publish the package to GitHub Packages
# While this job is dependent on the build job, do not combine the jobs as
# the build job will run multiple times
publish:
name: Publish PreRelease Package
runs-on: ubuntu-latest
needs: check
if: ${{ needs.check.outputs.has_changes == 'true' }}

# These permissions are required to publish the package to GitHub Packages
permissions:
contents: write
packages: write

# The steps below will only run once
steps:

# Installs the most recent versions of the .NET SDKs
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x

# Displays the available .NET SDKs for verification
- name: Display Available .NET SDKs
run: dotnet --list-sdks

# Checks out the code from the repository using a deep clone
# The deep close in necessary to access the full history of the repository
# so that the NerdBank.GitVersioning tool can determine the version number
- name: Checkout code (Deep Clone)
uses: actions/checkout@v4
with:
fetch-depth: 0

# Configure NuGet to use GitHub Packages as a source
- name: Configure NuGet for GitHub Packages
run: |
dotnet nuget add source https://nuget.pkg.github.com/scottoffen/index.json \
--name GitHub \
--username ${{ github.actor }} \
--password ${{ secrets.GITHUB_TOKEN }} \
--store-password-in-clear-text

# Restores the dependencies for the project
- name: Restore dependencies
run: dotnet restore ./src/Grapevine

# Builds the project using the Release configuration without restoring dependencies
- name: Build
run: dotnet build ./src/Grapevine --no-restore --configuration Release --output ./publish

# Publishes the package to GitHub Packages
- name: Publish to GitHub Packages
run: |
dotnet nuget push ./publish/*.nupkg --source https://nuget.pkg.github.com/scottoffen/index.json --api-key ${{ secrets.GITHUB_TOKEN }}
dotnet nuget push ./publish/*.snupkg --source https://nuget.pkg.github.com/scottoffen/index.json --api-key ${{ secrets.GITHUB_TOKEN }}
179 changes: 179 additions & 0 deletions .github/workflows/main-publish-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
# This workflow will automatically build and test the project when code is merged
# into the main branch, then publish a release of the library to GitHub Packages.
# It can also be manually triggered to optionally publish to Nuget.org.
name: Publish Release

# The workflow_dispatch event allows you to run the workflow manually
# The push event triggers the workflow on pushes to the main branch
on:
workflow_dispatch:
inputs:
pushNuget:
description: 'Push to Nuget'
required: false
default: false
type: boolean
pushGitHub:
description: 'Push to GitHub'
required: false
default: true
type: boolean
push:
branches:
- main
paths:
- 'src/**'
- '!src/**/*.md'

jobs:
# This job will build and run the tests for the project
build:
name: Build and Test
runs-on: ubuntu-latest

# These permissions are required to restore from GitHub Packages
permissions:
contents: read
packages: read

# The matrix strategy allows you to run the same steps on multiple operating systems
# The library should be compatible with all the operating systems in the matrix
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]

# The steps below will run in order for each of strageies defined in the matrix
steps:

# Installs the most recent versions of the .NET SDKs
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x

# Displays the available .NET SDKs for verification
- name: Display Available .NET SDKs
run: dotnet --list-sdks

# Checks out the code from the repository using a deep clone
# The deep close in necessary to access the full history of the repository
# so that the NerdBank.GitVersioning tool can determine the version number
- name: Checkout Code (Deep Clone)
uses: actions/checkout@v4
with:
fetch-depth: 0

# Configure NuGet to use GitHub Packages as a source
- name: Configure NuGet for GitHub Packages
run: |
dotnet nuget add source https://nuget.pkg.github.com/scottoffen/index.json \
--name GitHub \
--username ${{ github.actor }} \
--password ${{ secrets.GITHUB_TOKEN }} \
--store-password-in-clear-text

# Restores the dependencies for the project
- name: Restore Dependencies
run: dotnet restore ./src/Grapevine

# Builds the project without restoring the dependencies
- name: Build Project
run: dotnet build ./src/Grapevine --no-restore

# Runs all the tests in the project except the integration tests
# without rebuilding the project
- name: Execute Test
run: dotnet test ./src/Grapevine --no-build --verbosity normal --filter "Category!=Integration"

# This job will publish the package to GitHub Packages
# While this job is dependent on the build job, do not combine the jobs as
# the build job will run multiple times
publish:
name: Publish Package
runs-on: ubuntu-latest
needs: build

# These permissions are required to publish the package to GitHub Packages
permissions:
contents: write
packages: write

# Get default values for the workflow_dispatch event inputs
env:
PUSH_GITHUB: ${{ github.event.inputs.pushGitHub || 'true' }}
PUSH_NUGET: ${{ github.event.inputs.pushNuget || 'false' }}

# The steps below will only run once
steps:

# Installs the most recent versions of the .NET SDKs
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x

# Displays the available .NET SDKs for verification
- name: Display Available .NET SDKs
run: dotnet --list-sdks

# Checks out the code from the repository using a deep clone
# The deep close in necessary to access the full history of the repository
# so that the NerdBank.GitVersioning tool can determine the version number
- name: Checkout Code (Deep Clone)
uses: actions/checkout@v4
with:
fetch-depth: 0

# Configure NuGet to use GitHub Packages as a source
- name: Configure NuGet for GitHub Packages
run: |
dotnet nuget add source https://nuget.pkg.github.com/scottoffen/index.json \
--name GitHub \
--username ${{ github.actor }} \
--password ${{ secrets.GITHUB_TOKEN }} \
--store-password-in-clear-text

# Restores the dependencies for the project
- name: Restore Dependencies
run: dotnet restore ./src/Grapevine

# Builds the project using the Release configuration without restoring dependencies
- name: Build Release
run: dotnet build ./src/Grapevine --no-restore --configuration Release --output ./publish

# Output the github.event.inputs values
- name: Display Inputs
run: |
echo "pushGitHub: $PUSH_GITHUB"
echo "pushNuget: $PUSH_NUGET"

# Publishes the package to GitHub Packages
# This step is run by default, but can be disabled
- name: Publish to GitHub Packages
if: env.PUSH_GITHUB == 'true'
run: |
dotnet nuget push ./publish/*.nupkg --source https://nuget.pkg.github.com/scottoffen/index.json --api-key ${{ secrets.GITHUB_TOKEN }}
dotnet nuget push ./publish/*.snupkg --source https://nuget.pkg.github.com/scottoffen/index.json --api-key ${{ secrets.GITHUB_TOKEN }}

# Publishes the package to Nuget.org
# This step is optional and can be triggered manually
# The NUGET_API_KEY secret must be set in the repository settings
- name: Publish to Nuget.org
if: env.PUSH_NUGET == 'true'
run: |
dotnet nuget push ./publish/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}

# Outputs the version number for the release
# See https://www.jameskerr.blog/posts/how-to-set-output-in-github-actions/
- name: Get Version Info
id: get_version
run: |
cd src/Grapevine
echo "version='$(nbgv get-version -v NugetPackageVersion)'" >> "$GITHUB_OUTPUT"
cd ../..

# Create a release tag based on the version number
- name: Create Release
run: gh release create ${{ steps.get_version.outputs.version }} --title ${{ steps.get_version.outputs.version }} --notes "Release ${{ steps.get_version.outputs.version }}" --target main
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading