mirror of
https://github.com/ansible/awx.git
synced 2026-03-13 15:09:32 -02:30
Automate release process and changelog generation
This commit is contained in:
8
.github/PULL_REQUEST_TEMPLATE.md
vendored
8
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -1,3 +1,11 @@
|
||||
<!--- changelog-entry
|
||||
# Fill in 'msg' below to have an entry automatically added to the next release changelog.
|
||||
# Leaving 'msg' blank will not generate a changelog entry for this PR.
|
||||
# Please ensure this is a simple (and readable) one-line string.
|
||||
---
|
||||
msg: ""
|
||||
-->
|
||||
|
||||
##### SUMMARY
|
||||
<!--- Describe the change, including rationale and design decisions -->
|
||||
|
||||
|
||||
46
.github/workflows/release.yml
vendored
Normal file
46
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
name: Release AWX
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: 'Version'
|
||||
required: true
|
||||
default: ''
|
||||
confirm:
|
||||
description: 'Are you sure? Set this to yes.'
|
||||
required: true
|
||||
default: 'no'
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: "Verify inputs"
|
||||
run: |
|
||||
set -e
|
||||
|
||||
if [[ ${{ github.event.inputs.confirm }} != "yes" ]]; then
|
||||
>&2 echo "Confirm must be 'yes'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ${{ github.event.inputs.version }} == "" ]]; then
|
||||
>&2 echo "Set version to continue."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
- name: Generate changelog and release AWX
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install -y python3-pip
|
||||
pip3 install ansible-core
|
||||
ansible-playbook -v tools/ansible/release.yml \
|
||||
-e repo=${{ github.repository }} \
|
||||
-e version=${{ github.event.inputs.version }} \
|
||||
-e github_token=${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
|
||||
5
tools/ansible/release.yml
Normal file
5
tools/ansible/release.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
- hosts: localhost
|
||||
connection: local
|
||||
roles:
|
||||
- release
|
||||
2
tools/ansible/roles/release/defaults/main.yml
Normal file
2
tools/ansible/roles/release/defaults/main.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
parsed_changelog_entries: {}
|
||||
79
tools/ansible/roles/release/tasks/main.yml
Normal file
79
tools/ansible/roles/release/tasks/main.yml
Normal file
@@ -0,0 +1,79 @@
|
||||
---
|
||||
- name: Look up latest release of AWX
|
||||
uri:
|
||||
url: "https://api.github.com/repos/{{ repo }}/releases/latest"
|
||||
register: res
|
||||
|
||||
- name: Record latest tag information
|
||||
set_fact:
|
||||
latest_tag: "{{ res.json.name }}"
|
||||
created_at: "{{ res.json.created_at }}"
|
||||
|
||||
- name: Construct search query
|
||||
set_fact:
|
||||
search_query: "{{ ('repo:' + repo + ' type:pr is:merged merged:>=' + created_at) | urlencode }}"
|
||||
|
||||
- name: Find PRs since last release
|
||||
uri:
|
||||
url: "https://api.github.com/search/issues?q={{ search_query }}"
|
||||
headers:
|
||||
Accept: "application/vnd.github.v3+json"
|
||||
register: new_merged_prs
|
||||
|
||||
- name: Search PR descriptions for changelog entries
|
||||
command: awk '/<!--- changelog-entry/{flag=1;next}/-->/{flag=0}flag'
|
||||
args:
|
||||
stdin: "{{ item.body }}"
|
||||
loop: "{{ new_merged_prs.json['items'] }}"
|
||||
changed_when: false
|
||||
register: raw_changelog_entries
|
||||
|
||||
- name: Parse changelog entries
|
||||
set_fact:
|
||||
parsed_changelog_entries: |
|
||||
{{ parsed_changelog_entries | combine({item.item.pull_request.html_url: (item.stdout | from_yaml)}) }}
|
||||
loop: "{{ raw_changelog_entries.results }}"
|
||||
|
||||
- name: Construct final changelog blob
|
||||
set_fact:
|
||||
final_changelog: |
|
||||
{%- set entries = {} -%}
|
||||
{%- for entry in raw_changelog_entries.results -%}
|
||||
{%- set parsed_entry = (entry.stdout | from_yaml) -%}
|
||||
{%- if parsed_entry and parsed_entry.msg != "" -%}
|
||||
{%- set msg = parsed_entry.msg -%}
|
||||
{%- set pr_number = entry.item.number -%}
|
||||
{%- set pr_url = entry.item.pull_request.html_url -%}
|
||||
{%- set contributor_login = entry.item.user.login -%}
|
||||
{%- set contributor_url = entry.item.user.html_url -%}
|
||||
{%- set _ = entries.update({pr_url: {"msg": msg, "pr_number": pr_number, "contributor_login": contributor_login, "contributor_url": contributor_url}}) -%}
|
||||
{%- endif -%}
|
||||
{%- endfor -%}
|
||||
|
||||
{% if entries|length > 0 %}
|
||||
Changes:
|
||||
|
||||
{% endif %}
|
||||
{%- for key, value in entries.items() -%}
|
||||
- {{ value.msg }} ([#{{ value.pr_number }}]({{ key }}), [@{{ value.contributor_login }}]({{ value.contributor_url }}))
|
||||
{% endfor %}
|
||||
|
||||
- name: Prepare Release Data
|
||||
set_fact:
|
||||
payload:
|
||||
body: "{{ final_changelog }}"
|
||||
name: "{{ version }}"
|
||||
tag_name: "{{ version }}"
|
||||
draft: true
|
||||
|
||||
- name: Publish Release
|
||||
uri:
|
||||
url: "https://api.github.com/repos/{{ repo }}/releases"
|
||||
method: "POST"
|
||||
headers:
|
||||
Accept: "application/vnd.github.v3+json"
|
||||
Authorization: "Bearer {{ github_token }}"
|
||||
body: "{{ payload | to_json }}"
|
||||
status_code:
|
||||
- 200
|
||||
- 201
|
||||
Reference in New Issue
Block a user