This documentation provides a comprehensive overview of the CI/CD automation scripts utilized in the stevedunn/vogen.serialization project. The CI/CD setup currently consists of a set of GitHub Actions workflows that facilitate build and publish processes.

CI/CD Automation Overview

Directory Structure

The workflows for CI/CD automation are located in the .github/workflows/ directory.

  • .github/workflows/build.yaml: This script encompasses the build process of the project.
  • .github/workflows/publish.yaml: This script defines the publishing process once the build steps are successfully completed.

Step-by-Step Guide

Step 1: Build Workflow

The build.yaml file is where the build automation occurs. Below is an example of its contents:

name: Build

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout code
      uses: actions/checkout@v2

    - name: Setup .NET Environment
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: '6.0.300'

    - name: Restore NuGet packages
      run: dotnet restore

    - name: Build Project
      run: dotnet build --configuration Release

Explanation of Steps:

  • The workflow triggers on pushes and pull requests to the main branch.
  • It runs on an Ubuntu environment.
  • The code is checked out from the repository.
  • The .NET environment is set up using a specified version.
  • NuGet packages are restored to ensure that dependencies are available.
  • The project is built in the release configuration.

Step 2: Publish Workflow

The publish.yaml file defines how to publish the project after a successful build. Below is a sample:

name: Publish

on:
  push:
    tags:
      - 'v*'

jobs:
  publish:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout code
      uses: actions/checkout@v2

    - name: Setup .NET Environment
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: '6.0.300'

    - name: Restore NuGet packages
      run: dotnet restore

    - name: Build Project
      run: dotnet build --configuration Release

    - name: Publish Package
      run: dotnet pack --configuration Release --output ./output

Explanation of Steps:

  • This workflow is triggered on tagging events that match the pattern v*.
  • It follows similar initial steps: checking out code and setting up the .NET environment.
  • After restoring packages and building the project, the dotnet pack command is executed to create a NuGet package of the project set for publication.

Conclusion

The stevedunn/vogen.serialization project currently has CI/CD automation set up using GitHub Actions workflows, specifically for build and publish processes using C#.

Next Steps for CI/CD Setup: If there are additional CI/CD processes not yet implemented (e.g., testing or deployment workflows), consider the following steps:

  1. Add Testing Workflows: Implement a testing workflow to automatically run tests for each pull request or push.
  2. Improve Publishing Process: Define additional publishing strategies tailored to different target environments.
  3. Use Secrets for Sensitive Data: If publishing to package repositories, make sure to manage authentication tokens securely using GitHub Secrets.

For more detailed requirements on implementing these next steps, reference the GitHub Actions documentation.