Skip to content

Commit 5cc659f

Browse files
committed
Add CI/CD workflow and NuGet packaging configuration
- Add GitHub Actions workflow for build, test, and release - Configure NuGet package metadata in project file - Add CHANGELOG.md for version tracking - Add NuGet setup documentation - Workflow publishes to NuGet on version tags (v*)
1 parent 4b63514 commit 5cc659f

4 files changed

Lines changed: 230 additions & 5 deletions

File tree

.github/workflows/ci-cd.yml

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
name: CI/CD
2+
3+
on:
4+
push:
5+
branches: [ master, main ]
6+
tags:
7+
- 'v*'
8+
pull_request:
9+
branches: [ master, main ]
10+
workflow_dispatch:
11+
12+
env:
13+
DOTNET_VERSION: '9.0.x'
14+
CONFIGURATION: Release
15+
16+
jobs:
17+
build-and-test:
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Setup .NET
24+
uses: actions/setup-dotnet@v4
25+
with:
26+
dotnet-version: ${{ env.DOTNET_VERSION }}
27+
28+
- name: Restore dependencies
29+
run: dotnet restore
30+
31+
- name: Build
32+
run: dotnet build --no-restore --configuration ${{ env.CONFIGURATION }}
33+
34+
- name: Test
35+
run: dotnet test --no-build --configuration ${{ env.CONFIGURATION }} --verbosity normal --collect:"XPlat Code Coverage" --logger:trx
36+
37+
- name: Upload test results
38+
uses: actions/upload-artifact@v4
39+
if: always()
40+
with:
41+
name: test-results
42+
path: |
43+
**/*.trx
44+
**/coverage.cobertura.xml
45+
46+
- name: Pack
47+
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
48+
run: dotnet pack MathFlow.Core/MathFlow.Core.csproj --no-build --configuration ${{ env.CONFIGURATION }} --output nupkgs
49+
50+
- name: Upload NuGet package
51+
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: nuget-package
55+
path: nupkgs/*.nupkg
56+
57+
publish-nuget:
58+
needs: build-and-test
59+
runs-on: ubuntu-latest
60+
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
61+
62+
steps:
63+
- name: Setup .NET
64+
uses: actions/setup-dotnet@v4
65+
with:
66+
dotnet-version: ${{ env.DOTNET_VERSION }}
67+
68+
- name: Download NuGet package
69+
uses: actions/download-artifact@v4
70+
with:
71+
name: nuget-package
72+
path: nupkgs
73+
74+
- name: Publish to NuGet.org
75+
run: |
76+
for package in nupkgs/*.nupkg; do
77+
dotnet nuget push "$package" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
78+
done
79+
env:
80+
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
81+
82+
create-release:
83+
needs: build-and-test
84+
runs-on: ubuntu-latest
85+
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
86+
87+
permissions:
88+
contents: write
89+
90+
steps:
91+
- uses: actions/checkout@v4
92+
93+
- name: Download NuGet package
94+
uses: actions/download-artifact@v4
95+
with:
96+
name: nuget-package
97+
path: nupkgs
98+
99+
- name: Extract version from tag
100+
id: get_version
101+
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
102+
103+
- name: Create Release
104+
uses: actions/create-release@v1
105+
env:
106+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
107+
with:
108+
tag_name: ${{ github.ref }}
109+
release_name: Release v${{ steps.get_version.outputs.VERSION }}
110+
body: |
111+
## MathFlow v${{ steps.get_version.outputs.VERSION }}
112+
113+
### Installation
114+
```bash
115+
dotnet add package MathFlow --version ${{ steps.get_version.outputs.VERSION }}
116+
```
117+
118+
### Changes
119+
See [CHANGELOG.md](https://github.com/${{ github.repository }}/blob/master/CHANGELOG.md) for details.
120+
121+
### NuGet Package
122+
https://www.nuget.org/packages/MathFlow/${{ steps.get_version.outputs.VERSION }}
123+
draft: false
124+
prerelease: false
125+
126+
- name: Upload Release Asset
127+
uses: actions/upload-release-asset@v1
128+
env:
129+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
130+
with:
131+
upload_url: ${{ steps.create_release.outputs.upload_url }}
132+
asset_path: ./nupkgs/MathFlow.${{ steps.get_version.outputs.VERSION }}.nupkg
133+
asset_name: MathFlow.${{ steps.get_version.outputs.VERSION }}.nupkg
134+
asset_content_type: application/zip

CHANGELOG.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Changelog
2+
3+
All notable changes to MathFlow will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [1.0.0] - 2025-08-26
9+
10+
### Added
11+
- Initial release of MathFlow
12+
- Mathematical expression parsing and evaluation
13+
- Support for variables and custom functions
14+
- Symbolic differentiation
15+
- Expression simplification and expansion
16+
- Numerical integration (Simpson's, Trapezoidal, Gauss-Legendre)
17+
- Equation solving (Newton-Raphson, Bisection, Secant, Brent)
18+
- Complex number arithmetic
19+
- Vector operations (dot product, cross product, normalization)
20+
- Statistical functions (mean, median, variance, correlation, linear regression)
21+
- LaTeX and MathML output formats
22+
- Comprehensive test suite with 50+ tests
23+
- Full documentation and examples
24+
25+
### Features
26+
- Parse mathematical expressions from strings
27+
- Evaluate expressions with variables
28+
- Standard math operations: +, -, *, /, ^, %
29+
- Trigonometric functions: sin, cos, tan, asin, acos, atan, sinh, cosh, tanh
30+
- Other functions: exp, ln, log10, sqrt, abs, floor, ceil, round, sign, min, max, factorial
31+
- Mathematical constants: pi, e, tau (2*pi), phi (golden ratio)
32+
33+
[1.0.0]: https://github.com/Nonanti/MathFlow/releases/tag/v1.0.0

MathFlow.Core/MathFlow.Core.csproj

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,26 @@
77
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
88
<PackageId>MathFlow</PackageId>
99
<Version>1.0.0</Version>
10-
<Authors>MathFlow Contributors</Authors>
11-
<Description>A powerful and intuitive mathematical expression library for C# with symbolic computation</Description>
10+
<Authors>Nonanti</Authors>
11+
<Description>C# math expression library with symbolic computation support. Parse, evaluate, differentiate, simplify mathematical expressions.</Description>
1212
<PackageLicenseExpression>MIT</PackageLicenseExpression>
13-
<PackageProjectUrl>https://github.com/yourusername/MathFlow</PackageProjectUrl>
14-
<RepositoryUrl>https://github.com/yourusername/MathFlow</RepositoryUrl>
15-
<PackageTags>math;expression;parser;symbolic;calculus;algebra;mathflow</PackageTags>
13+
<PackageProjectUrl>https://github.com/Nonanti/MathFlow</PackageProjectUrl>
14+
<RepositoryUrl>https://github.com/Nonanti/MathFlow</RepositoryUrl>
15+
<RepositoryType>git</RepositoryType>
16+
<PackageTags>math;expression;parser;symbolic;calculus;algebra;derivative;integration;equation;solver;simplify;latex;mathml</PackageTags>
1617
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1718
<NoWarn>$(NoWarn);CS1591</NoWarn>
19+
<PackageReadmeFile>README.md</PackageReadmeFile>
20+
<PackageIcon>icon.png</PackageIcon>
21+
<Copyright>Copyright (c) 2025 Nonanti</Copyright>
22+
<PackageReleaseNotes>Initial release with core mathematical functionality</PackageReleaseNotes>
23+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
24+
<IncludeSymbols>true</IncludeSymbols>
25+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
1826
</PropertyGroup>
27+
28+
<ItemGroup>
29+
<None Include="../README.md" Pack="true" PackagePath="\" />
30+
</ItemGroup>
1931

2032
</Project>

NUGET_SETUP.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# NuGet Setup Instructions
2+
3+
To enable automatic NuGet package publishing, you need to set up a GitHub secret with your NuGet API key.
4+
5+
## Steps:
6+
7+
1. **Get your NuGet API Key:**
8+
- Go to https://www.nuget.org/account/apikeys
9+
- Sign in with your account
10+
- Click "Create" to create a new API key
11+
- Name it (e.g., "MathFlow GitHub Actions")
12+
- Select "Push" scope
13+
- Select "MathFlow" package or use glob pattern "MathFlow*"
14+
- Copy the generated key
15+
16+
2. **Add the API Key to GitHub Secrets:**
17+
- Go to your repository: https://github.com/Nonanti/MathFlow
18+
- Click on "Settings" tab
19+
- Go to "Secrets and variables" → "Actions"
20+
- Click "New repository secret"
21+
- Name: `NUGET_API_KEY`
22+
- Value: [Paste your NuGet API key]
23+
- Click "Add secret"
24+
25+
3. **How to publish a new version:**
26+
- Update the version in `MathFlow.Core/MathFlow.Core.csproj`
27+
- Update CHANGELOG.md with the new version details
28+
- Commit and push your changes
29+
- Create a new tag: `git tag v1.0.1` (replace with your version)
30+
- Push the tag: `git push origin v1.0.1`
31+
- The GitHub Action will automatically build, test, and publish to NuGet
32+
33+
## Manual Publishing (if needed):
34+
35+
```bash
36+
# Pack the project
37+
dotnet pack MathFlow.Core/MathFlow.Core.csproj -c Release
38+
39+
# Push to NuGet
40+
dotnet nuget push MathFlow.Core/bin/Release/MathFlow.1.0.0.nupkg --api-key YOUR_API_KEY --source https://api.nuget.org/v3/index.json
41+
```
42+
43+
## Testing the workflow:
44+
45+
You can test the build and test parts of the workflow by pushing to master.
46+
The NuGet publishing only happens when you push a version tag (v*).

0 commit comments

Comments
 (0)