-
Notifications
You must be signed in to change notification settings - Fork 0
147 lines (110 loc) · 4.26 KB
/
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
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
147
name: release stable
on:
# workflow_run:
# workflows: ["release candidate"]
# types:
# - completed
workflow_dispatch:
inputs:
RC_RUN_ID:
description: 'Run ID for the release candidate'
required: true
run-name: release for ${{ inputs.RC_RUN_ID }}
jobs:
main:
name: main
runs-on: ${{ vars.DEFAULT_RUNS_ON }}
env:
ARTIFACT_PREFIX: NuGet
steps:
- uses: btungut/devops/.github/actions/common@master
id: common
- name: iteration_vars
id: iteration_vars
shell: bash
run: |
set -euo pipefail
# call and parse GitHub API to get the run details of RC_RUN_ID
# https://docs.github.com/en/rest/reference/actions#get-a-workflow-run
DW_PATH="${{ steps.common.outputs.workflow-tmp-dir }}/release"
rm -rf $DW_PATH
mkdir -p $DW_PATH
echo "DW_PATH=$DW_PATH" >> $GITHUB_ENV
echo "DW_PATH=$DW_PATH"
RC_RUN_ID="${{ inputs.RC_RUN_ID }}"
if [ -z "${{ inputs.RC_RUN_ID }}" ]; then
echo "inputs.RC_RUN_ID is null or empty whitespace!"
exit 1
fi
echo "inputs.RC_RUN_ID: $RC_RUN_ID"
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 "steps.common.outputs.branch-version: $BRANCH_VERSION"
- name: download_artifacts
id: download_artifacts
uses: actions/download-artifact@v4
with:
name: src
github-token: ${{ secrets.GH_TOKEN }}
run-id: ${{ inputs.RC_RUN_ID }}
path: ${{ env.DW_PATH }}
repository: ${{ github.repository }}
merge-multiple: false
- name: validate_artifacts_src
id: validate_artifacts_src
shell: bash
run: |
set -euo pipefail
echo "PWD = $(pwd)"
DW_PATH="${{ env.DW_PATH }}"
[ -z "$DW_PATH" ] && { echo "DW_PATH is null or empty whitespace!"; exit 1; }
[ ! -d "$DW_PATH" ] && { echo "DW_PATH does not exist!"; exit 1; }
pushd $DW_PATH
[ -z "$(ls -A)" ] && { echo "DW_PATH is empty! PLEASE CHECK YOUR INPUTS!!!"; exit 1; }
tree || ls -al
# echo and exit 1, if there is no *.csproj file in the directory
[ -z "$(find . -type f -name '*.csproj')" ] && { echo "No *.csproj file found in $DW_PATH!"; exit 1; }
# echo and exit 1, if there is no bin/Release/*/*.dll file in the directory
[ -z "$(find . -type f -name '*.dll' -path '*/bin/Release/*')" ] && { echo "No *.dll file found in $DW_PATH/bin/Release/*!"; exit 1; }
popd
echo "Validation of artifacts in $DW_PATH is successful! dotnet pack could be called now!"
- name: dotnet_pack
id: dotnet_pack
shell: bash
run: |
set -euo pipefail
echo "PWD = $(pwd)"
OUTPUT_DIR="./.nuget"
rm -rf $OUTPUT_DIR
mkdir -p $OUTPUT_DIR
OUTPUT_DIR=$(realpath $OUTPUT_DIR)
echo "OUTPUT_DIR=$OUTPUT_DIR" >> $GITHUB_ENV
echo "OUTPUT_DIR=$OUTPUT_DIR"
PACKAGE_VERSION="${{ steps.common.outputs.branch-version }}"
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
echo "PACKAGE_VERSION=$PACKAGE_VERSION"
dotnet pack \
-c Release \
--verbosity minimal \
--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: ${{ env.DW_PATH }}
- name: Release
uses: softprops/action-gh-release@v2
with:
files: |
${{ env.OUTPUT_DIR }}/*.nupkg
${{ env.OUTPUT_DIR }}/*.snupkg
token: ${{ secrets.GH_TOKEN }}
name: v${{ steps.common.outputs.branch-version }}
tag_name: v${{ steps.common.outputs.branch-version }}
draft: false
prerelease: false
generate_release_notes: true