This repository has been archived by the owner on May 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from kurmann/26-klassenbibliothek-template-mit…
…-neuen-github-workflows-ausstatten Template-Projekt mit neuen GitHub Release-Crafter Workflows ausgestattet einschliesslich zusätzlicher Paketveröffentlichung auf GitHub
- Loading branch information
Showing
3 changed files
with
150 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,44 @@ | ||
name: Pack .NET Template | ||
|
||
# Versionierungsstrategie: | ||
# Für den main-Branch werden Releases mit der in der .csproj-Datei festgelegten Version erstellt, | ||
# die manuell vor dem Merge angepasst werden sollte. Dies ermöglicht eine präzise Kontrolle über Major und Minor Releases. | ||
# Für alle anderen Branches werden automatische Zwischenreleases mit einem Datumssuffix generiert, um kontinuierliches Testing und Feedback | ||
# für Entwicklungsstände zu ermöglichen. Das Datumssuffix wird basierend auf dem aktuellen Datum und der Uhrzeit zum Zeitpunkt des Builds hinzugefügt, | ||
# was jede Version einzigartig macht. | ||
name: .NET CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- '**' | ||
|
||
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: | ||
pack: | ||
build_and_test: | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
PROJECT_FILE: Templates.csproj | ||
BASE_VERSION: '1.0.0' # Wird dynamisch überschrieben | ||
CSPROJ_FILE: src/Templates/Templates.csproj | ||
DOTNET_VERSION: '8.0.x' | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup .NET Core | ||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v4 | ||
with: | ||
dotnet-version: '8.0.x' | ||
|
||
- name: Restore NuGet packages | ||
run: dotnet restore ${{ env.PROJECT_FILE }} | ||
|
||
# Schritt: Lese die PackageVersion aus der .csproj Datei und setze sie als Umgebungsvariable | ||
- name: Read Package Version from .csproj and Set as Env Var | ||
run: | | ||
version=$(grep '<PackageVersion>' ${{ env.PROJECT_FILE }} | sed -n -e 's/.*<PackageVersion>\(.*\)<\/PackageVersion>.*/\1/p') | ||
echo "Base version is $version" | ||
echo "BASE_VERSION=$version" >> $GITHUB_ENV | ||
# Schritt: Pack .NET Template Project mit dynamischer Versionierung für Zwischenreleases | ||
- name: Pack .NET Template Project | ||
run: | | ||
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then | ||
dotnet pack ${{ env.PROJECT_FILE }} --configuration Release --output nupkg | ||
else | ||
datetimeSuffix=$(date +"%Y%m%d%H%M") | ||
version="${{ env.BASE_VERSION }}-preview.$datetimeSuffix" | ||
dotnet pack ${{ env.PROJECT_FILE }} /p:PackageVersion=$version --configuration Release --output nupkg | ||
echo "Zwischenversion ist $version" | ||
fi | ||
- name: Publish to NuGet.org | ||
run: dotnet nuget push "nupkg/*.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate | ||
dotnet-version: ${{ env.DOTNET_VERSION }} | ||
|
||
- name: Install dependencies | ||
run: dotnet restore ${{ env.CSPROJ_FILE }} | ||
|
||
- name: Test | ||
run: dotnet test ${{ env.CSPROJ_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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
name: Publish NuGet Package on Release | ||
|
||
on: | ||
release: | ||
types: [published] | ||
workflow_dispatch: # Erlaubt manuelles Auslösen des Workflows über die GitHub-Oberfläche | ||
|
||
env: | ||
CSPROJ_FILE: src/Templates/Templates.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" \ | ||
-o nupkg | ||
shell: bash | ||
|
||
- name: List output files | ||
run: | | ||
echo "Listing built packages in nupkgs directory:" | ||
ls nupkg/ | ||
shell: bash | ||
|
||
- name: Push NuGet Package | ||
run: | | ||
cd nupkg | ||
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 |