Skip to content

Commit 750a14c

Browse files
authored
Build nuget packages for each published GitHub release (#56)
1 parent 88aa018 commit 750a14c

File tree

3 files changed

+103
-4
lines changed

3 files changed

+103
-4
lines changed

.github/workflows/release.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
8+
workflow_dispatch:
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
env:
14+
FSPROJ: "src\\ExcelFinancialFunctions\\ExcelFinancialFunctions.fsproj"
15+
steps:
16+
- uses: actions/checkout@v2
17+
- name: Setup .NET
18+
uses: actions/setup-dotnet@v1
19+
with:
20+
dotnet-version: 5.0.x
21+
- name: Restore dependencies
22+
run: dotnet restore $FSPROJ
23+
- name: Build Release
24+
run: dotnet build $FSPROJ /p:Configuration=Release --no-restore --verbosity normal
25+
- name: Create NuGet package
26+
run: dotnet pack $FSPROJ /p:Configuration=Release /p:GitVersion=${GITHUB_REF#refs/tags/} /p:ReleaseNotes="${{ github.event.release.body }}" --no-build --verbosity normal
27+
- name: Publish package to NuGet Gallery (if this version not published before)
28+
run: dotnet nuget push **\*.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_ORG_TOKEN }} --skip-duplicate

PackageReadmeFile.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Excel Financial Functions
2+
3+
This is a .NET Standard library that provides the full set of financial functions from Excel. The main goal for the library is compatibility with Excel, by providing the same functions, with the same behaviour. Note though that this is not a wrapper over the Excel library; the functions have been re-implemented in managed code so that you do not need to have Excel installed to use this library.
4+
5+
[![NuGet Badge](https://img.shields.io/nuget/v/ExcelFinancialFunctions.svg?style=flat)](https://www.nuget.org/packages/ExcelFinancialFunctions/)
6+
[![Build and Test](https://github.com/fsprojects/ExcelFinancialFunctions/actions/workflows/dotnet.yml/badge.svg)](https://github.com/fsprojects/ExcelFinancialFunctions/actions/workflows/dotnet.yml)
7+
8+
## Goal: Match Excel
9+
10+
We replicate the results Excel would produce in every situation,
11+
even in cases where we might disagree with Excel\'s approach. Please have a look at the [Compatibility](http://fsprojects.github.io/ExcelFinancialFunctions/compatibility.html) page for more detail on this topic.
12+
13+
Microsoft\'s official documentation on [Excel Functions](https://support.microsoft.com/en-us/office/excel-functions-by-category-5f91f4e9-7b42-46d2-9bd1-63f26a86c0eb) is the best place to learn more about how the functions should work. The scope for this library is the full set of functions in the "Financial Functions" category.
14+
15+
### Thoroughly tested
16+
17+
As of last count, the library is validated against 199,252 test cases.
18+
19+
* [ExcelFinancialFunctions.Tests](./tests/ExcelFinancialFunctions.Tests): Unit tests checking against previously-determined truth values from Excel 2010. Inputs and expected outputs are read from data files.
20+
* [ExcelFinancialFunctions.ConsoleTests](./tests/ExcelFinancialFunctions.ConsoleTests): Test cases comparing the library results directly to running Excel code via interop. These should be run on a Windows machine with Excel 2013 (or later) installed.
21+
22+
### You can help!
23+
24+
Found a discrepency? [Open an Issue](https://github.com/fsprojects/ExcelFinancialFunctions/issues)! Or better yet, a [Pull Request](https://github.com/fsprojects/ExcelFinancialFunctions/pulls).
25+
26+
## Adding it to your project
27+
28+
Excel Financial Functions is a .NET Standard 2.0 library, which you can add to any project
29+
based on a .NET implementation which [supports the standard](https://docs.microsoft.com/en-us/dotnet/standard/net-standard). This includes .NET Framework 4.6.1 or later, and .NET Core 2.0 or later.
30+
31+
Simply add it from NuGet in the usual way:
32+
33+
```
34+
PS> dotnet add package ExcelFinancialFunctions
35+
36+
Determining projects to restore...
37+
info : Adding PackageReference for package 'ExcelFinancialFunctions' into project
38+
info : GET https://api.nuget.org/v3/registration5-gz-semver2/excelfinancialfunctions/index.json
39+
info : OK https://api.nuget.org/v3/registration5-gz-semver2/excelfinancialfunctions/index.json 69ms
40+
info : Restoring packages for project.csproj...
41+
info : PackageReference for package 'ExcelFinancialFunctions' version '2.4.1' added to file 'project.csproj'.
42+
info : Committing restore...
43+
log : Restored project.csproj (in 72 ms).
44+
```
45+
46+
## Using it
47+
48+
Even though the libary is written in F#, you can use it from any .NET language, including C#. The functions are provided as static methods on a Financial class in the Excel.FinancialFunctions namespace.
49+
50+
``` c#
51+
using Excel.FinancialFunctions;
52+
53+
Console.WriteLine( Financial.IPmt(rate: 0.005, per: 53, nper: 360, pv: 500000, fv: 0, typ: PaymentDue.EndOfPeriod) );
54+
// Displays -796.3747578439793
55+
56+
Console.WriteLine( Financial.Pmt(rate: 0.005, nper: 360, pv: 500000, fv: 0, typ: PaymentDue.EndOfPeriod) );
57+
// Displays -1687.7136560969248
58+
```
59+
60+
Or from F#:
61+
62+
```F#
63+
open Excel.FinancialFunctions
64+
65+
printfn "%f" <| Financial.IPmt (0.005, 53., 180., 200000., 0., PaymentDue.EndOfPeriod)
66+
// Displays -796.374758
67+
68+
printfn "%f" <| Financial.Pmt (0.005, 180., 200000., 0., PaymentDue.EndOfPeriod)
69+
// Displays -1687.713656
70+
```

src/ExcelFinancialFunctions/ExcelFinancialFunctions.fsproj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
55
<GenerateDocumentationFile>true</GenerateDocumentationFile>
6-
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
6+
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
77
<WarnOn>3390;$(WarnOn)</WarnOn>
88
<Title>ExcelFinancialFunctions</Title>
99
<AssemblyTitle>ExcelFinancialFunctions</AssemblyTitle>
@@ -13,9 +13,9 @@
1313
<RepositoryUrl>https://github.com/fsprojects/ExcelFinancialFunctions</RepositoryUrl>
1414
<RepositoryType>git</RepositoryType>
1515
<PackageId>ExcelFinancialFunctions</PackageId>
16-
<PackageVersion>2.4.1</PackageVersion>
17-
<FileVersion>2.4.1</FileVersion>
18-
<AssemblyVersion>2.4.1</AssemblyVersion>
16+
<Version>$(GitVersion)</Version>
17+
<PackageReleaseNotes>$(ReleaseNotes)</PackageReleaseNotes>
18+
<PackageReadmeFile>PackageReadmeFile.md</PackageReadmeFile>
1919
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
2020
<FsDocsLicenseLink>https://github.com/fsprojects/ExcelFinancialFunctions/blob/master/LICENSE.txt</FsDocsLicenseLink>
2121
<PackageIcon>logo.png</PackageIcon>
@@ -38,6 +38,7 @@
3838
<Compile Include="testpreconditions.fs" />
3939
<Compile Include="wrapperdotnettype.fs" />
4040
<None Include="..\..\docs\img\logo.png" Pack="true" PackagePath="\"/>
41+
<None Include="..\..\PackageReadmeFile.md" Pack="true" PackagePath="\"/>
4142
</ItemGroup>
4243

4344
</Project>

0 commit comments

Comments
 (0)