-
Notifications
You must be signed in to change notification settings - Fork 1
/
azure-pipelines.yml
190 lines (147 loc) · 6.16 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
trigger:
- release/*
pr: none
variables:
- group: Passwords
- group: SoftwareVersions
- group: ChangelogIds
- group: ConfluencePages
parameters:
- name: flutterArVersion
displayName: Set Flutter Ar plugin Version
type: string
default: "0.0.0"
resources:
repositories:
- repository: sys_kubernetes_templates
type: bitbucket
endpoint: Bitbucket - sistemas
name: situm/sys-kubernetes-templates.git
pool:
vmImage: $(ubuntuVersion)
steps:
- checkout: self
fetchTags: false
fetchDepth: 1
displayName: Checkout self
- ${{ if eq(variables['Build.Reason'],'manual') }}:
- bash: |
if [[ "${{ parameters.flutterArVersion }}" == "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.flutterArVersion }})"
echo -e "\n[+] I'm a shy step so I don't tell you anything\n"
fi
displayName: Set Flutter Version Manual
- ${{ if ne(variables['Build.Reason'],'manual') }}:
- bash: |
FlutterArVersion=$(echo $(Build.SourceBranch) | cut -d "/" -f 4)
echo "##vso[task.setvariable variable=version]$(echo $FlutterArVersion)"
echo -e "\n[+] I'm a shy step that only executes where this pipeline run automatic\n"
displayName: Set Flutter Version Automatic
- bash: |
if [ -d "flutter-ar" ];then
cd flutter-ar
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[+] Flutter Plugin version: $(version)"
echo -e "\t[+] Current branch: $currentBranch"
echo -e "\n[+] Setting git to push flutter version\n"
git config --global user.email "sistemas@situm.es"
git config --global user.name "Situmops"
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: |
mkdir $(Agent.BuildDirectory)/binaries
cd $(Agent.BuildDirectory)/binaries
echo -e "\n[+] Download Flutter version $(flutterLinuxVersion)\n"
wget -q $(flutterLinuxVersion)
echo -e "\n[+] Untar Flutter version\n"
find . -iname "*.tar.xz" -exec tar xf {} \;
echo -e "\n[+] Download gcloud cli version $(gcloudCliVersion)\n"
curl -O $(gcloudCliVersion)
echo -e "\n[+] Untar gcloud Cli version\n"
find . -iname "*.tar.gz" -exec tar xzf {} \;
displayName: Install Binaries
- bash: |
if [ -d "flutter-ar" ];then
cd flutter-ar
fi
#Export binary paths
export PATH="$PATH:$(Agent.BuildDirectory)/binaries/flutter/bin"
export PATH="$PATH:$(Agent.BuildDirectory)/binaries/google-cloud-sdk/bin"
echo -e "\n[+] Fetch all branches\n"
git fetch
echo -e "\n[+] Checkout to $(currentBranch)\n"
git checkout $(currentBranch)
echo -e "\n[+] Change version in pubspec.yaml\n"
sed "s/^version:\s[0-9].*$/version: $(version)/g" -i pubspec.yaml
echo -e "\n[+] Change version in situm_flutter_ar.podspec"
sed "s/s.version\s.*= '[0-9\.].*'$/s.version = '$(version)'/g" -i ios/situm_flutter_ar.podspec
echo -e "\n[+] Set new plugin version in examples"
cd example
flutter pub get
echo -e "\n[+] Add,commit and push changes to $(currentBranch)"
git pull origin $(currentBranch)
git commit -am "[skip ci] Setting the Flutter AR version to $(version)"
git push --set-upstream origin $(currentBranch)
git push
displayName: Set version
- template: azure-templates/publish_release.yml@sys_kubernetes_templates
parameters:
bitbucket:
bitbucket_user: situmops
system: "N/A"
server: "github"
repofolder: "flutter-ar"
mergeBranches:
- "main"
- "develop"
- task: DownloadSecureFile@1
name: key_file
inputs:
secureFile: key-file.json
- bash: |
# Describe the login process
# 1. Download the key-file.json: File with Google credentials to connect via gcloud cli
# 2. Autenticate gcloud: Autenticate with gcloud cli using the credentials file.
# 3. Autenticate pub.dev: Generar a temporary token against pub.dev that will be used to publish the packages
# More info: https://dart.dev/tools/pub/automated-publishing#publish-from-anywhere-using-a-service-account
cp $(key_file.secureFilePath) .
export PATH="$PATH:$(Agent.BuildDirectory)/binaries/flutter/bin"
export PATH="$PATH:$(Agent.BuildDirectory)/binaries/google-cloud-sdk/bin"
echo -e "\n[+] Login with key-file.json\n"
gcloud auth activate-service-account --key-file=key-file.json
rm -rf key-file.json
echo -e "\n[+] Create temporary token \n"
gcloud auth print-identity-token --audiences=https://pub.dev | dart pub token add https://pub.dev
if [ -d "flutter-ar" ];then
cd flutter-ar
fi
echo -e "\n[+] Publish flutter package\n"
dart pub publish --force
displayName: Publish packages
#Comment steps for future works
#
# - ${{ if ne(variables['Build.Reason'],'manual') }}:
# - template: azure-templates/publish-changelog.yaml@sys_kubernetes_templates
# parameters:
# changelogId: $(Flutter_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: FLUTTER_SDK_TABLE
# confluence_release_page: $(FLUTTER_SDK_TABLE)
# confluence_release_page_title: "SDK Automatic Release Table - Flutter Plugin"
# bitbucket:
# bitbucket_user: $(bitbucket_user)
# bitbucket_pass: $(bitbucket_pass)
#