forked from ansible/django-ansible-base
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from john-westcott-iv/dab_releases
Dab releases
- Loading branch information
Showing
6 changed files
with
118 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
name: Release django-ansible-base | ||
|
||
env: | ||
LC_ALL: "C.UTF-8" # prevent ERROR: Ansible could not initialize the preferred locale: unsupported locale setting | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
stage: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 90 | ||
permissions: | ||
packages: write | ||
contents: write | ||
steps: | ||
- name: Checkout dab | ||
uses: actions/checkout@v3 | ||
with: | ||
path: dab | ||
|
||
- name: Create release | ||
working-directory: dab | ||
run: | | ||
ansible-playbook tools/ansible/release.yml -e github_token=${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
try: | ||
from ._version import version | ||
except ImportError: | ||
version = '0.0.0.dev' | ||
|
||
from typing import Tuple, Union | ||
|
||
VERSION_TUPLE = Tuple[Union[int, str], ...] | ||
|
||
__version__: str | ||
__version_tuple__: VERSION_TUPLE | ||
version_tuple: VERSION_TUPLE | ||
|
||
__version__ = version | ||
__version_tuple__ = version_tuple = tuple(version.split('.')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
version = '0.0.0.dev' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
--- | ||
- name: Release django-ansible-base | ||
hosts: localhost | ||
connection: local | ||
gather_facts: true | ||
vars: | ||
repo_identifier: "john-westcott-iv/django-ansible-base" | ||
api_repo_prefix: "https://api.github.com/repos/{{ repo_identifier }}" | ||
|
||
# Note: | ||
# When this playbook runs it will run in the directory of the playbook so ../../ would be a reference to the django-ansible-base root | ||
|
||
tasks: | ||
- name: Generate calver release number | ||
set_fact: | ||
release_number: "{{ ansible_date_time.year }}.{{ ansible_date_time.month }}.{{ ansible_date_time.day }}" | ||
|
||
- name: "Update version file with {{ release_number }}" | ||
ansible.builtin.lineinfile: | ||
create: True | ||
line: "version = '{{ release_number }}'" | ||
path: "../../ansible_base/_version.py" | ||
regex: "^version = .*" | ||
|
||
- name: Build django-ansible-base | ||
command: | ||
cmd: make build | ||
creates: 'dist/django-ansible-base-{{ release_number }}.tar.gz' | ||
args: | ||
chdir: '../../' | ||
tags: | ||
- build | ||
|
||
- name: Create release in github | ||
uri: | ||
url: "{{ api_repo_prefix }}/releases" | ||
method: POST | ||
body_format: json | ||
body: | ||
tag_name: "{{ release_number }}" | ||
name: "v{{ release_number }}" | ||
draft: False | ||
generate_release_notes: True | ||
make_latest: True | ||
headers: | ||
Accept: 'application/vnd.github.v3+json' | ||
Authorization: 'bearer {{ github_token }}' | ||
register: new_release_response | ||
tags: | ||
- github | ||
|
||
- name: Upload the build files | ||
debug: | ||
msg: "{{ file_name }}" | ||
uri: | ||
url: "{{ new_release_response.json['upload_url'] }}?name={{ file_name }}" | ||
method: POST | ||
src: "dist/{{ file_name }}" | ||
headers: | ||
Accept: 'application/vnd.github.v3+json' | ||
Authorization: 'bearer {{ github_token }}' | ||
vars: | ||
file_name: "{{ item | basename }}" | ||
loop: "{{ lookup('ansible.builtin.fileglob', '../../dist/*', wantlist=True) }}" | ||
loop_control: | ||
label: "{{ item | basename }}" | ||
tags: | ||
- github |