generated from VeyronSakai/RoslynAnalyzerTemplate
-
Notifications
You must be signed in to change notification settings - Fork 0
183 lines (175 loc) · 6.42 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
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
name: Release
on:
pull_request:
types:
- opened
- synchronize
- reopened
- closed
workflow_dispatch:
permissions:
contents: write
pull-requests: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_BOT_NAME: github-actions[bot]
GITHUB_BOT_EMAIL: github-actions[bot]@users.noreply.github.com
PACKAGE_JSON_PATH: VContainerAnalyzer.Unity/Assets/Plugins/VContainerAnalyzer/package.json
ANALYZER_DLL_PATH: VContainerAnalyzer.Unity/Assets/Plugins/VContainerAnalyzer/VContainerAnalyzer.dll
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
jobs:
paths:
name: paths
if: ${{ github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
outputs:
package_json: ${{ steps.filter.outputs.package_json }}
steps:
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
package_json:
- ${{ env.PACKAGE_JSON_PATH }}
draft:
name: draft
if: ${{ (github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'main') || github.event_name == 'workflow_dispatch'}}
runs-on: ubuntu-latest
outputs:
tag_name: ${{ steps.release_drafter.outputs.tag_name }}
steps:
- uses: release-drafter/release-drafter@v6
id: release_drafter
with:
commitish: main
update-files:
name: update-files
needs: draft
if: ${{ github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
env:
VERSION: ${{ needs.draft.outputs.tag_name }}
SOURCE_BRANCH: github-actions/update-files/${{ github.run_number }}
steps:
- uses: actions/checkout@v4
- name: Update package.json
run: |
json_content=$(cat "${PACKAGE_JSON_PATH}")
updated_json=$(echo "${json_content}" | jq --arg version "${VERSION}" '.version = $version')
echo "${updated_json}" | jq '.' > "${PACKAGE_JSON_PATH}"
- name: Commit package.json
uses: EndBug/add-and-commit@v9
id: commit-package-json
with:
author_name: ${{ env.GITHUB_BOT_NAME }}
author_email: ${{ env.GITHUB_BOT_EMAIL }}
message: "Update package.json"
add: ${{ env.PACKAGE_JSON_PATH }}
new_branch: ${{ env.SOURCE_BRANCH }}
- name: Update README.md
run: |
cp -f .github/DRAFT_README.md README.md
- name: Commit README.md
uses: EndBug/add-and-commit@v9
id: commit-readme
with:
author_name: ${{ env.GITHUB_BOT_NAME }}
author_email: ${{ env.GITHUB_BOT_EMAIL }}
message: "Update README.md"
add: "README.md"
new_branch: ${{ env.SOURCE_BRANCH }}
- uses: actions/setup-dotnet@v4
with:
dotnet-version: "7.0.x"
- name: Update VContainerAnalyzer.dll
run: |
make all
- name: Commit VContainerAnalyzer.dll
uses: EndBug/add-and-commit@v9
id: commit-dll
with:
author_name: ${{ env.GITHUB_BOT_NAME }}
author_email: ${{ env.GITHUB_BOT_EMAIL }}
message: "Update VContainerAnalyzer.dll"
add: ${{ env.ANALYZER_DLL_PATH }}
new_branch: ${{ env.SOURCE_BRANCH }}
- name: Create pull request and merge
if: ${{ steps.commit-package-json.outputs.committed == 'true' || steps.commit-readme.outputs.committed == 'true' || steps.commit-dll.outputs.committed == 'true'}}
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
gh pr create --title "Update files for release" --body "Update files for release" --base main --head "${SOURCE_BRANCH}"
gh pr merge "${SOURCE_BRANCH}" --auto --merge
release:
name: release
needs: [draft, paths]
environment: release
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'main' && github.event.pull_request.merged && needs.paths.outputs.package_json == 'true' }}
env:
VERSION: ${{ needs.draft.outputs.tag_name }}
steps:
- uses: actions/checkout@v4
with:
ref: main
- name: Validate version in package.json
run: |
package_version=$(jq -r '.version' "${PACKAGE_JSON_PATH}")
if [[ "${package_version}" != "${VERSION}" ]]; then
echo "::error::version in package.json (${package_version}) does not match the release draft tag (${VERSION})"
exit 1
fi
- uses: release-drafter/release-drafter@v6
id: release-drafter
with:
publish: true
commitish: main
- name: Get semver
id: get-semver
run: |
read -r major minor patch <<< "$(echo "${VERSION}" | grep -oE '^([0-9]+)\.([0-9]+)\.([0-9]+)' | awk -F '.' '{print $1 " " $2 " " $3}')"
{
echo "major=${major}"
echo "minor=${major}.${minor}"
echo "patch=${major}.${minor}.${patch}"
} >> "${GITHUB_OUTPUT}"
- uses: actions/checkout@v4
with:
ref: ${{ env.VERSION }}
- name: Update major tag
if: steps.get-semver.outputs.major != '0'
run: |
git push -f origin "refs/tags/${VERSION}:refs/tags/${{ steps.get-semver.outputs.major }}"
- name: Update minor tag
if: steps.get-semver.outputs.minor != '0.0'
run: |
git push -f origin "refs/tags/${VERSION}:refs/tags/${{ steps.get-semver.outputs.minor }}"
- name: Execute dotnet pack
run: |
dotnet pack ./VContainerAnalyzer/VContainerAnalyzer.csproj \
-c Release \
-p:Version="${VERSION}" \
-p:PackageVersion="${VERSION}" \
-o .
- name: Push to NuGet
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: |
dotnet nuget push "VContainerAnalyzer.${VERSION}.nupkg" \
-s https://api.nuget.org/v3/index.json \
-k "${NUGET_API_KEY}"
- name: Export unitypackage
uses: game-ci/unity-builder@v4
env:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
with:
projectPath: ./VContainerAnalyzer.Unity
targetPlatform: StandaloneLinux64
buildMethod: Editor.PackageExporter.Export
- name: Upload unitypackage
run: |
gh release upload "${VERSION}" "VContainerAnalyzer.Unity/VContainerAnalyzer.unitypackage"