Skip to content

Commit efa50c7

Browse files
committed
init 0.2.0
1 parent 0105795 commit efa50c7

2 files changed

Lines changed: 126 additions & 0 deletions

File tree

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: NuGet Publish
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
paths:
7+
- '**/*.fs'
8+
- '**/*.fsproj'
9+
- '**/*.sln'
10+
- '.github/workflows/nuget-publish.yml'
11+
release:
12+
types: [ published ]
13+
workflow_dispatch:
14+
inputs:
15+
version:
16+
description: 'Version to publish (e.g., 0.2.0). If empty on dispatch, publish is skipped.'
17+
required: false
18+
19+
jobs:
20+
publish:
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v4
26+
27+
- name: Setup .NET SDKs
28+
uses: actions/setup-dotnet@v4
29+
with:
30+
dotnet-version: |
31+
8.0.x
32+
9.0.x
33+
cache: true
34+
35+
- name: Restore dependencies
36+
run: dotnet restore ancpdevkit.sln
37+
38+
- name: Build solution
39+
run: dotnet build ancpdevkit.sln --configuration Release --no-restore
40+
41+
- name: Run tests
42+
run: dotnet test ancpdevkit.sln --configuration Release --no-build --verbosity normal
43+
44+
- name: Determine package version
45+
id: version
46+
run: |
47+
set -euo pipefail
48+
event='${{ github.event_name }}'
49+
ver=''
50+
if [ "$event" = 'release' ]; then
51+
ver='${{ github.event.release.tag_name }}'
52+
elif [ "$event" = 'workflow_dispatch' ]; then
53+
ver='${{ github.event.inputs.version }}'
54+
fi
55+
ver="${ver#v}"
56+
if [ -n "$ver" ]; then
57+
echo "Using package version: $ver"
58+
echo "pkg_version=$ver" >> "$GITHUB_OUTPUT"
59+
else
60+
echo "No version provided; skipping pack/publish."
61+
echo "pkg_version=" >> "$GITHUB_OUTPUT"
62+
fi
63+
64+
- name: Pack NuGet packages
65+
if: (github.event_name == 'release' || github.event_name == 'workflow_dispatch') && steps.version.outputs.pkg_version != ''
66+
run: |
67+
dotnet pack tools/ancp/f/f.fsproj --configuration Release --no-build --output ./nupkg \
68+
-p:GeneratePackageOnBuild=false -p:PackageVersion=${{ steps.version.outputs.pkg_version }} -p:ContinuousIntegrationBuild=true
69+
dotnet pack tools/ancp/fc/fc.fsproj --configuration Release --no-build --output ./nupkg \
70+
-p:GeneratePackageOnBuild=false -p:PackageVersion=${{ steps.version.outputs.pkg_version }} -p:ContinuousIntegrationBuild=true
71+
72+
- name: Publish packages to NuGet.org
73+
if: (github.event_name == 'release' || github.event_name == 'workflow_dispatch') && steps.version.outputs.pkg_version != ''
74+
env:
75+
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
76+
run: |
77+
if [ -z "+${NUGET_API_KEY}+" ]; then echo "NUGET_API_KEY is not set" && exit 1; fi
78+
dotnet nuget push ./nupkg/*.nupkg \
79+
--api-key $NUGET_API_KEY \
80+
--source https://api.nuget.org/v3/index.json \
81+
--skip-duplicate

.github/workflows/tests.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Tests and Coverage
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
pull_request:
7+
branches: [ main, master ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
build-test:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Setup .NET SDKs
19+
uses: actions/setup-dotnet@v4
20+
with:
21+
dotnet-version: |
22+
8.0.x
23+
9.0.x
24+
cache: true
25+
26+
- name: Restore dependencies
27+
run: dotnet restore ancpdevkit.sln
28+
29+
- name: Build
30+
run: dotnet build ancpdevkit.sln --no-restore --configuration Release
31+
32+
- name: Install dotnet-coverage
33+
run: dotnet tool install --global dotnet-coverage
34+
35+
- name: Run tests with coverage
36+
run: |
37+
~/.dotnet/tools/dotnet-coverage collect "dotnet test ancpdevkit.sln --no-build --configuration Release --logger:\"trx;LogFileName=test_results.trx\"" \
38+
-f cobertura -o "coverage.cobertura.xml"
39+
40+
- name: Upload coverage to Codecov
41+
uses: codecov/codecov-action@v5
42+
with:
43+
token: ${{ secrets.CODECOV_TOKEN }}
44+
files: coverage.cobertura.xml
45+
fail_ci_if_error: false

0 commit comments

Comments
 (0)