From e438464dc6c55d9e08ac6151d079e93b338f9bc1 Mon Sep 17 00:00:00 2001 From: Preben Huybrechts Date: Tue, 1 Oct 2024 12:24:47 +0200 Subject: [PATCH] Release pipeline --- .github/workflows/release.yml | 66 ++++++++++++++++++++++++++++++++++ src/ApimSanitizer.csproj | 4 +-- src/Properties/AssemblyInfo.cs | 7 ++++ 3 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 src/Properties/AssemblyInfo.cs diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..3f78c55 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,66 @@ +name: Create Release + +on: + push: + tags: + - 'v*' # This workflow runs when a tag is pushed that starts with 'v' + +jobs: + release: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + + - name: Set up Git for tagging + run: | + git config user.name "github-actions" + git config user.email "github-actions@github.com" + + - name: Extract version from tag + id: get_version + run: | + echo "##[set-output name=version;]${GITHUB_REF##*/}" + + - name: Update Assembly and NuGet package version + run: | + version=${{ steps.get_version.outputs.version }} + echo "Updating Assembly and NuGet package versions to ${version}" + sed -i "s/.*<\/VersionPrefix>/${version}<\/VersionPrefix>/g" ./src/ApimSanitizer.csproj + sed -i "s/\[assembly: AssemblyVersion(\".*\"\]/[assembly: AssemblyVersion(\"${version}\")]/g" ./src/Properties/AssemblyInfo.cs + sed -i "s/\[assembly: AssemblyFileVersion(\".*\"\]/[assembly: AssemblyFileVersion(\"${version}\")]/g" ./src/Properties/AssemblyInfo.cs + + - name: Build the project + run: dotnet build --configuration Release + + - name: Pack the NuGet package + run: dotnet pack --configuration Release --output ./artifacts + + - name: Upload build artifacts + uses: actions/upload-artifact@v3 + with: + name: nuget-package + path: ./artifacts/*.nupkg + + - name: Create GitHub Release + uses: actions/create-release@v1 + with: + tag_name: ${{ steps.get_version.outputs.version }} + release_name: Release ${{ steps.get_version.outputs.version }} + body: | + Release version ${{ steps.get_version.outputs.version }}. + draft: false + prerelease: false + files: ./artifacts/*.nupkg + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # - name: Push NuGet package to nuget.org + # run: dotnet nuget push ./artifacts/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json + + - name: Push NuGet package to GitHub packages + run: dotnet nuget push ./artifacts/*.nupkg --api-key ${{ secrets.GITHUB_TOKEN }} --source https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json \ No newline at end of file diff --git a/src/ApimSanitizer.csproj b/src/ApimSanitizer.csproj index 5cc2c7c..4eebfcd 100644 --- a/src/ApimSanitizer.csproj +++ b/src/ApimSanitizer.csproj @@ -10,14 +10,14 @@ - apimsanitizer + dotnet-apimsanitizer Pregress Sanitize open api defintion files to import them into Azure APIM. azure;apim;tool GlobalTool.md https://github.com/pregress/ApimSanitizer/blob/main/Documentation/Changelog.md https://github.com/pregress/ApimSanitizer/blob/main/_assets/icon.png - icon.png + coverlet-icon.png https://github.com/pregress/ApimSanitizer MIT git diff --git a/src/Properties/AssemblyInfo.cs b/src/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..40921d8 --- /dev/null +++ b/src/Properties/AssemblyInfo.cs @@ -0,0 +1,7 @@ +using System.Reflection; +using System.Runtime.InteropServices; + + +[assembly: ComVisible(false)] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")]