Skip to content

Commit 3060a6b

Browse files
committed
adding ansible playbook for releasing new computate versions easily
1 parent 63e9390 commit 3060a6b

File tree

3 files changed

+304
-0
lines changed

3 files changed

+304
-0
lines changed

computate_new_release.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
- name: Create a new release of the computate software
3+
connection: local
4+
hosts: localhost
5+
roles:
6+
- computate_new_release
7+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
APP_PREFIX: "{{ lookup('env', 'HOME') }}/.local"
3+
4+
COMPUTATE_BASE_NAME: "computate-base"
5+
COMPUTATE_BASE_SRC: "{{ APP_PREFIX }}/src/{{ COMPUTATE_BASE_NAME }}"
6+
7+
COMPUTATE_SEARCH_NAME: "computate-search"
8+
COMPUTATE_SEARCH_SRC: "{{ APP_PREFIX }}/src/{{ COMPUTATE_SEARCH_NAME }}"
9+
10+
COMPUTATE_VERTX_NAME: "computate-vertx"
11+
COMPUTATE_VERTX_SRC: "{{ APP_PREFIX }}/src/{{ COMPUTATE_VERTX_NAME }}"
12+
13+
COMPUTATE_NAME: "computate"
14+
COMPUTATE_SRC: "{{ APP_PREFIX }}/src/{{ COMPUTATE_NAME }}"
15+
+282
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,282 @@
1+
---
2+
3+
#- name: |
4+
# Ensure {{ COMPUTATE_BASE_NAME }} project has no uncommitted changes
5+
# shell:
6+
# cmd: git status -s -uall
7+
# chdir: "{{ COMPUTATE_BASE_SRC }}"
8+
# register: GIT_STATUS_COMPUTATE_BASE
9+
#- fail:
10+
# msg: |
11+
# The {{ COMPUTATE_BASE_NAME }} project has uncommitted changes
12+
# when: GIT_STATUS_COMPUTATE_BASE.stdout_lines | length > 0
13+
14+
- name: |
15+
Ensure {{ COMPUTATE_SEARCH_NAME }} project has no uncommitted changes
16+
shell:
17+
cmd: git status -s -uall
18+
chdir: "{{ COMPUTATE_SEARCH_SRC }}"
19+
register: GIT_STATUS_COMPUTATE_SEARCH
20+
- fail:
21+
msg: |
22+
The {{ COMPUTATE_SEARCH_NAME }} project has uncommitted changes
23+
when: GIT_STATUS_COMPUTATE_SEARCH.stdout_lines | length > 0
24+
25+
- name: |
26+
Ensure {{ COMPUTATE_VERTX_NAME }} project has no uncommitted changes
27+
shell:
28+
cmd: git status -s -uall
29+
chdir: "{{ COMPUTATE_VERTX_SRC }}"
30+
register: GIT_STATUS_COMPUTATE_VERTX
31+
- fail:
32+
msg: |
33+
The {{ COMPUTATE_VERTX_NAME }} project has uncommitted changes
34+
when: GIT_STATUS_COMPUTATE_VERTX.stdout_lines | length > 0
35+
36+
- name: |
37+
Ensure {{ COMPUTATE_NAME }} project has no uncommitted changes
38+
shell:
39+
cmd: git status -s -uall
40+
chdir: "{{ COMPUTATE_SRC }}"
41+
register: GIT_STATUS_COMPUTATE
42+
- fail:
43+
msg: |
44+
The {{ COMPUTATE_NAME }} project has uncommitted changes
45+
when: GIT_STATUS_COMPUTATE.stdout_lines | length > 0
46+
47+
- name: |
48+
Find the current computate version
49+
set_fact:
50+
PREV_VERSION: "{{ lookup('file', COMPUTATE_SRC + '/pom.xml') | regex_search('<version>([^<]+)</version>', '\\1', multiline=True) | first }}"
51+
- name: |
52+
Find the current computate version prefix and suffix
53+
set_fact:
54+
PREV_VERSION_PREFIX: "{{ PREV_VERSION | regex_search('^([\\d\\.]+?\\.)(\\d+)$', '\\1', multiline=True) | first }}"
55+
PREV_VERSION_SUFFIX: "{{ PREV_VERSION | regex_search('^([\\d\\.]+?\\.)(\\d+)$', '\\2', multiline=True) | first }}"
56+
- debug:
57+
var: PREV_VERSION_PREFIX
58+
- debug:
59+
var: PREV_VERSION_SUFFIX
60+
61+
- name: |
62+
Validate NEXT_VERSION specified
63+
fail:
64+
msg: >-
65+
NEXT_VERSION not specified.
66+
Current computate version is {{ PREV_VERSION }}.
67+
Run the playbook again with the NEXT VERSION set:
68+
ansible-playbook computate_new_release.yml -e NEXT_VERSION={{ PREV_VERSION_PREFIX }}{{ (PREV_VERSION_SUFFIX | int) + 1 }}
69+
when: NEXT_VERSION is not defined
70+
71+
- name: |
72+
Update the version in {{ COMPUTATE_BASE_NAME }}/pom.xml from {{ PREV_VERSION }} to {{ NEXT_VERSION }}
73+
ansible.builtin.replace:
74+
path: "{{ COMPUTATE_BASE_SRC }}/pom.xml"
75+
regexp: '>{{ PREV_VERSION }}<'
76+
replace: '>{{ NEXT_VERSION }}<'
77+
- name: |
78+
Ensure {{ COMPUTATE_BASE_NAME }} project has no uncommitted changes
79+
shell:
80+
cmd: git status -s -uall
81+
chdir: "{{ COMPUTATE_BASE_SRC }}"
82+
register: GIT_STATUS_COMPUTATE_BASE_2
83+
- name: |
84+
Run mvn clean install deploy -Pdeploy in {{ COMPUTATE_BASE_NAME }}
85+
shell:
86+
cmd: mvn clean install deploy -Pdeploy
87+
chdir: "{{ COMPUTATE_BASE_SRC }}"
88+
when: GIT_STATUS_COMPUTATE_BASE_2.stdout_lines | length > 0
89+
- name: |
90+
git add {{ COMPUTATE_BASE_NAME }}/pom.xml
91+
shell:
92+
cmd: git add {{ COMPUTATE_BASE_SRC }}/pom.xml
93+
chdir: "{{ COMPUTATE_BASE_SRC }}"
94+
when: GIT_STATUS_COMPUTATE_BASE_2.stdout_lines | length > 0
95+
- name: |
96+
git commit {{ COMPUTATE_BASE_NAME }}/pom.xml
97+
shell:
98+
cmd: git commit -m "Releasing version {{ NEXT_VERSION }}"
99+
chdir: "{{ COMPUTATE_BASE_SRC }}"
100+
when: GIT_STATUS_COMPUTATE_BASE_2.stdout_lines | length > 0
101+
- name: |
102+
git push {{ COMPUTATE_BASE_NAME }}/pom.xml
103+
shell:
104+
cmd: git push
105+
chdir: "{{ COMPUTATE_BASE_SRC }}"
106+
when: GIT_STATUS_COMPUTATE_BASE_2.stdout_lines | length > 0
107+
- name: |
108+
{{ COMPUTATE_BASE_NAME }} git tag {{ NEXT_VERSION }}
109+
shell:
110+
cmd: git tag {{ NEXT_VERSION }}
111+
chdir: "{{ COMPUTATE_BASE_SRC }}"
112+
when: GIT_STATUS_COMPUTATE_BASE_2.stdout_lines | length > 0
113+
- name: |
114+
git push --tags
115+
shell:
116+
cmd: git push --tags
117+
chdir: "{{ COMPUTATE_BASE_SRC }}"
118+
when: GIT_STATUS_COMPUTATE_BASE_2.stdout_lines | length > 0
119+
120+
- name: |
121+
Update the version in {{ COMPUTATE_SEARCH_NAME }}/pom.xml from {{ PREV_VERSION }} to {{ NEXT_VERSION }}
122+
ansible.builtin.replace:
123+
path: "{{ COMPUTATE_SEARCH_SRC }}/pom.xml"
124+
regexp: '>{{ PREV_VERSION }}<'
125+
replace: '>{{ NEXT_VERSION }}<'
126+
- name: |
127+
Ensure {{ COMPUTATE_SEARCH_NAME }} project has no uncommitted changes
128+
shell:
129+
cmd: git status -s -uall
130+
chdir: "{{ COMPUTATE_SEARCH_SRC }}"
131+
register: GIT_STATUS_COMPUTATE_SEARCH_2
132+
- name: |
133+
Run mvn clean install deploy -Pdeploy in {{ COMPUTATE_SEARCH_NAME }}
134+
shell:
135+
cmd: mvn clean install deploy -Pdeploy
136+
chdir: "{{ COMPUTATE_SEARCH_SRC }}"
137+
when: GIT_STATUS_COMPUTATE_SEARCH_2.stdout_lines | length > 0
138+
- name: |
139+
git add {{ COMPUTATE_SEARCH_NAME }}/pom.xml
140+
shell:
141+
cmd: git add {{ COMPUTATE_SEARCH_SRC }}/pom.xml
142+
chdir: "{{ COMPUTATE_SEARCH_SRC }}"
143+
when: GIT_STATUS_COMPUTATE_SEARCH_2.stdout_lines | length > 0
144+
- name: |
145+
git commit {{ COMPUTATE_SEARCH_NAME }}/pom.xml
146+
shell:
147+
cmd: git commit -m "Releasing version {{ NEXT_VERSION }}"
148+
chdir: "{{ COMPUTATE_SEARCH_SRC }}"
149+
when: GIT_STATUS_COMPUTATE_SEARCH_2.stdout_lines | length > 0
150+
- name: |
151+
git push {{ COMPUTATE_SEARCH_NAME }}/pom.xml
152+
shell:
153+
cmd: git push
154+
chdir: "{{ COMPUTATE_SEARCH_SRC }}"
155+
when: GIT_STATUS_COMPUTATE_SEARCH_2.stdout_lines | length > 0
156+
- name: |
157+
{{ COMPUTATE_SEARCH_NAME }} git tag {{ NEXT_VERSION }}
158+
shell:
159+
cmd: git tag {{ NEXT_VERSION }}
160+
chdir: "{{ COMPUTATE_SEARCH_SRC }}"
161+
when: GIT_STATUS_COMPUTATE_SEARCH_2.stdout_lines | length > 0
162+
- name: |
163+
git push --tags
164+
shell:
165+
cmd: git push --tags
166+
chdir: "{{ COMPUTATE_SEARCH_SRC }}"
167+
when: GIT_STATUS_COMPUTATE_SEARCH_2.stdout_lines | length > 0
168+
169+
- name: |
170+
Update the version in {{ COMPUTATE_VERTX_NAME }}/pom.xml from {{ PREV_VERSION }} to {{ NEXT_VERSION }}
171+
ansible.builtin.replace:
172+
path: "{{ COMPUTATE_VERTX_SRC }}/pom.xml"
173+
regexp: '>{{ PREV_VERSION }}<'
174+
replace: '>{{ NEXT_VERSION }}<'
175+
- name: |
176+
Ensure {{ COMPUTATE_VERTX_NAME }} project has no uncommitted changes
177+
shell:
178+
cmd: git status -s -uall
179+
chdir: "{{ COMPUTATE_VERTX_SRC }}"
180+
register: GIT_STATUS_COMPUTATE_VERTX_2
181+
- name: |
182+
Run mvn clean install deploy -Pdeploy in {{ COMPUTATE_VERTX_NAME }}
183+
shell:
184+
cmd: mvn clean install deploy -Pdeploy
185+
chdir: "{{ COMPUTATE_VERTX_SRC }}"
186+
when: GIT_STATUS_COMPUTATE_VERTX_2.stdout_lines | length > 0
187+
- name: |
188+
git add {{ COMPUTATE_VERTX_NAME }}/pom.xml
189+
shell:
190+
cmd: git add {{ COMPUTATE_VERTX_SRC }}/pom.xml
191+
chdir: "{{ COMPUTATE_VERTX_SRC }}"
192+
when: GIT_STATUS_COMPUTATE_VERTX_2.stdout_lines | length > 0
193+
- name: |
194+
git commit {{ COMPUTATE_VERTX_NAME }}/pom.xml
195+
shell:
196+
cmd: git commit -m "Releasing version {{ NEXT_VERSION }}"
197+
chdir: "{{ COMPUTATE_VERTX_SRC }}"
198+
when: GIT_STATUS_COMPUTATE_VERTX_2.stdout_lines | length > 0
199+
- name: |
200+
git push {{ COMPUTATE_VERTX_NAME }}/pom.xml
201+
shell:
202+
cmd: git push
203+
chdir: "{{ COMPUTATE_VERTX_SRC }}"
204+
when: GIT_STATUS_COMPUTATE_VERTX_2.stdout_lines | length > 0
205+
- name: |
206+
{{ COMPUTATE_VERTX_NAME }} git tag {{ NEXT_VERSION }}
207+
shell:
208+
cmd: git tag {{ NEXT_VERSION }}
209+
chdir: "{{ COMPUTATE_VERTX_SRC }}"
210+
when: GIT_STATUS_COMPUTATE_VERTX_2.stdout_lines | length > 0
211+
- name: |
212+
git push --tags
213+
shell:
214+
cmd: git push --tags
215+
chdir: "{{ COMPUTATE_VERTX_SRC }}"
216+
when: GIT_STATUS_COMPUTATE_VERTX_2.stdout_lines | length > 0
217+
218+
- name: |
219+
Update the version in {{ COMPUTATE_NAME }}/pom.xml from {{ PREV_VERSION }} to {{ NEXT_VERSION }}
220+
ansible.builtin.replace:
221+
path: "{{ COMPUTATE_SRC }}/pom.xml"
222+
regexp: '>{{ PREV_VERSION }}<'
223+
replace: '>{{ NEXT_VERSION }}<'
224+
- name: |
225+
Ensure {{ COMPUTATE_NAME }} project has no uncommitted changes
226+
shell:
227+
cmd: git status -s -uall
228+
chdir: "{{ COMPUTATE_SRC }}"
229+
register: GIT_STATUS_COMPUTATE_2
230+
- name: |
231+
Run mvn clean install deploy -Pdeploy in {{ COMPUTATE_NAME }}
232+
shell:
233+
cmd: mvn clean install deploy -Pdeploy
234+
chdir: "{{ COMPUTATE_SRC }}"
235+
when: GIT_STATUS_COMPUTATE_2.stdout_lines | length > 0
236+
- name: |
237+
git add {{ COMPUTATE_NAME }}/pom.xml
238+
shell:
239+
cmd: git add {{ COMPUTATE_SRC }}/pom.xml
240+
chdir: "{{ COMPUTATE_SRC }}"
241+
when: GIT_STATUS_COMPUTATE_2.stdout_lines | length > 0
242+
- name: |
243+
git commit {{ COMPUTATE_NAME }}/pom.xml
244+
shell:
245+
cmd: git commit -m "Releasing version {{ NEXT_VERSION }}"
246+
chdir: "{{ COMPUTATE_SRC }}"
247+
when: GIT_STATUS_COMPUTATE_2.stdout_lines | length > 0
248+
- name: |
249+
git push {{ COMPUTATE_NAME }}/pom.xml
250+
shell:
251+
cmd: git push
252+
chdir: "{{ COMPUTATE_SRC }}"
253+
when: GIT_STATUS_COMPUTATE_2.stdout_lines | length > 0
254+
- name: |
255+
{{ COMPUTATE_NAME }} git tag {{ NEXT_VERSION }}
256+
shell:
257+
cmd: git tag {{ NEXT_VERSION }}
258+
chdir: "{{ COMPUTATE_SRC }}"
259+
when: GIT_STATUS_COMPUTATE_2.stdout_lines | length > 0
260+
- name: |
261+
git push --tags
262+
shell:
263+
cmd: git push --tags
264+
chdir: "{{ COMPUTATE_SRC }}"
265+
when: GIT_STATUS_COMPUTATE_2.stdout_lines | length > 0
266+
267+
- name: |
268+
Create a {{ COMPUTATE_BASE_NAME }} {{ NEXT_VERSION }} tag in GitHub
269+
shell:
270+
cmd: xdg-open https://github.com/computate-org/{{ COMPUTATE_BASE_NAME }}/releases/tag/{{ NEXT_VERSION }}
271+
- name: |
272+
Create a {{ COMPUTATE_SEARCH_NAME }} {{ NEXT_VERSION }} tag in GitHub
273+
shell:
274+
cmd: xdg-open https://github.com/computate-org/{{ COMPUTATE_SEARCH_NAME }}/releases/tag/{{ NEXT_VERSION }}
275+
- name: |
276+
Create a {{ COMPUTATE_VERTX_NAME }} {{ NEXT_VERSION }} tag in GitHub
277+
shell:
278+
cmd: xdg-open https://github.com/computate-org/{{ COMPUTATE_VERTX_NAME }}/releases/tag/{{ NEXT_VERSION }}
279+
- name: |
280+
Create a {{ COMPUTATE_NAME }} {{ NEXT_VERSION }} tag in GitHub
281+
shell:
282+
cmd: xdg-open https://github.com/computate-org/{{ COMPUTATE_NAME }}/releases/tag/{{ NEXT_VERSION }}

0 commit comments

Comments
 (0)