-
Notifications
You must be signed in to change notification settings - Fork 0
188 lines (170 loc) · 6.93 KB
/
dotnet.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
name: dotnet
on:
push:
tags:
- 'v*'
pull_request:
branches: [ '*' ]
tags:
- 'v*'
paths-ignore:
- '**.md'
defaults:
run:
working-directory: ./
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.100
- name: Restore dependencies
run: dotnet restore
- name: Set version number
shell: powershell
run: |
$VERSION = & git.exe tag --points-at HEAD
if ($VERSION) {
$NVERSION = $VERSION.substring(1)
echo "[assembly: System.Reflection.AssemblyVersion(`"$NVERSION`")]" | Out-File -Append -FilePath ${env:GITHUB_WORKSPACE}/src/Shotr.Ui/Properties/AssemblyVersion.cs -Encoding utf8
echo "[assembly: System.Reflection.AssemblyFileVersion(`"$NVERSION`")]" | Out-File -Append -FilePath ${env:GITHUB_WORKSPACE}/src/Shotr.Ui/Properties/AssemblyVersion.cs -Encoding utf8
echo "Version is: $NVERSION"
echo "CURRENT_BRANCH=BetaTest" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
} else {
echo "Version is empty...skipping set."
echo "CURRENT_BRANCH=Testing" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
}
- name: Publish
run: dotnet publish -r win-x64 -c "${{ env.CURRENT_BRANCH }}"
- name: Test
run: dotnet test --no-build --verbosity normal
- uses: actions/upload-artifact@v2
with:
name: Shotr
path: ./src/Shotr.Ui/bin/${{ env.CURRENT_BRANCH }}/net6.0-windows10.0.19041.0/win-x64/publish/Shotr.exe
- uses: actions/upload-artifact@v2
with:
name: Shotr-Installer
path: ./src/Shotr.Ui.Installer/bin/${{ env.CURRENT_BRANCH }}/net6.0-windows/win-x64/publish/Shotr-Installer.exe
comment-on-pr:
name: Leave a comment with a link to the build on the PR
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/github-script@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.issues.createComment( {
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'The artifact is located here: https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}#artifacts'
} )
create-release:
name: Create Release Draft and Attach Asset
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v2
- name: Set Release Version
id: get_release_version
run: echo ::set-output name=version::$(echo $GITHUB_REF | cut -d / -f 3 | sed s/^v// | sed 's/-a//' )
- name: Get Issues and Format
id: get_issues_and_format
run: |
cd $GITHUB_WORKSPACE
echo 'ISSUES<<EOF' >> $GITHUB_ENV
echo "### Features: " >> $GITHUB_ENV
echo `GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} gh issue list -m "${{ steps.get_release_version.outputs.version }}" -s "all" -l "feature request" | awk -F $'\t' '{ printf "- %s (#%s)\r\n", $3, $1 }'` >> $GITHUB_ENV
echo "" >> $GITHUB_ENV
echo "### Bug Fixes: " >> $GITHUB_ENV
echo `GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} gh issue list -m "${{ steps.get_release_version.outputs.version }}" -s "all" -l "bug" | awk -F $'\t' '{ printf "- %s (#%s)\r\n", $3, $1 }'` >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Download Zip Artifact
id: download
uses: actions/download-artifact@v2
with:
name: Shotr
- name: Download Installer Zip Artifact
id: download-installer
uses: actions/download-artifact@v2
with:
name: Shotr-Installer
- name: Display structure of downloaded files
run: ls -R
working-directory: ${{steps.download.outputs.download-path}}
- name: Zip up release file
run: zip Shotr.zip Shotr.exe
working-directory: ${{steps.download.outputs.download-path}}
- name: Display structure of downloaded files for installer
run: ls -R
working-directory: ${{steps.download-installer.outputs.download-path}}
- name: Zip up release file for installer
run: zip Shotr-Installer.zip Shotr-Installer.exe
working-directory: ${{steps.download-installer.outputs.download-path}}
- name: Create Release Draft
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ steps.get_release_version.outputs.version }}
draft: true
prerelease: false
body: ${{env.ISSUES}}
- name: Upload Release Asset Exeutable
id: upload-release-asset
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: Shotr.exe
asset_name: Shotr.exe
asset_content_type: application/octet-stream
- name: Upload Release Asset Zip
id: upload-release-asset-zip
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: Shotr.zip
asset_name: Shotr.zip
asset_content_type: application/zip
- name: Upload Installer Release Executable
id: upload-release-asset-installer
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: Shotr-Installer.exe
asset_name: Shotr-Installer.exe
asset_content_type: application/octet-stream
- name: Upload Installer Release Zip
id: upload-release-asset-installer-zip
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: Shotr-Installer.zip
asset_name: Shotr-Installer.zip
asset_content_type: application/zip
#
# - name: Publish Release
# run: |
# curl \
# --request PATCH \
# --url https://api.github.com/repos/${{ github.repository }}/releases/${{ steps.create_release.outputs.id }} \
# --header 'Authorization: token ${{ secrets.GITHUB_TOKEN }}' \
# --header "Accept: application/vnd.github.v3+json" \
# --data-raw '{"draft":false}'