-
Notifications
You must be signed in to change notification settings - Fork 6
114 lines (93 loc) · 3.76 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
name: release
on:
workflow_dispatch:
inputs:
ver:
description: 'The version number, should be specified as a semantic version e.g: X.Y.Z'
required: true
release-notes:
description: 'The versions release notes'
required: true
permissions:
contents: read
env:
DOTNET_VERSION: '8.0'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
repository: benpollarduk/NetAF
token: ${{ secrets.PAT }}
- name: Setup environment
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Install dependencies
run: dotnet restore
- name: Install node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Update docfx
run: dotnet tool update -g docfx
- name: Update version and release notes in csproj file
run: |
echo "Version: ${{ inputs.ver }}"
echo "Release notes: ${{ inputs.release-notes }}"
# update the .csproj file with the input version
sed -i "s/<Version>.*<\/Version>/<Version>${{ inputs.ver }}<\/Version>/" NetAF/NetAF.csproj
sed -i "s/<AssemblyVersion>.*<\/AssemblyVersion>/<AssemblyVersion>${{ inputs.ver }}.0<\/AssemblyVersion>/" NetAF/NetAF.csproj
sed -i "s/<FileVersion>.*<\/FileVersion>/<FileVersion>${{ inputs.ver }}<\/FileVersion>/" NetAF/NetAF.csproj
# update the .csproj file with the release notes
sed -i "s/<PackageReleaseNotes>.*<\/PackageReleaseNotes>/<PackageReleaseNotes>${{ inputs.release-notes }}<\/PackageReleaseNotes>/" NetAF/NetAF.csproj
- name: Build
run: dotnet build -c Release
- name: Run tests with coverlet
run: dotnet test /p:CollectCoverage=true /p:CoverletOutput=TestResults/ /p:CoverletOutputFormat=lcov
- name: Tag the commit
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git tag -a "${{ inputs.ver }}" -m "${{ inputs.ver }} tagged during GitHub action"
git push --tags
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Push NuGet package (GitHub)
run: |
dotnet nuget push ./NetAF/bin/Release/*.nupkg --api-key ${{ secrets.PAT }} --source https://nuget.pkg.github.com/benpollarduk/index.json
- name: Push NuGet package (NuGet.org)
run: |
dotnet nuget push ./NetAF/bin/Release/*.nupkg --api-key ${{ secrets.NUGET_TOKEN }} --source https://api.nuget.org/v3/index.json
- name: Build documentation
continue-on-error: true
run: docfx docs/docfx/docfx.json
- name: Copy website files, commit and tag, then push changes to NetAF-docs
continue-on-error: true
run: |
mkdir NetAF-docs
cd NetAF-docs
git init
git remote add origin https://${{ secrets.PAT }}@github.com/benpollarduk/NetAF-docs.git
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git fetch
git checkout main
git rm -r --ignore-unmatch .
cp -r ../docs/docfx/_site/* .
git add .
git commit -m "Update documentation"
git tag -a "${{ inputs.ver }}" -m "${{ inputs.ver }} tagged during GitHub action"
git push --follow-tags https://${{ secrets.PAT }}@github.com/benpollarduk/NetAF-docs.git HEAD:main
- name: Create GitHub release
uses: actions/create-release@v1
with:
tag_name: "${{ inputs.ver }}"
release_name: "${{ inputs.ver }}"
body: "${{ inputs.release-notes }}"
env:
GITHUB_TOKEN: ${{ secrets.PAT }}