-
Notifications
You must be signed in to change notification settings - Fork 0
147 lines (122 loc) · 4.26 KB
/
rc.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
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
145
146
name: release candidate
on:
workflow_dispatch:
inputs:
PUBLISH_NUGET_PACKAGE:
description: 'Publish NuGet package to nuget.org'
required: true
default: false
type: boolean
DOTNET_VERBOSITY:
type: choice
description: 'Verbosity level for dotnet commands'
options:
- quiet
- minimal
- normal
- detailed
- diagnostic
default: 'minimal'
# push:
# branches:
# - rc/v*
# paths-ignore:
# - 'README'
# - 'README.md'
# - 'LICENSE'
# - '.github/**'
run-name: ${{ github.ref_name }} - ${{ github.event.head_commit.message || github.workflow_dispatch || github.sha }}
jobs:
build_and_test:
name: build_and_test
runs-on: ${{ vars.DEFAULT_RUNS_ON }}
env:
DOTNET_VERBOSITY: ${{ inputs.DOTNET_VERBOSITY || 'minimal' }}
NUGET_SOURCE: "https://api.nuget.org/v3/index.json"
steps:
- uses: btungut/devops/.github/actions/common@master
id: common
- uses: btungut/devops/.github/actions/git-checkout@master
with:
gitToken: ${{ secrets.GITHUB_TOKEN }}
- name: iteration_vars
id: iteration_vars
shell: bash
run: |
set -euo pipefail
BRANCH_VERSION="${{ steps.common.outputs.branch-version }}"
if [ -z "$BRANCH_VERSION" ]; then
echo "steps.common.outputs.branch-version is null or empty whitespace!"
exit 1
fi
echo -e "\nsteps.common.outputs.branch-version = $BRANCH_VERSION\n"
- uses: ./app/.github/actions/dotnet-common
with:
dotnet-verbosity: ${{ env.DOTNET_VERBOSITY }}
dir-sln: app
dir-src-project: app/src
dir-unit-tests: app/tests
dir-integration-tests: app/tests_integration
- name: dotnet_pack
id: dotnet_pack
shell: bash
run: |
set -euo pipefail
echo "PWD = $(pwd)"
OUTPUT_DIR="${{ runner.temp }}/.nuget"
echo "OUTPUT_DIR=$OUTPUT_DIR" >> $GITHUB_ENV
echo "OUTPUT_DIR=$OUTPUT_DIR"
rm -rf $OUTPUT_DIR
mkdir -p $OUTPUT_DIR
PACKAGE_VERSION="${{ steps.common.outputs.branch-version }}-rc${{ steps.common.outputs.rev-unique }}"
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
echo "PACKAGE_VERSION=$PACKAGE_VERSION"
dotnet pack \
-c Release \
--verbosity $DOTNET_VERBOSITY \
--no-build \
--no-restore \
-p:PackageVersion="$PACKAGE_VERSION" \
--output $OUTPUT_DIR
echo -e "\n\nls for $OUTPUT_DIR\n"
ls -al $OUTPUT_DIR
working-directory: app/src
- name: upload_artifacts
uses: actions/upload-artifact@v4
with:
path: ${{ env.OUTPUT_DIR }}
name: NuGet-${{ env.PACKAGE_VERSION }}
if-no-files-found: error
include-hidden-files: true
- name: publish_nuget_package
id: publish_nuget_package
shell: bash
run: |
set -euo pipefail
echo "PWD = $(pwd)"
NUGET_API_KEY="${{ secrets.NUGET_API_KEY }}"
if [ -z "$NUGET_API_KEY" ]; then
echo "NUGET_API_KEY is null or empty whitespace!"
exit 1
fi
echo -e "\ndotnet nuget push for nupkg\n"
dotnet nuget push \
${{ env.OUTPUT_DIR }}/*.nupkg \
--skip-duplicate \
--api-key "$NUGET_API_KEY" \
--source "$NUGET_SOURCE"
echo -e "\n SUCCESS: dotnet nuget push for nupkg\n\n"
echo -e "\ndotnet nuget push for snupkg\n"
dotnet nuget push \
${{ env.OUTPUT_DIR }}/*.snupkg \
--skip-duplicate \
--api-key "$NUGET_API_KEY" \
--source "$NUGET_SOURCE"
echo -e "\n SUCCESS: dotnet nuget push for snupkg\n\n"
# echo multiline with env var
echo -e "\n\n
NuGet package published successfully!
Package Version: $PACKAGE_VERSION
https://www.nuget.org/packages/AspNetHeaderReplicator/$PACKAGE_VERSION/
\n" >> $GITHUB_STEP_SUMMARY
if: ${{ inputs.PUBLISH_NUGET_PACKAGE }}