Skip to content

Commit 9e16459

Browse files
albelli-cicd-automationSergii Kolbasin
authored andcommitted
Setup the pack-and-push-nuget github action
0 parents  commit 9e16459

3 files changed

Lines changed: 95 additions & 0 deletions

File tree

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Copyright 2021 Albelli BV
2+
3+
Redistribution and use in source and binary forms, with or without
4+
modification, are permitted provided that the following conditions are met:
5+
6+
1. Redistributions of source code must retain the above copyright notice, this
7+
list of conditions and the following disclaimer.
8+
9+
2. Redistributions in binary form must reproduce the above copyright notice,
10+
this list of conditions and the following disclaimer in the documentation
11+
and/or other materials provided with the distribution.
12+
13+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
14+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
17+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
20+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
21+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Pack And Push NuGet Package To NuGet Server
2+
3+
A GitHub Action to pack and push a [nuget package](https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-nuget-push).
4+
5+
You could use [albumprinter/actions-get-git-version](https://github.com/albumprinter/actions-get-git-version) to get the semver using git log.
6+
7+
## Usage
8+
9+
```yaml
10+
- uses: albumprinter/actions-pack-and-push-nuget@v1
11+
with:
12+
package: YOUR_PACKAGE_NAME
13+
description: YOUR_PACKAGE_DESCRIPTION
14+
version: YOUR_PACKAGE_VERSION or ${{ steps.git-version.outputs.version }}
15+
paths: dist deploy.sh
16+
server: ${{ secrets.ARTIFACTORY_DEPLOY_RELEASE_URL }}
17+
username: ${{ secrets.ARTIFACTORY_USERNAME }}
18+
password: ${{ secrets.ARTIFACTORY_USER_PASSWORD }}
19+
```

action.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# https://docs.github.com/en/actions/creating-actions/about-custom-actions
2+
3+
name: Pack And Push NuGet Package
4+
description: Pack a nuget package and push it to the nuget server.
5+
6+
inputs:
7+
package:
8+
description: nuget package name
9+
required: true
10+
11+
description:
12+
description: nuget package description
13+
required: true
14+
15+
version:
16+
description: nuget package version
17+
required: true
18+
19+
authors:
20+
description: nuget package authors
21+
required: false
22+
default: 'Albelli'
23+
24+
paths:
25+
description: paths to files to be packaged in the nuget package
26+
required: true
27+
28+
server:
29+
description: nuget api url
30+
required: true
31+
32+
username:
33+
description: nuget username
34+
required: true
35+
36+
password:
37+
description: nuget password
38+
required: true
39+
40+
runs:
41+
using: composite
42+
steps:
43+
- name: pack nuget package and publish it to the nuget server
44+
shell: bash
45+
run: |
46+
PR_BRANCH=${GITHUB_HEAD_REF}
47+
PUSH_BRANCH=${GITHUB_REF#refs/heads/}
48+
BRANCH="${PR_BRANCH:-${PUSH_BRANCH}}"
49+
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?><package xmlns=\"http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd\"><metadata><id>${{ inputs.package }}</id><version>${{ inputs.version }}</version><authors>${{ inputs.authors }}</authors><description>${{ inputs.description }}</description></metadata></package>" > config.nuspec
50+
echo "{\"build\":\"${{ inputs.version }}\", \"branch\":\"$BRANCH\"}" > info.json
51+
zip -r ${{ inputs.package }}.nupkg config.nuspec info.json ${{ inputs.paths }}
52+
dotnet nuget add source ${{ inputs.server }} -n albelli -u ${{ inputs.username }} -p ${{ inputs.password }} --store-password-in-clear-text
53+
dotnet nuget push ${{ inputs.package }}.nupkg -s albelli --skip-duplicate --api-key ${{ inputs.username }}:${{ inputs.password }} --timeout 15
54+

0 commit comments

Comments
 (0)