-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcreate-release-asset-on-git-tag.yml
More file actions
144 lines (120 loc) · 4.64 KB
/
create-release-asset-on-git-tag.yml
File metadata and controls
144 lines (120 loc) · 4.64 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# https://github.com/actions/upload-release-asset
# https://github.com/montudor/action-zip
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
name: Create Release on Git Tag
env:
PROJECT: RecursiveDataAnnotationsValidation
CONFIG: Release
TARGET: netstandard2.0
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
# https://stackoverflow.com/a/58178121
# https://stackoverflow.com/a/59284102
- name: Get Release Version
run: |
echo "RELEASE_TAG=${GITHUB_REF##*/}" >> $GITHUB_ENV
echo "RELEASE_VERSION=${GITHUB_REF##*/v}" >> $GITHUB_ENV
- name: Print Release Version
run: |
echo "GITHUB_REF=$GITHUB_REF"
echo "RELEASE_TAG=$RELEASE_TAG env.RELEASE_TAG=${{ env.RELEASE_TAG }}"
echo "RELEASE_VERSION=$RELEASE_VERSION env.RELEASE_VERSION=${{ env.RELEASE_VERSION }}"
- name: Setup .NET 8
uses: actions/setup-dotnet@v1
with:
dotnet-version: 8.0.204
- name: dotnet build
run: dotnet build --configuration ${{ env.CONFIG }}
- name: dotnet test
run: dotnet test --configuration ${{ env.CONFIG }}
- name: dotnet publish
working-directory: ./src/${{ env.PROJECT }}
run: >
dotnet publish --configuration ${{ env.CONFIG }}
/p:Version="${{ env.RELEASE_VERSION }}" /p:InformationalVersion="${{ env.RELEASE_VERSION }}"
- name: Create artifacts directory
run: mkdir -p artifacts
- name: dotnet pack
run: >
dotnet pack
--configuration ${{ env.CONFIG }}
/p:Version="${{ env.RELEASE_VERSION }}"
--include-symbols
--output artifacts/
- name: Inspect artifacts directory
run: ls -l artifacts/
- name: Archive artifacts directory
uses: actions/upload-artifact@v7
with:
name: ${{ env.PROJECT }}.artifacts.${{ env.RELEASE_VERSION }}
path: |
artifacts/
- 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: false
prerelease: true
- name: Create release directory
run: mkdir -p release
- name: Create Release Zip File
uses: vimtor/action-zip@v1
with:
files: LICENSE README.md artifacts/
recursive: true
dest: release/${{ env.PROJECT }}-${{ env.RELEASE_TAG }}.zip
- name: Inspect release directory
run: ls -l release/
- name: Archive release directory
uses: actions/upload-artifact@v7
with:
name: ${{ env.PROJECT }}.release.${{ env.RELEASE_TAG }}
path: |
release/
- name: Attach Zip to GitHub Release
if: ${{ env.RELEASE_CREATE }}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: release/${{ env.PROJECT }}-${{ env.RELEASE_TAG }}.zip
asset_name: ${{ env.PROJECT }}-${{ env.RELEASE_VERSION }}.zip
asset_content_type: application/zip
- name: Attach .nupkg file to GitHub Release
id: upload-release-asset-nupkg
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: artifacts/${{ env.PROJECT }}.${{ env.RELEASE_VERSION }}.nupkg
asset_name: ${{ env.PROJECT }}.${{ env.RELEASE_VERSION }}.nupkg
asset_content_type: application/zip
- name: Attach .snupkg file to GitHub Release
id: upload-release-asset-snupkg
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: artifacts/${{ env.PROJECT }}.${{ env.RELEASE_VERSION }}.snupkg
asset_name: ${{ env.PROJECT }}.${{ env.RELEASE_VERSION }}.snupkg
asset_content_type: application/zip
- name: Publish on nuget.org
run: >
dotnet nuget push '**/*.nupkg'
-k ${{ secrets.NugetApiKey }}
-s https://api.nuget.org/v3/index.json