Skip to content

About

Reusable GitHub Actions workflows for my .NET NuGet libraries: build, format check, test, pack and GitHub releases.

Topics

Resources

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

github-workflows

github-workflows

Reusable GitHub Actions workflows for the JorgeCostaMacia.* .NET libraries — build, format check, test, pack and GitHub Releases — written once and called with uses: from every library repo.

License Release

Called by ddd-dotnet, quartz-dotnet, serilog-dotnet, bus-dotnet, bus-kafka-dotnet, bus-rabbitmq-dotnet and http-dotnet. Public so that those public repos can call it; it is built for them, and nothing here is supported for anyone else.

Workflows

Workflow What it does
dotnet-build-nuget Convention guards, restore, build, format check, test and pack of a library repo, as the nuget artifact
github-release The GitHub Release of the pushed vX.Y.Z tag, its notes the tag's section of the CHANGELOG (GitHub's generated notes when there is none)

Each workflow documents itself: its header says what it does, how to call it and what the calling repo needs. release.yml is not one of them: it is this repository's own, which creates the GitHub Release of each vX.Y.Z tag.

Calling them

A library repo keeps three small workflows. Develop is the gate:

name: Develop

on:
  push:
    branches: [ "develop" ]
  pull_request:
    branches: [ "develop", "main" ]

permissions:
  contents: read

concurrency:
  group: develop-${{ github.ref }}
  cancel-in-progress: true

jobs:
  build:
    uses: JorgeCostaMacia/github-workflows/.github/workflows/dotnet-build-nuget.yml@v1
    with:
      solution: my-library.slnx

Main builds the same way and pushes the packages to nuget.org. The push is the caller's own job, because the Trusted Publishing policy on nuget.org names the repo's main.yml:

name: Main

on:
  push:
    branches: [ "main" ]

permissions:
  contents: read

concurrency:
  group: main

jobs:
  build:
    uses: JorgeCostaMacia/github-workflows/.github/workflows/dotnet-build-nuget.yml@v1
    with:
      solution: my-library.slnx

  publish:
    needs: build
    runs-on: ubuntu-latest
    permissions:
      id-token: write # the OIDC token that nuget.org exchanges for a one-hour API key
    steps:
      - name: Download nuget artifact
        uses: actions/download-artifact@v8
        with:
          name: nuget
          path: nuget
      - name: NuGet login
        uses: NuGet/login@v1
        id: login
        with:
          user: JorgeCostaMacia
      # One push for every package (the shell expands the list; each .snupkg goes with its .nupkg).
      # --skip-duplicate: a version already on nuget.org is left as it is, so a push to main that did not move the
      # version publishes nothing.
      - name: Push NuGet
        env:
          NUGET_API_KEY: ${{ steps.login.outputs.NUGET_API_KEY }}
        run: dotnet nuget push nuget/*.nupkg --api-key "$NUGET_API_KEY" --source https://api.nuget.org/v3/index.json --skip-duplicate

Release records each vX.Y.Z tag the GitFlow finish pushes, its notes the tag's section of the library's CHANGELOG.md (## 1.2.0, one paragraph per line):

name: Release

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

permissions:
  contents: write

jobs:
  release:
    uses: JorgeCostaMacia/github-workflows/.github/workflows/github-release.yml@v1

Trying a change

There is nothing to build or check here: a workflow only really runs when a repository calls it. Before every release, a library's feature branch pins this repository's @develop instead of @v1, and its own workflows run the change.

See CONTRIBUTING.md for GitFlow, the release and how to try a change before it, and AGENTS.md for how the repository is put together.

Versioning

Every release is a vX.Y.Z tag with its GitHub Release, and moves the major tag, v1, which callers pin (@v1): a compatible change reaches them with no change on their side, and a breaking one gets a new major. What a version asks of the repositories that call it is in CHANGELOG.md.

Contact

About

Reusable GitHub Actions workflows for my .NET NuGet libraries: build, format check, test, pack and GitHub releases.

Topics

Resources

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors