-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automated release #691
Automated release #691
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
name: Release eda-server | ||
|
||
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: Install go-task | ||
run: | | ||
curl -sL https://taskfile.dev/install.sh | sh | ||
mv ./bin/task /usr/local/bin/task | ||
task --version | ||
|
||
- name: Checkout eda-server | ||
uses: actions/checkout@v3 | ||
|
||
- name: Get python version from Taskfile | ||
run: echo py_version=`task PYTHON_VERSION` >> $GITHUB_ENV | ||
|
||
- name: Install python ${{ env.py_version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ env.py_version }} | ||
|
||
- name: Install python deeps | ||
run: pip install -r requirements_dev.txt | ||
|
||
- name: Create release | ||
run: ansible-playbook tools/ansible/release.yml -i localhost -e github_token=${{ secrets.GITHUB_TOKEN }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -355,3 +355,16 @@ tasks: | |
- task: macpodman | ||
vars: | ||
CLI_ARGS: tunnel | ||
|
||
build:release: | ||
desc: "builds all the files needed for a release" | ||
cmds: | ||
- cmd: mkdir -p dist | ||
- cmd: tar -zcvf dist/eda-server.tar.gz LICENSE README.md Taskfile.dist.yaml docs poetry.lock pyproject.toml pytest.ini requirements_dev.txt scripts setup.cfg src tests tools | ||
|
||
|
||
PYTHON_VERSION: | ||
desc: "Return the required python version for build tools" | ||
cmds: | ||
- cmd: echo "3.9" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We moved to python3.11 |
||
silent: true |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ build-backend = "poetry.core.masonry.api" | |
|
||
[tool.poetry] | ||
name = "aap-eda" | ||
version = "0.2.0" | ||
version = "2024.3.4" | ||
description = "" | ||
authors = ["Red Hat, Inc. <info@ansible.com>"] | ||
readme = "README.md" | ||
|
@@ -120,3 +120,25 @@ ban-relative-imports = "parents" | |
|
||
[tool.ruff.pydocstyle] | ||
convention = "pep257" | ||
|
||
[tool.setuptools_scm] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we use poetry for building as it is configured? |
||
version_scheme = "calver-by-date" | ||
|
||
[tool.bumpver] | ||
current_version = "2024.3.4" | ||
version_pattern = "YYYY.MM.DD" | ||
commit_message = "chore: bump version {old_version} -> {new_version}" | ||
tag_message = "{new_version}" | ||
tag_scope = "default" | ||
pre_commit_hook = "" | ||
post_commit_hook = "" | ||
commit = true | ||
tag = true | ||
push = true | ||
|
||
[tool.bumpver.file_patterns] | ||
"pyproject.toml" = [ | ||
'current_version = "{version}"', | ||
'version = "{version}"', | ||
] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ansible | ||
setuptools_scm | ||
bumpver |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
--- | ||
- name: Release eda-server | ||
hosts: localhost | ||
connection: local | ||
gather_facts: true | ||
vars: | ||
repo_identifier: "ansible/eda-server" | ||
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 eda-server root | ||
|
||
tasks: | ||
- name: Generate calver release number | ||
set_fact: | ||
# setuptools-scm will strip leading 0's off the date format so we need to do that too | ||
release_number: "{{ (ansible_date_time.date | to_datetime('%Y-%m-%d')).strftime('%Y.%m.%d') | regex_replace('\\.0', '.') }}" | ||
|
||
- name: Tag the repo | ||
command: | ||
cmd: "git tag -f {{ release_number }}" | ||
|
||
- name: Get the build number from setuptools-scm | ||
command: | ||
cmd: python -m setuptools_scm | ||
register: setuptools_command_version | ||
|
||
- name: Make sure the selected release number and setuptools_scm agree | ||
assert: | ||
that: | ||
release_number == setuptools_command_version.stdout | ||
msg: "We expected the release number to be {{ release_number }} but setuptools-scm wanted it to be {{ setuptools_command_version.stdout }}" | ||
|
||
- name: Build eda-server | ||
command: | ||
cmd: task build:release | ||
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 | ||
status_code: | ||
- 201 | ||
headers: | ||
Accept: 'application/vnd.github.v3+json' | ||
Authorization: 'bearer {{ github_token }}' | ||
register: new_release_response | ||
tags: | ||
- github | ||
|
||
- name: Upload the build files | ||
uri: | ||
# For some reason the upload_url ends with eda-server/releases/138751035/assets{?name,label} | ||
# We have to strip that off before adding our args to the URLs | ||
url: "{{ new_release_response.json['upload_url'] | regex_replace('{.*}', '') }}?name={{ file_name }}" | ||
method: POST | ||
src: "{{ item }}" | ||
status_code: | ||
- 201 | ||
headers: | ||
Accept: 'application/vnd.github.v3+json' | ||
Authorization: 'bearer {{ github_token }}' | ||
Content-Type: "{{ file_name.endswith('tar.gz') | ternary('application/gzip', 'application/x-wheel+zip') }}" | ||
vars: | ||
file_name: "{{ item | basename }}" | ||
loop: "{{ lookup('ansible.builtin.fileglob', '../../dist/*', wantlist=True) }}" | ||
loop_control: | ||
label: "{{ item | basename }}" | ||
tags: | ||
- github |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is missing the build command?