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 #56 from kurmann/55-add-release-draft-and-publish-…
Browse files Browse the repository at this point in the history
…package-workflows-to-class-lib-repo

Neuer Release Draft- und Publish Package-Workflow in `classlib-repo`-Template übernommen
kurmann authored Apr 26, 2024
2 parents 05fc3f7 + 89de3ea commit 3675279
Showing 2 changed files with 30 additions and 20 deletions.
10 changes: 5 additions & 5 deletions templates/entities-repo/.github/workflows/draft_release.yml
Original file line number Diff line number Diff line change
@@ -7,15 +7,15 @@ on:
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.
contents: write
pull-requests: read

jobs:
build_and_test:
runs-on: ubuntu-latest

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

steps:
@@ -27,10 +27,10 @@ jobs:
dotnet-version: ${{ env.DOTNET_VERSION }}

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

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

release_draft:
runs-on: ubuntu-latest
40 changes: 25 additions & 15 deletions templates/entities-repo/.github/workflows/publish_package.yml
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ name: Publish NuGet Package on Release
on:
release:
types: [published, prereleased]
workflow_dispatch: # Erlaubt manuelles Auslösen des Workflows über die GitHub-Oberfläche
workflow_dispatch:

permissions:
contents: write
@@ -15,32 +15,42 @@ env:
DOTNET_VERSION: '8.0.x'

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

- name: Get latest release
id: get_release
- name: Get latest release or prerelease
id: get_release_or_prerelease
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')
RELEASES_JSON=$(gh release list --json tagName,name,isPrerelease --exclude-drafts)
LATEST_RELEASE_OR_PRERELEASE_JSON=$(echo "$RELEASES_JSON" | jq -r '.[0]')
RELEASE_TAG_NAME=$(echo "$LATEST_RELEASE_OR_PRERELEASE_JSON" | jq -r '.tagName')
RELEASE_NAME=$(echo "$LATEST_RELEASE_OR_PRERELEASE_JSON" | jq -r '.name')
RELEASE_IS_PRERELEASE=$(echo "$LATEST_RELEASE_OR_PRERELEASE_JSON" | jq -r '.isPrerelease')
RELEASE_VERSION="${RELEASE_TAG_NAME#"v"}"
REPO_URL="https://github.com/${GITHUB_REPOSITORY}"
RELEASE_URL="${REPO_URL}/releases/tag/${RELEASE_TAG_NAME}"
echo "release_version=$RELEASE_VERSION" >> "$GITHUB_OUTPUT"
echo "release_tag_name=$RELEASE_TAG_NAME" >> "$GITHUB_OUTPUT"
echo "release_url=$RELEASE_URL" >> "$GITHUB_OUTPUT"
echo "release_is_prerelease=$RELEASE_IS_PRERELEASE" >> "$GITHUB_OUTPUT"
echo "Found latest $(if [ "$RELEASE_IS_PRERELEASE" = "true" ]; then echo "prerelease"; else echo "release"; fi): $RELEASE_TAG_NAME"
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 }}
release_version: ${{ steps.get_release_or_prerelease.outputs.release_version }}
release_tag_name: ${{ steps.get_release_or_prerelease.outputs.release_tag_name }}
release_url: ${{ steps.get_release_or_prerelease.outputs.release_url }}
release_is_prerelease: ${{ steps.get_release_or_prerelease.outputs.release_is_prerelease }}

build_and_publish:
needs: get_release
needs: get_release_or_prerelease
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
@@ -57,10 +67,10 @@ jobs:

- name: Pack
run: |
echo "Using version ${{ needs.get_release.outputs.release_version }} from setup job."
echo "Using version ${{ needs.get_release_or_prerelease.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:PackageVersion=${{ needs.get_release_or_prerelease.outputs.release_version }} \
-p:PackageReleaseNotes=${{ needs.get_release_or_prerelease.outputs.release_url }} \
-p:PackageProjectUrl="https://github.com/${{ github.repository }}" \
-p:RepositoryUrl="https://github.com/${{ github.repository }}.git" \
-p:RepositoryType="git" \

0 comments on commit 3675279

Please sign in to comment.