Skip to content

Commit 28683a5

Browse files
this commits introduces workflow for publishing packages to nuget
1 parent 8ba094f commit 28683a5

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: workflow - publish package
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- development
8+
9+
jobs:
10+
publish:
11+
runs-on: ubuntu-latest
12+
13+
defaults:
14+
run:
15+
working-directory: Artifacts/Comanda.Internal.Contracts
16+
17+
steps:
18+
- name: checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: setup .NET
22+
uses: actions/setup-dotnet@v4
23+
with:
24+
dotnet-version: '9.0.x'
25+
26+
- name: restore dependencies
27+
run: dotnet restore
28+
29+
- name: build
30+
run: dotnet build --configuration Release --no-restore
31+
32+
- name: set version and pack
33+
id: pack
34+
run: |
35+
BASE_VERSION="1.0"
36+
37+
if [[ "${GITHUB_REF}" == "refs/heads/master" ]]; then
38+
VERSION="${BASE_VERSION}.${GITHUB_RUN_NUMBER}"
39+
elif [[ "${GITHUB_REF}" == "refs/heads/development" ]]; then
40+
VERSION="${BASE_VERSION}-beta.${GITHUB_RUN_NUMBER}"
41+
else
42+
echo "branch not configured for publication"
43+
exit 1
44+
fi
45+
46+
echo "use version: $VERSION"
47+
dotnet pack -c Release -p:PackageVersion=$VERSION -o ./output --no-build
48+
49+
echo "package_version=$VERSION" >> $GITHUB_OUTPUT
50+
51+
- name: push package to nuget
52+
run: dotnet nuget push ./output/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate

0 commit comments

Comments
 (0)