From 7ddecb819be20f840b61393f9e8fc04123fadf09 Mon Sep 17 00:00:00 2001 From: Alex Wichmann Date: Tue, 7 Feb 2023 13:24:28 +0100 Subject: [PATCH] ci: nuget publishing chore: release-internal, until open-source chore: rename internal release workflow name ci: remove unneeded internal nuget repository (#86) ci: setup nuget publishing (#87) Update release-package.yml Create CHANGELOG.md chore: update CHANGELOG.md Update release-package.yml reset changelog chore: update CHANGELOG.md Update release-package.yml reset changelog chore: update CHANGELOG.md Update LEGO.AsyncAPI.csproj Update LEGO.AsyncAPI.Readers.csproj reset changelog chore: update CHANGELOG.md Update release-package.yml reset changelog chore: update CHANGELOG.md reset changelog --- .github/workflows/ci.yml | 2 - .github/workflows/release-internal.yml | 35 +++++++ .github/workflows/release-package.yml | 92 +++++++++++-------- CHANGELOG.md | 1 + CODEOWNERS | 1 + .../LEGO.AsyncAPI.Readers.csproj | 2 +- src/LEGO.AsyncAPI/LEGO.AsyncAPI.csproj | 2 +- 7 files changed, 94 insertions(+), 41 deletions(-) create mode 100644 .github/workflows/release-internal.yml create mode 100644 CHANGELOG.md create mode 100644 CODEOWNERS diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 517cc299..447ff2b5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,8 +25,6 @@ jobs: with: dotnet-version: '6.0.x' include-prerelease: true - - name: Add Nuget source Lego - run: dotnet nuget add source --username USERNAME --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/lego/index.json" - name: Restore dependencies run: dotnet restore - name: Build diff --git a/.github/workflows/release-internal.yml b/.github/workflows/release-internal.yml new file mode 100644 index 00000000..8b54315b --- /dev/null +++ b/.github/workflows/release-internal.yml @@ -0,0 +1,35 @@ +name: Publish internal NuGet package +on: + push: + branches: [ main ] + paths: + - 'src/LEGO.AsyncAPI/**' + - 'src/LEGO.AsyncAPI.Readers/**' + - 'src/LEGO.AsyncAPI.Writers/**' + - ".github/workflows/release-package.yml" + - '!**/*.md' + workflow_dispatch: + +jobs: + release: + runs-on: ubuntu-latest + name: Publish NuGet packages + strategy: + matrix: + package-name: [ "LEGO.AsyncAPI", "LEGO.AsyncAPI.Readers"] + steps: + - name: Checkout repository + uses: actions/checkout@v1 + + - name: Setup .NET Core @ Latest + uses: actions/setup-dotnet@v1 + with: + source-url: https://nuget.pkg.github.com/LEGO/index.json + env: + NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} + + - name: Build ${{ matrix.package-name }} project and pack NuGet package + run: dotnet pack src/${{ matrix.package-name }}/${{ matrix.package-name }}.csproj -c Release -o out-${{ matrix.package-name }} -p:PackageVersion=0.2.$GITHUB_RUN_NUMBER.0-prerelease + + - name: Push generated package to GitHub Packages registry + run: dotnet nuget push out-${{ matrix.package-name }}/*.nupkg --skip-duplicate -n --api-key ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/release-package.yml b/.github/workflows/release-package.yml index 1f55a173..0f064176 100644 --- a/.github/workflows/release-package.yml +++ b/.github/workflows/release-package.yml @@ -1,56 +1,74 @@ -name: Publish a NuGet package +name: Publish NuGet package on: -# push: -# branches: [ main ] -# paths: -# - 'src/LEGO.AsyncAPI/**' -# - 'src/LEGO.AsyncAPI.Readers/**' -# - ".github/workflows/release-package.yml" -# - '!**/*.md' workflow_dispatch: jobs: + prereleaseCheck: + runs-on: ubuntu-latest + environment: AsyncAPI + name: Check release + steps: + - name: Checkout repository + uses: actions/checkout@v1 + + - name: Semantic Release + uses: cycjimmy/semantic-release-action@v3 + id: semantic + with: + extra_plugins: | + conventional-changelog-conventionalcommits + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Get token + if: steps.semantic.outputs.new_release_published == 'true' + id: get_token + uses: peter-murray/workflow-application-token-action@v2.1.0 + with: + application_id: ${{ secrets.APPLICATION_ID }} + application_private_key: ${{ secrets.APPLICATION_PRIVATE_KEY }} + + - name: Commit changes + if: steps.semantic.outputs.new_release_published == 'true' + env: + GITHUB_TOKEN: ${{ steps.get_token.outputs.token }} + FILE_TO_COMMIT: CHANGELOG.md + DESTINATION_BRANCH: ${{ github.ref }} + run: | + export MESSAGE="chore: update $FILE_TO_COMMIT" + export SHA=$( git rev-parse $DESTINATION_BRANCH:$FILE_TO_COMMIT ) + export CONTENT=$( base64 -i $FILE_TO_COMMIT ) + gh api --method PUT /repos/:owner/:repo/contents/$FILE_TO_COMMIT \ + --field message="$MESSAGE" \ + --field content="$CONTENT" \ + --field encoding="base64" \ + --field branch="$DESTINATION_BRANCH" \ + --field sha="$SHA" + + outputs: + trigger_release: ${{ steps.semantic.outputs.new_release_published }} + version: ${{ steps.semantic.outputs.new_release_published == 'true' && steps.semantic.outputs.new_release_version }} + release: runs-on: ubuntu-latest name: Publish NuGet packages + needs: prereleaseCheck + environment: AsyncAPI strategy: matrix: - package-name: [ "LEGO.AsyncAPI", "LEGO.AsyncAPI.Readers"] + package-name: [ "LEGO.AsyncAPI", "LEGO.AsyncAPI.Readers" ] steps: - name: Checkout repository uses: actions/checkout@v1 - - name: Semantic Release - uses: cycjimmy/semantic-release-action@v3 - id: semantic # Need an `id` for output variables - with: - extra_plugins: | - conventional-changelog-conventionalcommits - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Setup .NET Core @ Latest + if: needs.prereleaseCheck.outputs.trigger_release == 'true' uses: actions/setup-dotnet@v1 - with: - source-url: https://nuget.pkg.github.com/LEGO/index.json - env: - NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} - name: Build ${{ matrix.package-name }} project and pack NuGet package - if: steps.semantic.outputs.new_release_published == 'true' - run: dotnet pack src/${{ matrix.package-name }}/${{ matrix.package-name }}.csproj -c Release -o out-${{ matrix.package-name }} -p:PackageVersion=${{ steps.semantic.outputs.new_release_version }}-prerelease + if: needs.prereleaseCheck.outputs.trigger_release == 'true' + run: dotnet pack src/${{ matrix.package-name }}/${{ matrix.package-name }}.csproj -c Release -o out-${{ matrix.package-name }} -p:PackageVersion=${{ needs.prereleaseCheck.outputs.version }} - name: Push generated package to GitHub Packages registry - if: steps.semantic.outputs.new_release_published == 'true' - run: dotnet nuget push out-${{ matrix.package-name }}/*.nupkg --skip-duplicate -n --api-key ${{secrets.GITHUB_TOKEN}} - - - name: Create Pull Request - if: steps.semantic.outputs.new_release_published == 'true' - id: pr - uses: peter-evans/create-pull-request@v4 - with: - token: ${{ secrets.GITHUB_TOKEN }} - title: 'chore: update Changelog' - base: main - add-paths: | - CHANGELOG.md + if: needs.prereleaseCheck.outputs.trigger_release == 'true' + run: dotnet nuget push out-${{ matrix.package-name }}/*.nupkg -s https://api.nuget.org/v3/index.json --skip-duplicate -n --api-key ${{secrets.NUGET}} diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1 @@ + diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 00000000..f1759cb1 --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1 @@ +* @VisualBean diff --git a/src/LEGO.AsyncAPI.Readers/LEGO.AsyncAPI.Readers.csproj b/src/LEGO.AsyncAPI.Readers/LEGO.AsyncAPI.Readers.csproj index ddf544ed..3b7e1e2c 100644 --- a/src/LEGO.AsyncAPI.Readers/LEGO.AsyncAPI.Readers.csproj +++ b/src/LEGO.AsyncAPI.Readers/LEGO.AsyncAPI.Readers.csproj @@ -4,11 +4,11 @@ net6.0 disable disable + The LEGO Group https://github.com/LEGO/AsyncAPI.NET AsyncAPI.NET Readers for JSON and YAML documents AsyncAPI .NET LEGO.AsyncAPI.Readers - 1.0.0 LEGO.AsyncAPI.Readers LEGO.AsyncAPI.Readers https://github.com/LEGO/AsyncAPI.NET diff --git a/src/LEGO.AsyncAPI/LEGO.AsyncAPI.csproj b/src/LEGO.AsyncAPI/LEGO.AsyncAPI.csproj index 188dda85..8fce8475 100644 --- a/src/LEGO.AsyncAPI/LEGO.AsyncAPI.csproj +++ b/src/LEGO.AsyncAPI/LEGO.AsyncAPI.csproj @@ -3,11 +3,11 @@ net6.0 disable + The LEGO Group https://github.com/LEGO/AsyncAPI.NET AsyncAPI.NET models AsyncAPI .NET LEGO.AsyncAPI - 1.0.0 LEGO.AsyncAPI LEGO.AsyncAPI https://github.com/LEGO/AsyncAPI.NET