Skip to content

Commit

Permalink
ci: nuget publishing
Browse files Browse the repository at this point in the history
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
  • Loading branch information
VisualBean committed Feb 7, 2023
1 parent 04e8af8 commit 7ddecb8
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 41 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/release-internal.yml
Original file line number Diff line number Diff line change
@@ -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}}
92 changes: 55 additions & 37 deletions .github/workflows/release-package.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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}}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @VisualBean
2 changes: 1 addition & 1 deletion src/LEGO.AsyncAPI.Readers/LEGO.AsyncAPI.Readers.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>disable</Nullable>
<Company>The LEGO Group</Company>
<PackageProjectUrl>https://github.com/LEGO/AsyncAPI.NET</PackageProjectUrl>
<Description>AsyncAPI.NET Readers for JSON and YAML documents</Description>
<PackageTags>AsyncAPI .NET</PackageTags>
<PackageId>LEGO.AsyncAPI.Readers</PackageId>
<Version>1.0.0</Version>
<AssemblyName>LEGO.AsyncAPI.Readers</AssemblyName>
<RootNamespace>LEGO.AsyncAPI.Readers</RootNamespace>
<RepositoryUrl>https://github.com/LEGO/AsyncAPI.NET</RepositoryUrl>
Expand Down
2 changes: 1 addition & 1 deletion src/LEGO.AsyncAPI/LEGO.AsyncAPI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Company>The LEGO Group</Company>
<PackageProjectUrl>https://github.com/LEGO/AsyncAPI.NET</PackageProjectUrl>
<Description>AsyncAPI.NET models</Description>
<PackageTags>AsyncAPI .NET</PackageTags>
<PackageId>LEGO.AsyncAPI</PackageId>
<Version>1.0.0</Version>
<AssemblyName>LEGO.AsyncAPI</AssemblyName>
<RootNamespace>LEGO.AsyncAPI</RootNamespace>
<RepositoryUrl>https://github.com/LEGO/AsyncAPI.NET</RepositoryUrl>
Expand Down

0 comments on commit 7ddecb8

Please sign in to comment.