-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathazure-pipelines.yml
249 lines (213 loc) · 7.81 KB
/
azure-pipelines.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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
# OC Release
trigger: none
pr: none
schedules:
- cron: "0 */8 * * *" # DAMN BUG!!!!!!!!!!!!!!!!!!!!!!!!!
displayName: Schedule Build
branches:
include:
- master
always: true
variables:
BuildCheck: 'False'
FORCE_INSTALL: 1
BUILD_UTILITIES: 1
DEBUG: 0
pool:
vmImage: 'macOS-latest'
steps:
- task: Bash@3
displayName: Prepare Pipelines
inputs:
targetType: 'inline'
script: |
#!/bin/bash
UserPlusRepo=$(Build.Repository.Name)
Repo=${UserPlusRepo#*/}
echo "##vso[task.setvariable variable=REPO]$Repo"
if [[ $(Build.SourceBranch) != 'refs/heads/master' ]]; then
echo "##vso[task.setvariable variable=DEBUG]1"
echo "DEBUG"
fi
- task: Bash@3
displayName: Check Changes
inputs:
targetType: 'inline'
script: |
#!/bin/bash
BD="$(date +"%Y-%m-%d")" # Build Date
echo "##vso[task.setvariable variable=BuildDate]$BD"
cd ../b || exit 1
mkdir "RepoOperation"
cd "RepoOperation" || exit 1
git clone "$(Build.Repository.Uri).git"
if [[ $DEBUG == 1 ]]; then
cd $(REPO) || exit 1
git checkout $(Build.SourceBranchName)
cd ../
fi
# Clean SHA History Folder
if [[ "$(basename "$(REPO)"/Commits/20*)" != "$BD" ]]; then
rm -rf "$(REPO)"/Commits/20*
mkdir "$(REPO)"/Commits/"$BD"
cp "$(REPO)"/Commits/*.sha1 "$(REPO)"/Commits/"$BD"
fi
# Check and Update commit SHA
function CPSHA() {
local Latest="$(git ls-remote https://github.com/acidanthera/"${2}"Pkg.git HEAD | cut -c1-40)"
local Previous="$(<"$(REPO)"/Commits/"${1}".sha1)"
local Tdy="$(<"$(REPO)"/Commits/"$BD"/"${1}".sha1)"
# Store todays commits for later usage. Dir parallel with RepoOperation, under ./b
echo "${1}cmt=$Tdy" >> ../TdyCommit
if [[ "$Previous" != "$Latest" ]]; then
rm -rf "$(REPO)"/Commits/"${1}".sha1
echo "Changes found in ${2}Pkg"
echo "$Latest" >> "$(REPO)/Commits/"${1}".sha1"
echo "##vso[task.setvariable variable=BuildCheck]True"
else
echo "${2}Pkg up to date"
fi
echo "Latest: $Latest"
echo "Previous: $Previous"
echo "Tdy: $Tdy"
printf "\n"
}
CPSHA OC OpenCore
cat ../TdyCommit
- task: Bash@3
condition: or(eq(variables['BuildCheck'], 'True'), ne(variables['Build.SourceBranch'], 'refs/heads/master'))
displayName: Build OpenCorePkg
inputs:
targetType: 'inline'
script: |
#!/bin/bash
cd ../b
git clone --depth=30 https://github.com/acidanthera/OpenCorePkg.git
cd OpenCorePkg
# Patch Build Tool
curl -# -L -O "https://raw.githubusercontent.com/acidanthera/ocbuild/master/efibuild.sh"
chmod +x efibuild.sh
sed -i -e 's/--depth=1/--depth=30/g' efibuild.sh
sed -i -e 's/.dsc"/.dsc" \| xcpretty/g' efibuild.sh
sed -i -e 's/updaterepo "https\:\/\/github.com\/acidanthera\/audk" UDK master || exit 1/git clone --recursive https\:\/\/github.com\/acidanthera\/audk --depth=1 UDK || exit 1/' efibuild.sh
sed -i -e 's/src=.*/src=\$\(cat efibuild.sh\) \&\& eval \"\$src\" \|\| exit 1/g' build_oc.tool
sed -i -e 's/ARCHS=.*/ARCHS=\(X64\)/g' build_oc.tool
./build_oc.tool
#- task: Bash@3
# condition: or(eq(variables['BuildCheck'], 'True'), ne(variables['Build.SourceBranch'], 'refs/heads/master'))
# displayName: Build AppleSupportPkg
# inputs:
# targetType: 'inline'
# script: |
# #!/bin/bash
# cd ../b/OpenCorePkg/UDK/
# git clone --depth=30 https://github.com/acidanthera/AppleSupportPkg.git
# cd AppleSupportPkg
#
# # Patch Build Tool
# ## Patch efibuild.sh
# cp ../../efibuild.sh .
# sed -i -e 's/ln -s ..\/UDK/ln -s ..\/../g' efibuild.sh
# sed -i -e 's/rm -rf UDK//g' efibuild.sh
# sed -i -e 's/sym=.*/sym=""/g' efibuild.sh
# sed -i -e 's/git clone https:\/\/github.com\/acidanthera\/audk.*//g' efibuild.sh
# sed -i -e 's/cd UDK/cd ..\/..\/UDK/g' efibuild.sh
# sed -i -e 's/ln -s .. ".*/:/g' efibuild.sh
# sed -i -e 's/cd .. \|/cd $ASPDir \|/g' efibuild.sh # Hope this won't break soon
#
# ## Patch build_oc.tool
# sed -i -e 's/"$0")/"$0")\'$'\n''ASPDir=\$PWD/g' build_oc.tool
# sed -i -e 's/src=.*/src=\$\(cat efibuild.sh\) \&\& eval \"\$src\" \|\| exit 1/g' build_oc.tool
#
# ./build_oc.tool
- task: CmdLine@2
condition: and(succeeded(), eq(variables['BuildCheck'], 'True'), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
displayName: Move Binaries
inputs:
script: |
cd ../b/OpenCorePkg
mkdir ../../a/Artifacts
for Artifact in OpenCore; do #AppleSupport
for Tgt in DEBUG RELEASE; do
cp UDK/Build/${Artifact}Pkg/${Tgt}*/X64/${Artifact}*.zip ../../a/Artifacts
done
done
ls $(Build.ArtifactStagingDirectory)/Artifacts
- task: Bash@3
condition: and(succeeded(), or(eq(variables['BuildCheck'], 'True'), ne(variables['Build.SourceBranch'], 'refs/heads/master')))
displayName: Get Commit Notes
inputs:
targetType: 'inline'
script: |
#!/bin/bash
eval $(cat "${PWD}/../b/TdyCommit")
ToMD="$(pwd)/../a/ReleaseNotes.md"
echo "## Changes" >> $ToMD
cd ../b/OpenCorePkg/UDK || exit 1
# Get Commit Notes as Release Notes
function GNotes() {
cd "${2}"Pkg || exit 1
local Count="$(git rev-list --count $(eval echo \$"${1}"cmt)..HEAD)"
if [[ "$Count" != 0 ]]; then
local Note="$(git log -"$Count" --format=" - %s %n")"
echo "Got $Count Notes from ${2}Pkg"
echo "### ${2}Pkg" >> $ToMD || exit 1
echo "$Note" >> $ToMD || exit 1
fi
cd ../
}
GNotes OC OpenCore
# Reformat Release Notes
## Exclude unnecessary links
sed -i -e $'s/http.*//g' $ToMD
sed -i -e '/^$/d' $ToMD
cat $ToMD
- task: CmdLine@2
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq(variables['BuildCheck'], 'True'))
displayName: Refresh Commits
inputs:
script: |
git config --global credential.helper store
echo https://$(PAT):[email protected] >> ~/.git-credentials
git config --global user.name 'Azure Pipelines'
git config --global user.email '<>'
cd ../b/RepoOperation/$(REPO)
git add .
git commit -m "Refresh Commits to $(BuildDate)"
git push origin master
# Gitee Sucks!!
#- task: CmdLine@2
# condition: eq(variables['BuildCheck'], 'True')
# displayName: Publish Gitee Mirror
# inputs:
# script: |
# rm -rf ~/.gitconfig
# rm -rf ~/.git-credentials
# git config --global credential.helper store
# git config --global user.email $(Email)
# git config --global user.name $(User)
# cd ../b
# git clone https://williambj1:$(GiteePAT)@gitee.com/williambj1/$(REPO).git
# cd $(REPO)
# rm -rf OpenCore-Build/*
# cp -R $(Build.ArtifactStagingDirectory)/Artifacts/OpenCore*.zip OpenCore-Build
# cp -R $(Build.ArtifactStagingDirectory)/ReleaseNotes.md OpenCore-Build
# mv OpenCore-Build/ReleaseNotes.md OpenCore-Build/README.md
# git add .
# git commit -m "OpenCore-Build-$(BuildDate)"
# git push origin master
- task: GitHubRelease@0
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq(variables['BuildCheck'], 'True'))
displayName: 'Publish GitHub Release'
inputs:
gitHubConnection: release
repositoryName: '$(Build.Repository.Name)'
action: 'edit'
target: '$(Build.SourceVersion)'
tagSource: 'manual'
tag: '$(BuildDate)'
title: '$(BuildDate)'
releaseNotesFile: '$(Build.ArtifactStagingDirectory)/ReleaseNotes.md'
assets: '$(Build.ArtifactStagingDirectory)/Artifacts/*.zip'
addChangeLog: false
isPreRelease: true