-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (79 loc) · 3.86 KB
/
nuget_release.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
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
95
name: Release to Nuget
on:
push:
tags:
- "v*-beta*"
- "v*-rc*"
workflow_dispatch:
branches: [main, nuget]
env:
TAG_NAME: ${{ github.event.release.tag_name }}
PROJECT_PATH: ./FluentPasswordHashing
ARTIFACT_NAME: FluentPasswordHashing
PACKAGE_RELEASE_NOTES_URL: https://github.com/${{ github.repository }}/releases/tag/
PACKAGE_OUTPUT_DIRECTORY: ${{ github.workspace }}/output
NUGET_SOURCE_URL: https://api.nuget.org/v3/index.json
NUGET_AUTH_TOKEN: ${{ secrets.NUGET_AUTH_TOKEN }}
GITHUB_REPO_URL: https://github.com/${{ github.repository }}
GITHUB_SOURCE_URL: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json
DOT_NET_VERSION: 6.*
DRAFT: false
PRERELEASE: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.DOT_NET_VERSION }}
- name: Run Restore
run: dotnet restore
- name: Run Tests
run: dotnet test -c Release
- name: Build Project
run: dotnet build ${{ env.PROJECT_PATH }} -c Release --no-restore
- name: Get Version
id: version
uses: battila7/get-version-action@v2
- name: Create Nuget Package
env:
Command: pack ${{ env.PROJECT_PATH }} -c Release --no-restore --include-symbols --output ${{ env.PACKAGE_OUTPUT_DIRECTORY }}
AssemblyVersion: ${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }}
FileVersion: ${{ steps.version.outputs.version-without-v }}
PackageReleaseNotes: "See ${{ env.PACKAGE_RELEASE_NOTES_URL }}${{ steps.version.outputs.version }}"
RepositoryUrl: "${{ env.GITHUB_REPO_URL }}"
run: dotnet ${{ env.Command }} -p:AssemblyVersion=${{ env.AssemblyVersion }} -p:FileVersion=${{ env.FileVersion }} -p:PackageReleaseNotes="${{ env.PackageReleaseNotes }}" -p:RepositoryUrl="${{ env.RepositoryUrl }}"
- name: Push Package to Nuget
run: dotnet nuget push ${{ env.PACKAGE_OUTPUT_DIRECTORY }}/*.nupkg --skip-duplicate -k ${{ env.NUGET_AUTH_TOKEN }} -s ${{ env.NUGET_SOURCE_URL }}
- name: Push Package to GitHub
run: dotnet nuget push ${{ env.PACKAGE_OUTPUT_DIRECTORY }}/*.nupkg --skip-duplicate -k ${{ secrets.GITHUB_TOKEN }} -s ${{ env.GITHUB_SOURCE_URL }}
- name: Archive Nuget Package
uses: actions/upload-artifact@v2
with:
name: ${{ env.ARTIFACT_NAME }}.${{ steps.version.outputs.version-without-v }}.nupkg
path: "${{ env.PACKAGE_OUTPUT_DIRECTORY }}/*.nupkg"
- name: Zip Archive
run: |
zip --junk-paths ${{ env.ARTIFACT_NAME }}.${{ steps.version.outputs.version-without-v }}.zip ${{ env.PACKAGE_OUTPUT_DIRECTORY }}/*.nupkg
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: ${{ env.DRAFT }}
prerelease: ${{ env.PRERELEASE }}
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./${{ env.ARTIFACT_NAME }}.${{ steps.version.outputs.version-without-v }}.zip
asset_name: ${{ env.ARTIFACT_NAME }}.${{ steps.version.outputs.version-without-v }}.nupkg.zip
asset_content_type: application/zip