-
Notifications
You must be signed in to change notification settings - Fork 221
154 lines (120 loc) · 4.24 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
148
149
150
151
152
153
154
name: Release
on:
push:
branches:
- 'main'
paths:
- 'CHANGELOG.md'
env:
GITHUB_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }}
OWNER_NAME: ${{ github.repository_owner }}
REPO_NAME: ${{ github.event.repository.name }}
OWNER_ID: ${{ github.event.repository.owner.node_id }}
REPO_ID: ${{ github.event.repository.node_id }}
PR_ID: ${{ github.event.pull_request.node_id }}
PROJECT_NAME: ${{ github.event.repository.name }}_VNext
concurrency: ci-${{ github.ref }}
jobs:
#Get Version
prepare_check:
runs-on: ubuntu-latest
env:
WORKER_NAME: VERSION_SCANNER
outputs:
releaseVersion: ${{steps.scanner.outputs.RELEASE_VERSION}}
releasePackString: ${{steps.outter.outputs.RELEASE_PACK_STRING}}
hasNugetKey: ${{steps.outter.outputs.HAS_NUGET_KEY}}
hasCoverageKey: ${{steps.outter.outputs.HAS_COVERAGE_KEY}}
steps:
- uses: actions/checkout@v4
#- name: 🔨 Setup .NET 6.X SDK
# uses: actions/setup-dotnet@v3
# with:
# dotnet-version: '6.x'
- name: 📡 Scan Prepare Enviroment
id: scanner
run: dotnet test './test/workflow/Workflow.Runner' --nologo -c Release
- name: 🙂 Output ReleaseVersion
id: outter
run: |
if [ "${{ steps.scanner.outputs.RELEASE_VERSION }}" == "" ]; then
echo "未扫描到版本号,请核对 CHANGELOD 文档!"
exit 1
fi
echo "RELEASE_PACK_STRING=${{github.event.repository.name}}_Release_v${{ steps.scanner.outputs.RELEASE_VERSION }}" >> "$GITHUB_OUTPUT"
if [ "${{ secrets.NUGET_KEY }}" == "" ]; then
echo "HAS_NUGET_KEY=false" >> $GITHUB_OUTPUT
else
echo "HAS_NUGET_KEY=true" >> $GITHUB_OUTPUT
fi
#Archive Project
archive_project:
runs-on: ubuntu-latest
needs: prepare_check
env:
GITHUB_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }}
PROJECT_ARCHIVE_NAME: ${{ needs.prepare_check.outputs.releasePackString }}
WORKER_NAME: PROJECT_ARCHIVE
steps:
- uses: actions/checkout@v4
#- name: 🔨 Setup .NET 6.X SDK
# uses: actions/setup-dotnet@v3
# with:
# dotnet-version: '6.x'
- name: 📄 Achive Project
run: dotnet test './test/workflow/Workflow.Runner' --nologo -c Release
publish:
runs-on: ubuntu-latest
needs: prepare_check
steps:
- uses: actions/checkout@v4
- name: 🔨 Setup .NET SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
3.1.x
5.0.x
6.0.x
7.0.x
8.0.x
9.0.x
- name: ✊ Release Dll
run: dotnet build -c Release
- name: 🚦 Check & Pack Nuget
run: dotnet test './test/workflow/Workflow.Nuget.Publish' --nologo --no-restore --no-build -c Release
- name: 📶 Push to Nuget
if: ${{ needs.prepare_check.outputs.hasNugetKey == 'true' }}
run: dotnet nuget push *.nupkg -k ${{ secrets.NUGET_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate
release:
runs-on: ubuntu-latest
needs: prepare_check
env:
RELEASE_VERSION: ${{needs.prepare_check.outputs.releaseVersion}}
PACK_STRING: ${{needs.prepare_check.outputs.releasePackString}}
steps:
- uses: actions/checkout@v4
- name: 🎉 Release
run: |
RELEASE_ID=$(gh api graphql -H "X-Github-Next-Global-ID: 1" -f query='
query{
repository(owner:"${{github.repository_owner}}",name:"${{github.event.repository.name}}"){
release(tagName:"v${{env.RELEASE_VERSION}}"){
id
}
}
}' --jq '.data.repository.release.id')
RESULT=0
if [ "$RELEASE_ID" != "" ]; then
if [ "$RELEASE_ID" != "null" ]; then
RESULT=1
fi
fi
if [ $RESULT == 0 ]; then
echo "::debug::no release package"
echo "不存在 Id ,开始创建 Release v${{env.RELEASE_VERSION}} 包!"
gh release create v${{env.RELEASE_VERSION}} -F CHANGELOG.md
else
echo "::debug::exist release package"
echo "该 Release v${{env.RELEASE_VERSION}} 包已存在!"
gh release edit v${{env.RELEASE_VERSION}} --notes-file CHANGELOG.md
fi