Skip to content

Commit

Permalink
Merge pull request #1 from pregress/release-action
Browse files Browse the repository at this point in the history
Release pipeline
  • Loading branch information
pregress authored Oct 1, 2024
2 parents f82abb1 + e438464 commit d3648f6
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 2 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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 "[email protected]"
- 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>.*<\/VersionPrefix>/<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
4 changes: 2 additions & 2 deletions src/ApimSanitizer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
</PropertyGroup>

<PropertyGroup>
<PackageId>apimsanitizer</PackageId>
<PackageId>dotnet-apimsanitizer</PackageId>
<Authors>Pregress</Authors>
<Description>Sanitize open api defintion files to import them into Azure APIM.</Description>
<PackageTags>azure;apim;tool</PackageTags>
<PackageReadmeFile>GlobalTool.md</PackageReadmeFile>
<PackageReleaseNotes>https://github.com/pregress/ApimSanitizer/blob/main/Documentation/Changelog.md</PackageReleaseNotes>
<PackageIconUrl>https://github.com/pregress/ApimSanitizer/blob/main/_assets/icon.png</PackageIconUrl>
<PackageIcon>icon.png</PackageIcon>
<PackageIcon>coverlet-icon.png</PackageIcon>
<PackageProjectUrl>https://github.com/pregress/ApimSanitizer</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryType>git</RepositoryType>
Expand Down
7 changes: 7 additions & 0 deletions src/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -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")]

0 comments on commit d3648f6

Please sign in to comment.