From 25e85cf91911f7f11dd86b3d8a4caef7139d53dd Mon Sep 17 00:00:00 2001 From: Patrick Kurmann Date: Fri, 26 Apr 2024 07:28:15 +0200 Subject: [PATCH 1/3] removed inline docs --- templates/entities-repo/.github/workflows/publish_package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/entities-repo/.github/workflows/publish_package.yml b/templates/entities-repo/.github/workflows/publish_package.yml index a89983c..fac3572 100644 --- a/templates/entities-repo/.github/workflows/publish_package.yml +++ b/templates/entities-repo/.github/workflows/publish_package.yml @@ -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 From 15ebfdfb515e557124a66e21d4eb5ea630785b60 Mon Sep 17 00:00:00 2001 From: Patrick Kurmann Date: Fri, 26 Apr 2024 07:29:46 +0200 Subject: [PATCH 2/3] get release or prerelease workflow --- .../.github/workflows/draft_release.yml | 4 +- .../.github/workflows/publish_package.yml | 38 ++++++++++++------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/templates/entities-repo/.github/workflows/draft_release.yml b/templates/entities-repo/.github/workflows/draft_release.yml index 5ed73d2..1f1bdda 100644 --- a/templates/entities-repo/.github/workflows/draft_release.yml +++ b/templates/entities-repo/.github/workflows/draft_release.yml @@ -7,8 +7,8 @@ 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: diff --git a/templates/entities-repo/.github/workflows/publish_package.yml b/templates/entities-repo/.github/workflows/publish_package.yml index fac3572..3e83cc1 100644 --- a/templates/entities-repo/.github/workflows/publish_package.yml +++ b/templates/entities-repo/.github/workflows/publish_package.yml @@ -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" \ From 89de3eaa7d8f14110819511fe683f4e3e0bf652e Mon Sep 17 00:00:00 2001 From: Patrick Kurmann Date: Fri, 26 Apr 2024 07:30:32 +0200 Subject: [PATCH 3/3] consistent csproj file var name --- templates/entities-repo/.github/workflows/draft_release.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/entities-repo/.github/workflows/draft_release.yml b/templates/entities-repo/.github/workflows/draft_release.yml index 1f1bdda..ed29a85 100644 --- a/templates/entities-repo/.github/workflows/draft_release.yml +++ b/templates/entities-repo/.github/workflows/draft_release.yml @@ -15,7 +15,7 @@ jobs: 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