-
Notifications
You must be signed in to change notification settings - Fork 6
/
azure-pipelines.yml
222 lines (180 loc) · 8.05 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
trigger:
- release/*
pr: none
pool:
vmImage: ubuntu-latest
parameters:
- name: RNVersion
type: string
displayName: React Native Plugin Version
default: "0.0.0"
variables:
- group: Passwords
- group: ConfluencePages
- group: ChangelogIds
resources:
repositories:
- repository: sys_kubernetes_templates
type: bitbucket
endpoint: Bitbucket - sistemas
name: situm/sys-kubernetes-templates.git
ref: master
- repository: web_developers
type: bitbucket
endpoint: Bitbucket - sistemas
name: situm/web-developers.git
ref: master
steps:
- ${{ if contains(variables['Build.SourceBranch'], 'release/') }}:
- checkout: self
fetchDepth: 1
fetchTags: false
displayName: Checkout self
- ${{ if eq(variables['Build.Reason'],'manual') }}:
- bash: |
if [[ "${{ parameters.RNVersion }}" == "0.0.0" ]];then
echo -e "\n[!] IMPORTANT: You don't set the plugin version when you run the release branch and I'm not fortune teller\n"
exit 1
else
echo "##vso[task.setvariable variable=version]$(echo ${{ parameters.RNVersion }})"
echo -e "\n[+] I'm a shy step so I don't tell you anything\n"
fi
displayName: Set RN Version Manual
- ${{ if ne(variables['Build.Reason'],'manual') }}:
- bash: |
RNVersion=$(echo $(Build.SourceBranch) | cut -d "/" -f 4)
echo "##vso[task.setvariable variable=version]$(echo $RNVersion)"
echo -e "\n[+] I'm a shy step that only executes where this pipeline run automatic\n"
displayName: Set RN Version Automatic
- bash: |
if [ -d "react-native" ];then
cd react-native
fi
currentBranch=$(echo $(Build.SourceBranch) | cut -d "/" -f 3,4)
echo "##vso[task.setvariable variable=currentBranch]$(echo $currentBranch)"
echo -e "\n[+] Defined versions:"
echo -e "\t[+] NPM cli version: $(npm --version)"
echo -e "\t[+] React Native Plugin version: $(version)"
echo -e "\t[+] Current branch: $currentBranch"
echo -e "\n[+] Setting git remote credentials\n"
git remote set-url origin https://situmops:$(github_token)@github.com/$(Build.Repository.Name).git
cat .git/config
displayName: Initial Vars & Configs
- bash: |
if [ -d "react-native" ];then
cd react-native
fi
echo -e "\n[+] Setting NPM version to $(version)"
npm version $(version) --no-git-tag-version
echo -e "\n[+] Setting git to push NPM version\n"
git config --global user.email "[email protected]"
git config --global user.name "Situmops"
echo -e "\n[+] Fetch branches \n"
git fetch
echo -e "\n[+] Changing to $(currentBranch)"
git checkout $(currentBranch)
echo -e "\n[+] Add,Commit and Push to $(currentBranch)"
git commit -am "[skip ci] Setting the React Native version to $(version)"
git push --set-upstream origin $(currentBranch)
git push
displayName: Make changes
- template: azure-templates/publish_release.yml@sys_kubernetes_templates
parameters:
bitbucket:
bitbucket_user: situmops
system: "N/A"
server: "github"
repoFolder: "react-native"
mergeBranches:
- "master"
- "develop"
- bash: |
if [ -d "react-native" ];then
cd react-native
fi
echo -e "\n[+] Fetch all branches\n"
git fetch
echo -e "\n[+] Checkout and Pull to master branch\n"
git checkout master
git pull origin master
echo -e "\n[+] Installing yarn dependencies\n"
yarn install
echo -e "\n[+] Configure NPM login"
echo "//registry.npmjs.org/:_authToken=$(NPM_TOKEN)" > ~/.npmrc
echo -e "\n[+] Publish NPM packages"
npm publish
displayName: NPM publish
- template: azure-templates/commit-doc.yaml@sys_kubernetes_templates
parameters:
version: $(version)
docPath: "sdk_documentation/react-native"
system: "react-native"
release: "react-native"
developersBranch: "master"
bitbucket:
bitbucket_user: $(bitbucket_user)
bitbucket_pass: $(bitbucket_pass)
- bash: |
if [ -d "react-native" ];then
cd react-native
fi
#
#IMPORTANT: This code performs the following steps:
#- Switches to the master branch in the situm-react-native-plugin repository.
#- Stores the values of the android and iOS SDK in the androidsdk and iossdk variables respectively.
#- Switches to the previous commit of the master branch in the situm-react-native-plugin repository.
#- Stores the values of the android and iOS SDK in the androidsdk_old and iossdk_old variables respectively.
#- Compares the values, and if they have changed, publishes the new version in bold format.
#- From the previous comparation it sets the SDK version and pass it (if is necessary) to template to publish changelog
echo -e "\n[+] Pull master changes and change to master branch \n"
git fetch
git checkout master
git pull origin master
androidsdk=$(grep -oE '"android": "[0-9]+\.[0-9]+\.[0-9]+@aar"' package.json | awk -F'["@]' '{print $4}')
iossdk=$(grep -oE '"ios": "[0-9]+\.[0-9]+\.[0-9]+"' package.json | awk -F'"' '{print $4}')
echo -e "\n[+] Checkout to previous commit\n"
git checkout HEAD~1
androidsdk_old=$(grep -oE '"android": "[0-9]+\.[0-9]+\.[0-9]+@aar"' package.json | awk -F'["@]' '{print $4}')
iossdk_old=$(grep -oE '"ios": "[0-9]+\.[0-9]+\.[0-9]+"' package.json | awk -F'"' '{print $4}')
echo -e "\n[+] Return repository to master branch\n"
git checkout master
echo -e "\n[+] Versions:"
echo -e "\t[+] RN SDK: $(version)"
echo -e "\t[+] ANDROID SDK: $androidsdk"
echo -e "\t[+] IOS SDK: $iossdk"
echo -e "\t[+] ANDROID SDK (OLD VERSION): $androidsdk_old"
echo -e "\t[+] IOS SDK (OLD IOS): $iossdk_old"
versions="| *VERSIÓN* | *FECHA* | *ANDROID SDK* | *IOS SDK* |\n|$(version)|$(date +"%d/%m/%Y")|"
if [ "$androidsdk" != "$androidsdk_old" ];then
versions="$versions *$androidsdk* |"
android_changelog_version=$androidsdk
else
android_changelog_version="0.0.0"
versions="$versions $androidsdk|"
fi
if [ "$iossdk" != "$iossdk_old" ];then
versions="$versions *$iossdk*|"
ios_changelog_version=$iossdk
else
ios_changelog_version="0.0.0"
versions="$versions $iossdk|"
fi
echo "##vso[task.setvariable variable=versions]$(echo $versions)"
echo "##vso[task.setvariable variable=android_changelog_version]$(echo $android_changelog_version)"
echo "##vso[task.setvariable variable=ios_changelog_version]$(echo $ios_changelog_version )"
displayName: Get Versions
- ${{ if ne(variables['Build.Reason'],'manual') }}:
- template: azure-templates/publish-changelog.yaml@sys_kubernetes_templates
parameters:
changelogId: $(RNSDK_Changelog_id)
android_changelog_version: $(android_changelog_version)
ios_changelog_version: $(ios_changelog_version)
- template: azure-templates/release-table.yaml@sys_kubernetes_templates
parameters:
versions: $(versions)
releaseTable: RN_SDK_TABLE
confluence_release_page: $(RN_SDK_TABLE)
confluence_release_page_title: "SDK Automatic Release Table - React Native Plugin"
bitbucket:
bitbucket_user: $(bitbucket_user)
bitbucket_pass: $(bitbucket_pass)