Skip to content

Commit

Permalink
INFRA: Update build action to support tagging, release and publish to…
Browse files Browse the repository at this point in the history
… NuGet
  • Loading branch information
cjdutoit committed Feb 20, 2024
1 parent 13ba02c commit b5f0972
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 6 deletions.
101 changes: 101 additions & 0 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,104 @@ jobs:
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal
add_tag:
runs-on: ubuntu-latest
needs:
- build
if: >-
needs.build.result == 'success' &&
github.event.pull_request.merged &&
github.event.pull_request.base.ref == 'main' &&
startsWith(github.event.pull_request.title, 'RELEASES:') &&
contains(github.event.pull_request.labels.*.name, 'RELEASES')
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
token: ${{ secrets.PAT_FOR_TAGGING }}
- name: Configure Git
run: >-
git config user.name "GitHub Action"
git config user.email "[email protected]"
- name: Extract Version
id: extract_version
run: >
# Running on Linux/Unix
sudo apt-get install xmlstarlet
version_number=$(xmlstarlet sel -t -v "//Version" -n STX.EFxceptions.SQLite/STX.EFxceptions.SQLite.csproj)
echo "$version_number"
echo "version_number<<EOF" >> $GITHUB_OUTPUT
echo "$version_number" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
shell: bash
- name: Display Version
run: 'echo "Version number: ${{ steps.extract_version.outputs.version_number }}"'
- name: Extract Package Release Notes
id: extract_package_release_notes
run: >
# Running on Linux/Unix
sudo apt-get install xmlstarlet
package_release_notes=$(xmlstarlet sel -t -v "//PackageReleaseNotes" -n STX.EFxceptions.SQLite/STX.EFxceptions.SQLite.csproj)
echo "$package_release_notes"
echo "package_release_notes<<EOF" >> $GITHUB_OUTPUT
echo "$package_release_notes" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
shell: bash
- name: Display Package Release Notes
run: 'echo "Package Release Notes: ${{ steps.extract_package_release_notes.outputs.package_release_notes }}"'
- name: Create GitHub Tag
run: >-
git tag -a "v${{ steps.extract_version.outputs.version_number }}" -m "Release - v${{ steps.extract_version.outputs.version_number }}"
git push origin --tags
- name: Create GitHub Release
uses: actions/create-release@v1
with:
tag_name: v${{ steps.extract_version.outputs.version_number }}
release_name: Release - v${{ steps.extract_version.outputs.version_number }}
body: >-
## Release - v${{ steps.extract_version.outputs.version_number }}
### Release Notes
${{ steps.extract_package_release_notes.outputs.package_release_notes }}
env:
GITHUB_TOKEN: ${{ secrets.PAT_FOR_TAGGING }}
publish:
runs-on: ubuntu-latest
needs:
- add_tag
if: needs.add_tag.result == 'success'
steps:
- name: Check out
uses: actions/checkout@v3
- name: Setup .Net
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.201
- name: Restore
run: dotnet restore
- name: Build
run: dotnet build --no-restore --configuration Release
- name: Pack NuGet Package
run: dotnet pack --configuration Release --include-symbols
- name: Push NuGet Package
run: dotnet nuget push **/bin/Release/**/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_ACCESS }} --skip-duplicate
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<Description>A Standardized .NET library for SQLite that implements AspNetCore.Identity, that captures the exceptions thrown by EntityFramework and converts them into meaningful exceptions...</Description>
<Copyright>The Standard Community 2024 (c)</Copyright>
<PackageIcon>EFxceptions.png</PackageIcon>
<PackageProjectUrl>https://github.com/The-Standard-Organization/STX.EFxceptions</PackageProjectUrl>
<RepositoryUrl>https://github.com/The-Standard-Organization/STX.EFxceptions</RepositoryUrl>
<PackageProjectUrl>https://github.com/The-Standard-Organization/STX.EFxceptions.SQLite</PackageProjectUrl>
<RepositoryUrl>https://github.com/The-Standard-Organization/STX.EFxceptions.SQLite</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>.NET; EF; Entity Framework; Exceptions; SQLite; The Standard</PackageTags>
<PackageReleaseNotes>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<Description>A Standardized .NET library that provides core functionality that is used by the SQLite implementations of EFxceptions</Description>
<Copyright>The Standard Community 2024 (c)</Copyright>
<PackageIcon>EFxceptions.png</PackageIcon>
<PackageProjectUrl>https://github.com/The-Standard-Organization/STX.EFxceptions</PackageProjectUrl>
<RepositoryUrl>https://github.com/The-Standard-Organization/STX.EFxceptions</RepositoryUrl>
<PackageProjectUrl>https://github.com/The-Standard-Organization/STX.EFxceptions.SQLite</PackageProjectUrl>
<RepositoryUrl>https://github.com/The-Standard-Organization/STX.EFxceptions.SQLite</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>.NET; EF; Entity Framework; Exceptions; SQLite; The Standard</PackageTags>
<PackageReleaseNotes>
Expand Down
16 changes: 16 additions & 0 deletions STX.EFxceptions.SQLite.Infrastructure.Build/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,22 @@ static void Main(string[] args)
}
}
}
},
{
"add_tag",
new TagJob(
runsOn: BuildMachines.UbuntuLatest,
dependsOn: "build",
projectRelativePath: "STX.EFxceptions.SQLite/STX.EFxceptions.SQLite.csproj",
githubToken: "${{ secrets.PAT_FOR_TAGGING }}",
branchName: branchName)
},
{
"publish",
new PublishJob(
runsOn: BuildMachines.UbuntuLatest,
dependsOn: "add_tag",
nugetApiKey: "${{ secrets.NUGET_ACCESS }}")
}
}
};
Expand Down
4 changes: 2 additions & 2 deletions STX.EFxceptions.SQLite/STX.EFxceptions.SQLite.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<Description>A Standardized .NET library for SQLite that captures the exceptions thrown by EntityFramework and converts them into meaningful exceptions...</Description>
<Copyright>The Standard Community 2024 (c)</Copyright>
<PackageIcon>EFxceptions.png</PackageIcon>
<PackageProjectUrl>https://github.com/The-Standard-Organization/STX.EFxceptions</PackageProjectUrl>
<RepositoryUrl>https://github.com/The-Standard-Organization/STX.EFxceptions</RepositoryUrl>
<PackageProjectUrl>https://github.com/The-Standard-Organization/STX.EFxceptions.SQLite</PackageProjectUrl>
<RepositoryUrl>https://github.com/The-Standard-Organization/STX.EFxceptions.SQLite</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>.NET; EF; Entity Framework; Exceptions; SQLite; The Standard</PackageTags>
<PackageReleaseNotes>
Expand Down

0 comments on commit b5f0972

Please sign in to comment.