Skip to content

Commit

Permalink
Devide the release process in two parts
Browse files Browse the repository at this point in the history
This will first run a workflow that performs the "git-actions", like
creating the changelog, bumping the version and tagging.
Secondly the tag itself will trigger a publish workflow that will build
packages and docs and publish them to the corresponding places.

[noissue]
  • Loading branch information
mdellweg committed Nov 22, 2023
1 parent b889ae0 commit 40e11c3
Show file tree
Hide file tree
Showing 4 changed files with 174 additions and 202 deletions.
2 changes: 0 additions & 2 deletions plugin-template
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,6 @@ def write_template_section(config, name, plugin_root_dir, verbose=False):
for relative_path in generate_relative_path_set(section_template_dir):
if not config["stalebot"] and "stale" in relative_path:
continue
if config["issue_tracker"] != "github" and "update_github" in relative_path:
continue
if config["use_issue_template"] is False and "ISSUE_TEMPLATE" in relative_path:
continue
if config["kanban"] is False and "kanban" in relative_path:
Expand Down
172 changes: 172 additions & 0 deletions templates/github/.github/workflows/publish.yml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
{% include 'header.j2' %}
{% from 'macros.j2' import
set_env_vars,
checkout,
setup_python,
setup_ruby,
install_httpie,
display_logs,
run_script,
set_secrets,
install_python_deps,
configure_git,
with context %}
---
name: {{ plugin_app_label | camel }} Publish Release
on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]"

defaults:
run:
working-directory: "{{ plugin_name }}"

jobs:
build-bindings-docs:
needs: build-artifacts
runs-on: ubuntu-latest
# Install scripts expect TEST to be set, 'docs' is most appropriate even though we don't run tests
env:
TEST: docs
PLUGIN_VERSION: {{ "${{ github.ref_name }}" }}

steps:
{{ checkout(depth=1, path=plugin_name) | indent(6) }}

{{ setup_python() | indent(6) }}

{%- if deploy_client_to_rubygems %}
{{ setup_ruby() | indent(6) }}
{%- endif %}

{{ install_httpie() | indent(6) }}

# Building the bindings and docs requires accessing the OpenAPI specs endpoint, so we need to
# setup the Pulp instance.
{{ run_script(name="Before Install", file="before_install.sh") | indent(6) }}

{{ run_script(name="Install", file="install.sh") | indent(6) }}

{{ run_script(name="Install Python client", file="install_python_client.sh", withenv=False) | indent(6) }}

{%- if deploy_client_to_rubygems %}
{{ run_script(name="Install Ruby client", file="install_ruby_client.sh", withenv=False) | indent(6) }}
{%- endif %}

- name: Upload python client packages
uses: actions/upload-artifact@v3
with:
name: python-client.tar
path: python-client.tar

- name: Upload python client docs
uses: actions/upload-artifact@v3
with:
name: python-client-docs.tar
path: python-client-docs.tar

{%- if deploy_client_to_rubygems %}
- name: Upload ruby client packages
uses: actions/upload-artifact@v3
with:
name: ruby-client.tar
path: ruby-client.tar
{%- endif %}

{%- if publish_docs_to_pulpprojectdotorg and docs_test %}
- name: Build docs
run: |
export DJANGO_SETTINGS_MODULE=pulpcore.app.settings
export PULP_SETTINGS=$PWD/.ci/ansible/settings/settings.py
make -C docs/ PULP_URL="{{ pulp_scheme }}://pulp" diagrams html
tar -cvf docs/docs.tar docs/_build

- name: Upload built docs
uses: actions/upload-artifact@v3
with:
name: docs.tar
path: docs/docs.tar
{%- endif %}

{{ display_logs() | indent(6) }}


publish:
runs-on: ubuntu-latest
needs: build-bindings-docs

env:
TEST: publish
GITHUB_TOKEN: {{ "${{ secrets.GITHUB_TOKEN }}" }}

steps:
- uses: actions/download-artifact@v3
with:
name: {{ plugin_name }}.tar

{{ setup_python(pyversion="3.8") | indent(6) }}

{{ setup_ruby() | indent(6) }}

{{ configure_git() | indent(6) }}

- name: Untar repository
run: |
tar -xf {{ plugin_name }}.tar

{{ set_secrets() | indent(6) }}

{{ install_python_deps("gitpython requests packaging~=21.3") | indent(6) }}

{%- if publish_docs_to_pulpprojectdotorg and docs_test %}

- name: Download built docs
uses: actions/download-artifact@v3
with:
name: docs.tar

- name: Download Python client docs
uses: actions/download-artifact@v3
with:
name: python-client-docs.tar

- name: Publish docs to pulpproject.org
run: |
tar -xvf docs.tar
.github/workflows/scripts/publish_docs.sh tag {{ "${{ github.ref_name }}" }}
{%- endif %}

{%- if deploy_to_pypi %}
- name: Deploy plugin to pypi
run: bash .github/workflows/scripts/publish_plugin_pypi.sh {{ "${{ github.ref_name }}" }}
{%- endif %}

{%- if deploy_client_to_pypi %}
- name: Download Python client
uses: actions/download-artifact@v3
with:
name: python-client.tar

- name: Untar python client packages
run: tar -xvf python-client.tar

- name: Publish client to pypi
run: bash .github/workflows/scripts/publish_client_pypi.sh
{%- endif %}

{%- if deploy_client_to_rubygems %}
- name: Download Ruby client
uses: actions/download-artifact@v3
with:
name: ruby-client.tar

- name: Untar Ruby client packages
run: tar -xvf ruby-client.tar

- name: Publish client to rubygems
run: bash .github/workflows/scripts/publish_client_gem.sh
{%- endif %}

- name: Create release on GitHub
run: bash .github/workflows/scripts/create_release_from_tag.sh {{ "${{ github.ref_name }}" }}
Loading

0 comments on commit 40e11c3

Please sign in to comment.