Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.

Commit

Permalink
Merge pull request #45 from kurmann/44-klassenbibliothek-template-mit…
Browse files Browse the repository at this point in the history
…-neuen-workflows

Template für Klassenbibliothek-Repository mit neuen Release Drafter- und Paketierungsworkflows ausgestattet
  • Loading branch information
kurmann authored Apr 25, 2024
2 parents 977effa + ce22b33 commit 44cd83a
Show file tree
Hide file tree
Showing 4 changed files with 175 additions and 67 deletions.
39 changes: 39 additions & 0 deletions templates/entities-repo/.github/release-drafter-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Konfigurationsdatei für das Release-Drafter-Tool.
# release-drafter-config.yml

# Definiert die Vorlage für den Namen des Releases.
name-template: 'v$RESOLVED_VERSION' # Automatisch erhöhte Versionsnummer

# Definiert die Vorlage für den Namen des Release-Tags.
tag-template: 'v$RESOLVED_VERSION' # Automatisch erhöhte Versionsnummer

# Kategorien für das Changelog, identifiziert durch Labels auf Pull Requests.
categories:
- title: 'Features'
labels:
- 'enhancement'
- title: 'Bug Fixes'
labels:
- 'bug'
- title: 'Dokumentation'
labels:
- 'documentation'

# Layout des Changelogs, formatiert nach den Änderungen in den Pull Requests.
template: |
## Änderungen
$CHANGES
# Version-Resolver bestimmt die Art der Versionserhöhung basierend auf den PR Labels.
version-resolver:
major:
labels:
- 'breaking'
minor:
labels:
- 'enhancement'
patch:
labels:
- 'bug'
- 'documentation'
default: minor
67 changes: 0 additions & 67 deletions templates/entities-repo/.github/workflows/dotnet.yml

This file was deleted.

45 changes: 45 additions & 0 deletions templates/entities-repo/.github/workflows/draft_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Draft Release

on:
push:
branches:
- '**'
workflow_dispatch:

permissions:
contents: write # Erlaubt das Erstellen von Releases und das Schreiben von Tags.
pull-requests: read # Ermöglicht das Lesen von PR-Informationen für den Release-Entwurf.

jobs:
build_and_test:
runs-on: ubuntu-latest

env:
PROJECT_FILE: src/ProjectName/ProjectName.csproj
DOTNET_VERSION: '8.0.x'

steps:
- uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Install dependencies
run: dotnet restore ${{ env.PROJECT_FILE }}

- name: Test
run: dotnet test ${{ env.PROJECT_FILE }}

release_draft:
runs-on: ubuntu-latest
needs: build_and_test
steps:
- uses: actions/checkout@v4
- name: Run Release Drafter
uses: release-drafter/release-drafter@v6
with:
config-name: 'release-drafter-config.yml'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
91 changes: 91 additions & 0 deletions templates/entities-repo/.github/workflows/publish_package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Publish NuGet Package on Release

on:
release:
types: [published]
workflow_dispatch: # Erlaubt manuelles Auslösen des Workflows über die GitHub-Oberfläche

permissions:
contents: write
packages: write
pull-requests: read

env:
CSPROJ_FILE: src/ProjectName/ProjectName.csproj
DOTNET_VERSION: '8.0.x'

jobs:
get_release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Get latest release
id: get_release
run: |
RELEASE_JSON=$(gh release view --json tagName,name,url)
RELEASE_TAG_NAME=$(echo "$RELEASE_JSON" | jq -r '.tagName')
RELEASE_NAME=$(echo "$RELEASE_JSON" | jq -r '.name')
RELEASE_URL=$(echo "$RELEASE_JSON" | jq -r '.url')
RELEASE_VERSION="${RELEASE_TAG_NAME#"v"}"
echo "release_version=$RELEASE_VERSION" >> "$GITHUB_OUTPUT"
echo "release_tag_name=$RELEASE_TAG_NAME" >> "$GITHUB_OUTPUT"
echo "release_url=$RELEASE_URL" >> "$GITHUB_OUTPUT"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
outputs:
release_version: ${{ steps.get_release.outputs.release_version }}
release_tag_name: ${{ steps.get_release.outputs.release_tag_name }}
release_url: ${{ steps.get_release.outputs.release_url }}

build_and_publish:
needs: get_release
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Restore dependencies
run: dotnet restore ${{ env.CSPROJ_FILE }}

- name: Build
run: dotnet build ${{ env.CSPROJ_FILE }} --no-restore --configuration Release

- name: Pack
run: |
echo "Using version ${{ needs.get_release.outputs.release_version }} from setup job."
dotnet pack ${{ env.CSPROJ_FILE }} --no-build --configuration Release \
-p:PackageVersion=${{ needs.get_release.outputs.release_version }} \
-p:PackageReleaseNotes=${{ needs.get_release.outputs.release_url }} \
-p:PackageProjectUrl="https://github.com/${{ github.repository }}" \
-p:RepositoryUrl="https://github.com/${{ github.repository }}.git" \
-p:RepositoryType="git" \
--include-symbols -p:SymbolPackageFormat=snupkg \
-o nupkgs
shell: bash

- name: List output files
run: |
echo "Listing built packages in nupkgs directory:"
ls nupkgs/
shell: bash

- name: Push NuGet Package
run: |
cd nupkgs
dotnet nuget push "*.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
shell: pwsh

- name: Push to GitHub Packages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd nupkgs
dotnet nuget push "*.nupkg" --api-key $env:GITHUB_TOKEN --source "https://nuget.pkg.github.com/${{ github.repository_owner }}" --skip-duplicate
shell: pwsh


0 comments on commit 44cd83a

Please sign in to comment.