-
Notifications
You must be signed in to change notification settings - Fork 77
94 lines (82 loc) · 3.74 KB
/
Nuget.yml
File metadata and controls
94 lines (82 loc) · 3.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: 'Upload to MyGet and NuGet'
run-name: ${{ github.event_name == 'push' && 'Upload to MyGet' || 'Upload to NuGet' }}
on:
push:
branches:
- master
release:
types: [published]
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Setup .NET 10
uses: actions/setup-dotnet@v5
with:
dotnet-version: '10.x'
dotnet-quality: 'preview'
- uses: actions/checkout@v6
- name: 'Determine version and target'
id: version
run: |
if [[ "${{ github.event_name }}" == "push" ]]; then
# MyGet versioning
commithash=$(git rev-parse --short HEAD)
currtime=$(date +%s)
echo "commit hash is $commithash"
echo "time is $currtime"
version=10.0.0-master-$currtime-$commithash
echo "version is $version"
echo "version=$version" >> $GITHUB_OUTPUT
echo "apikey=${{ secrets.MYGET_KEY }}" >> $GITHUB_OUTPUT
echo "source=myget" >> $GITHUB_OUTPUT
echo "target=MyGet" >> $GITHUB_OUTPUT
else
# NuGet versioning from release tag
tagname="${{ github.event.release.tag_name }}"
# Validate tag name exists
if [[ -z "$tagname" ]]; then
echo "Error: Release tag name is empty"
exit 1
fi
# Remove 'v' prefix if present (e.g., v1.0.0 -> 1.0.0)
version="${tagname#v}"
echo "Release tag is $tagname"
echo "Package version is $version"
# Validate version format (SemVer 2.0.0: X.Y.Z[-prerelease][+build])
if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$ ]]; then
echo "Error: Invalid version format '$version'."
echo "Expected semantic version (e.g., 1.0.0, 1.0.0-beta.1, 1.0.0+build.123)"
exit 1
fi
echo "version=$version" >> $GITHUB_OUTPUT
echo "apikey=${{ secrets.NUGET_KEY }}" >> $GITHUB_OUTPUT
echo "source=nuget.org" >> $GITHUB_OUTPUT
echo "target=NuGet" >> $GITHUB_OUTPUT
fi
- name: 'Pack and publish AngouriMath'
run: |
cd Sources/AngouriMath
dotnet restore AngouriMath.csproj
dotnet build AngouriMath.csproj -c release
dotnet pack AngouriMath.csproj -c release -p:PackageVersion=${{ steps.version.outputs.version }}
cd bin/release
dotnet nuget push AngouriMath.${{ steps.version.outputs.version }}.nupkg --api-key ${{ steps.version.outputs.apikey }} --source "${{ steps.version.outputs.source }}"
- name: 'Pack and publish AngouriMath.FSharp'
run: |
cd Sources/Wrappers/AngouriMath.FSharp
dotnet restore
dotnet build -c Release
dotnet pack -c Release -p:PackageVersion=${{ steps.version.outputs.version }}
cd bin/Release
dotnet nuget push AngouriMath.FSharp.${{ steps.version.outputs.version }}.nupkg --api-key ${{ steps.version.outputs.apikey }} --source "${{ steps.version.outputs.source }}"
- name: 'Pack and publish AngouriMath.Interactive'
run: |
cd Sources/Wrappers/AngouriMath.Interactive
dotnet restore
dotnet build -c Release
dotnet pack -c Release -p:PackageVersion=${{ steps.version.outputs.version }}
cd bin/Release
dotnet nuget push AngouriMath.Interactive.${{ steps.version.outputs.version }}.nupkg --api-key ${{ steps.version.outputs.apikey }} --source "${{ steps.version.outputs.source }}"