Skip to content

Commit

Permalink
ci: Add pipelines for release & testing
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMerski committed Feb 9, 2024
1 parent c7cc78a commit 49207cf
Show file tree
Hide file tree
Showing 6 changed files with 214 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "nuget" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "monthly"
groups:
all:
patterns:
- "*"
- package-ecosystem: "github-actions" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "monthly"
groups:
all:
patterns:
- "*"
65 changes: 65 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name-template: 'v$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'
categories:
- title: '🛠 Breaking Changes'
labels:
- 'breaking-change'
- 'major'
- title: '🚀 Features'
labels:
- 'feature'
- 'enhancement'
- title: '🐛 Bug Fixes'
labels:
- 'fix'
- 'bugfix'
- 'bug'
- title: '🧰 Maintenance'
labels:
- 'chore'
- 'dependencies'
- 'security'
- title: '🏗️ GitHub actions'
labels:
- 'ci'
- 'github-actions'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
commitish: 'main'
exclude-labels:
- "ignore-for-release"
version-resolver:
major:
labels:
- 'major'
minor:
labels:
- 'minor'
patch:
labels:
- 'patch'
default: patch
autolabeler:
- label: 'chore'
branch:
- '/docs{0,1}\/.+/'
title:
- "/chore/i"
- "/docs/i"
- label: 'github-actions'
title:
- "/github actions/i"
- "/ci/i"
- label: 'bug'
branch:
- '/fix\/.+/'
title:
- "/bug/i"
- "/fix/i"
- label: 'feature'
title:
- "/feat/i"
template: |
## Changes
$CHANGES
53 changes: 53 additions & 0 deletions .github/workflows/publish-nuget.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Publish C# package to the Github NuGet registry

on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: 'Version to publish'
required: true

env:
# tag names are formatted like `v1.0.0`, nuget needs it without a `v`
PACKAGE_VERSION_PREFIXED: ${{ github.event_name == 'release' && github.event.release.tag_name || github.event.inputs.version }}

jobs:
test:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Install dependencies
run: dotnet restore
- name: Test
run: dotnet test --no-build

publish:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
needs:
- test
steps:
- uses: actions/checkout@v4
- name: Format nuget version
run: |
echo "PACKAGE_VERSION=${PACKAGE_VERSION_PREFIXED#v}" | tee -a $GITHUB_ENV
- uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release
working-directory: Q42.Google.Cloud.Compute.Metadata.V1
- name: Publish to github nuget registry
run: dotnet nuget push bin/Release/*.nupkg --api-key "${{ secrets.NUGET_KEY }}" --source "https://api.nuget.org/v3/index.json"
working-directory: Q42.Google.Cloud.Compute.Metadata.V1
42 changes: 42 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Release Drafter

on:
push:
# branches to consider in the event; optional, defaults to all
branches:
- main
# pull_request event is required only for autolabeler
pull_request:
# Only following types are handled by the action, but one can default to all as well
types: [opened, reopened, synchronize]
# pull_request_target event is required for autolabeler to support PRs from forks
# pull_request_target:
# types: [opened, reopened, synchronize]

permissions:
contents: read

jobs:
update_release_draft:
permissions:
# write permission is required to create a github release
contents: write
# write permission is required for autolabeler
# otherwise, read permission is required at least
pull-requests: write
runs-on: ubuntu-latest
steps:
# (Optional) GitHub Enterprise requires GHE_HOST variable set
#- name: Set GHE_HOST
# run: |
# echo "GHE_HOST=${GITHUB_SERVER_URL##https:\/\/}" >> $GITHUB_ENV

# Drafts your next Release notes as Pull Requests are merged into "master"
- uses: release-drafter/release-drafter@v5
# (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
name: Release Drafter
id: drafter
with:
disable-autolabeler: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27 changes: 27 additions & 0 deletions .github/workflows/verify-pr
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Publish C# package to the Github NuGet registry

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

jobs:
test:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: 📥 Restore dependencies
run: dotnet restore --verbosity normal
- name: 🔨 Build
run: dotnet build --no-restore --verbosity normal
- name: 📋 Test
run: dotnet test --no-restore --verbosity normal
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackageId>Q42.Google.Cloud.Compute.Metadata.V1</PackageId>
<Version>$(PACKAGE_VERSION)</Version>
<Company>Q42</Company>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>

</Project>

0 comments on commit 49207cf

Please sign in to comment.