-
Notifications
You must be signed in to change notification settings - Fork 15
107 lines (86 loc) · 3.01 KB
/
build.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
name: Build
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
name: Build
runs-on: windows-latest
steps:
- name: Check out
uses: actions/checkout@v3
- name: Setup .Net
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.302
- name: Restore
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal
add_tag:
name: Tag and Release
runs-on: ubuntu-latest
needs:
- build
if: >-
needs.build.result == 'success' &&
github.event.pull_request.merged &&
github.event.pull_request.base.ref == 'main' &&
startsWith(github.event.pull_request.title, 'RELEASES:') &&
contains(github.event.pull_request.labels.*.name, 'RELEASES')
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
token: ${{ secrets.PAT_FOR_TAGGING }}
- name: Configure Git
run: >-
git config user.name "GitHub Action"
git config user.email "[email protected]"
- name: Extract Version
id: extract_version
run: >
# Running on Linux/Unix
sudo apt-get install xmlstarlet
version_number=$(xmlstarlet sel -t -v "//Version" -n GitFyle.Core.Api/GitFyle.Core.Api.csproj)
echo "$version_number"
echo "version_number<<EOF" >> $GITHUB_OUTPUT
echo "$version_number" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
shell: bash
- name: Display Version
run: 'echo "Version number: ${{ steps.extract_version.outputs.version_number }}"'
- name: Extract Package Release Notes
id: extract_package_release_notes
run: >
# Running on Linux/Unix
sudo apt-get install xmlstarlet
package_release_notes=$(xmlstarlet sel -t -v "//PackageReleaseNotes" -n GitFyle.Core.Api/GitFyle.Core.Api.csproj)
echo "$package_release_notes"
echo "package_release_notes<<EOF" >> $GITHUB_OUTPUT
echo "$package_release_notes" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
shell: bash
- name: Display Package Release Notes
run: 'echo "Package Release Notes: ${{ steps.extract_package_release_notes.outputs.package_release_notes }}"'
- name: Create GitHub Tag
run: >-
git tag -a "v${{ steps.extract_version.outputs.version_number }}" -m "Release - v${{ steps.extract_version.outputs.version_number }}"
git push origin --tags
- name: Create GitHub Release
uses: actions/create-release@v1
with:
tag_name: v${{ steps.extract_version.outputs.version_number }}
release_name: Release - v${{ steps.extract_version.outputs.version_number }}
body: >-
## Release - v${{ steps.extract_version.outputs.version_number }}
### Release Notes
${{ steps.extract_package_release_notes.outputs.package_release_notes }}
env:
GITHUB_TOKEN: ${{ secrets.PAT_FOR_TAGGING }}