-
Notifications
You must be signed in to change notification settings - Fork 0
138 lines (120 loc) · 4.28 KB
/
Copy pathrelease.yml
File metadata and controls
138 lines (120 loc) · 4.28 KB
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
name: Release
on:
push:
branches: [ main ]
workflow_dispatch:
permissions:
contents: write
packages: write
pull-requests: write
jobs:
release:
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Check for existing tags
id: check_tags
run: |
if git describe --tags --abbrev=0 2>/dev/null; then
echo "has_tags=true" >> $GITHUB_OUTPUT
echo "Found existing tags"
else
echo "has_tags=false" >> $GITHUB_OUTPUT
echo "No tags found - will create initial release"
fi
- name: Get next version
id: get_version
uses: mathieudutour/github-tag-action@v6.2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
release_branches: main
pre_release_branches: develop
dry_run: true
default_bump: ${{ steps.check_tags.outputs.has_tags == 'false' && 'major' || 'false' }}
custom_release_rules: |
breaking:major,
feat:minor,
fix:patch,
perf:patch,
revert:patch,
docs:patch:README,
refactor:patch,
test:false,
style:false,
chore:false,
ci:false
- name: Check if should release
id: should_release
run: |
if [[ "${{ steps.get_version.outputs.new_version }}" != "" ]]; then
echo "new_release=true" >> $GITHUB_OUTPUT
echo "New version will be: ${{ steps.get_version.outputs.new_version }}"
else
echo "new_release=false" >> $GITHUB_OUTPUT
echo "No new version to release"
fi
- name: Setup .NET
if: steps.should_release.outputs.new_release == 'true'
uses: actions/setup-dotnet@v5
with:
dotnet-version: '9.0.x'
- name: Update version in csproj
if: steps.should_release.outputs.new_release == 'true'
run: |
VERSION=${{ steps.get_version.outputs.new_version }}
sed -i "s|<Version>.*</Version>|<Version>${VERSION}</Version>|g" AutoTestId/AutoTestId.csproj
- name: Restore dependencies
if: steps.should_release.outputs.new_release == 'true'
run: dotnet restore
- name: Build
if: steps.should_release.outputs.new_release == 'true'
run: dotnet build --configuration Release --no-restore
- name: Test
if: steps.should_release.outputs.new_release == 'true'
run: dotnet test --configuration Release --no-build --verbosity normal
- name: Pack
if: steps.should_release.outputs.new_release == 'true'
run: dotnet pack --configuration Release --no-build --output ./artifacts
- name: Generate changelog
if: steps.should_release.outputs.new_release == 'true'
id: changelog
uses: TriPSs/conventional-changelog-action@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
version-file: './AutoTestId/AutoTestId.csproj'
version-path: '//Project/PropertyGroup/Version'
skip-version-file: true
skip-commit: true
output-file: false
- name: Create tag
if: steps.should_release.outputs.new_release == 'true'
uses: mathieudutour/github-tag-action@v6.2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
custom_tag: ${{ steps.get_version.outputs.new_version }}
# - name: Push to NuGet
# if: steps.should_release.outputs.new_release == 'true'
# run: |
# dotnet nuget push ./artifacts/*.nupkg \
# --api-key ${{ secrets.NUGET_API_KEY }} \
# --source https://api.nuget.org/v3/index.json \
# --skip-duplicate
- name: Create GitHub Release
if: steps.should_release.outputs.new_release == 'true'
uses: softprops/action-gh-release@v3
with:
tag_name: v${{ steps.get_version.outputs.new_version }}
name: Release v${{ steps.get_version.outputs.new_version }}
body: ${{ steps.changelog.outputs.clean_changelog }}
files: |
./artifacts/*.nupkg
./artifacts/*.snupkg
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}