-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (80 loc) · 2.85 KB
/
CleanArchitecture.Blazored.Deploy.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
name: CleanArchitecture.Blazored.Deploy
run-name: Deploying package to nuget
on:
workflow_dispatch:
push:
branches: [ "main" ]
release:
types:
- published
env:
NuGetDirectory: ${{github.workspace }}/nuget
jobs:
create_nuget:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .Net
uses: actions/[email protected]
with:
dotnet-version: 8.x
- name: Build Generated Project
shell: pwsh
run: .\CleanArchitecture.Blazored.restore.ps1
- name: Build Project
run: dotnet build --no-restore src/CleanArchitecture.Blazored.csproj -c Release
- name: Get latest release tag
id: get_tag
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "REPOSITORY_NAME=${{ github.repository }}"
tag=$(curl -s \
"https://api.github.com/repos/${{ github.repository }}/releases/latest" \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ env.GH_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
| jq -r '.tag_name')
echo "Tag=$tag"
echo "::set-output name=tag::$tag"
- name: Ensure Release Tag
if: steps.get_tag.outputs.tag == null || steps.get_tag.outputs.tag == ''
run: exit 1
- name: Prepare Version tag
id: prep_version
run: |
export test_version=$(echo ${{ steps.get_tag.outputs.tag }} | sed -E 's/^[^0-9\.]*([0-9\.].*)$/\1/')
echo "Prep Tag=$test_version"
echo ::set-output name=version::$test_version
- name: Ensure Version
if: steps.prep_version.outputs.version == null || steps.prep_version.outputs.version == ''
run: exit 1
- name: Pack Nuget package
run: dotnet pack src/CleanArchitecture.Blazored.csproj /p:PackageVersionNumber=${{ steps.prep_version.outputs.version }} --configuration Release --output ${{ env.NuGetDirectory }}
- uses: actions/upload-artifact@v3
if: github.event_name =='release'
with:
name: nuget
if-no-files-found: error
retention-days: 7
path: ${{ env.NuGetDirectory }}/*.nupkg
deploy:
if: github.event_name =='release'
runs-on: ubuntu-latest
needs:
- create_nuget
steps:
- uses: actions/download-artifact@v3
with:
name: nuget
path: ${{ env.NuGetDirectory }}
- name: Setup .NET
uses: actions/[email protected]
with:
dotnet-version: 8.x
- name: Publish Nuget package
run: |
cd ${{ env.NuGetDirectory }}
for file in *.nupkg; do
dotnet nuget push "$file" --api-key "${{ secrets.NUGET_APIKEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate
done