-
Notifications
You must be signed in to change notification settings - Fork 0
50 lines (42 loc) · 1.59 KB
/
pack.yml
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
name: Publish NuGet Package to GitHub Registry
on:
push:
branches:
- releases/*
create:
branches:
- releases/*
tags:
- releases/*
jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Extract package information
run: |
BRANCH_NAME="${GITHUB_REF#refs/heads/}"
if [[ "$BRANCH_NAME" =~ releases/([^/]+)/(.+) ]]; then
echo "PACKAGE=${BASH_REMATCH[1]}" >> $GITHUB_ENV
echo "VERSION=${BASH_REMATCH[2]}" >> $GITHUB_ENV
else
echo "Branch name does not match the required pattern 'releases/{Package}/{Version}'"
exit 1
fi
- name: Set up .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: Pack the project
run: find -type f -name "$PACKAGE.csproj" | xargs -I {} dotnet pack "{}" --configuration Release --output ./nupkgs
- name: Validate package version
run: |
PACKAGE_FILE=$(find ./nupkgs -name '$PACKAGE.$VERSION.nupkg' | head -n 1)
if [ -z "$PACKAGE_FILE" ]; then
echo "No NuGet package '$PACKAGE.$VERSION.nupkg' found."
echo "Maybe the package or version doesn't match the expected '$PACKAGE' with version '$VERSION'."
ls ./nupkgs
exit 1
fi
- name: Publish NuGet package to GitHub Packages
run: dotnet nuget push ./nupkgs/$PACKAGE.$VERSION.nupkg --source https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json -k {{"${{ secrets.TOKEN_GITHUB }}"