Skip to content

Commit

Permalink
Update CI
Browse files Browse the repository at this point in the history
Required PR: pulp/pulp_container#355

[noissue]
  • Loading branch information
goosemania committed Jul 2, 2021
1 parent 656586d commit eff5426
Show file tree
Hide file tree
Showing 6 changed files with 179 additions and 7 deletions.
79 changes: 79 additions & 0 deletions .github/workflows/create-branch.yml
@@ -0,0 +1,79 @@
# WARNING: DO NOT EDIT!
#
# This file was generated by plugin_template, and is managed by it. Please use
# './plugin-template --github pulp_2to3_migration' to update this file.
#
# For more info visit https://github.com/pulp/plugin_template
---
name: Create New Release Branch
on:
workflow_dispatch:
inputs:
name:
description: "Branch name (e.g. 3.14)"
required: true

env:
RELEASE_WORKFLOW: true

jobs:
create-branch:
runs-on: ubuntu-latest

strategy:
fail-fast: false

steps:
- uses: actions/checkout@v2
with:
# by default, it uses a depth of 1
# this fetches all history so that we can read each commit
fetch-depth: 0

- uses: actions/setup-python@v2
with:
python-version: "3.7"

- name: Install python dependencies
run: |
echo ::group::PYDEPS
pip install bump2version
echo ::endgroup::
- name: Setting secrets
run: python3 .github/workflows/scripts/secrets.py "$SECRETS_CONTEXT"
env:
SECRETS_CONTEXT: ${{ toJson(secrets) }}

- name: Verify that branch name matches current version string on master branch
run: |
X_Y_VERSION=$(grep version setup.py | sed -rn 's/version="(.*)\.0\.dev",/\1/p' | awk '{$1=$1};1')
if [[ "$X_Y_VERSION" != "${{ github.event.inputs.name }}" ]]
then
echo "Branch name doesn't match the current version string $X_Y_VERSION."
exit 1
fi
- name: Create ${{ github.event.inputs.name }} release branch
run: |
git checkout -b ${{ github.event.inputs.name }}
git push origin ${{ github.event.inputs.name }}
- name: Bump version on master branch
run: |
git checkout master
bump2version --no-commit minor
- name: Make a PR with version bump
uses: peter-evans/create-pull-request@v3
with:
committer: pulpbot <pulp-infra@redhat.com>
author: pulpbot <pulp-infra@redhat.com>
branch: minor-version-bump
base: master
title: Bump minor version
body: '[noissue]'
commit-message: |
Bump minor version
[noissue]
delete-branch: true
34 changes: 33 additions & 1 deletion .github/workflows/release.yml
Expand Up @@ -37,7 +37,7 @@ jobs:
- name: Install python dependencies
run: |
echo ::group::PYDEPS
pip install bandersnatch bump2version gitpython python-redmine towncrier wheel
pip install bandersnatch bump2version gitpython python-redmine towncrier==19.9.0 wheel
echo ::endgroup::
- name: Configure Git with pulpbot name and email
Expand Down Expand Up @@ -198,6 +198,11 @@ jobs:
with:
ruby-version: "2.6"

- name: Configure Git with pulpbot name and email
run: |
git config --global user.name 'pulpbot'
git config --global user.email 'pulp-infra@redhat.com'
- name: Untar repository
run: |
shopt -s dotglob
Expand All @@ -217,6 +222,12 @@ jobs:
env:
SECRETS_CONTEXT: ${{ toJson(secrets) }}

- name: Install python dependencies
run: |
echo ::group::PYDEPS
pip install gitpython python-redmine
echo ::endgroup::
- name: Push branch and tag to GitHub
run: bash .github/workflows/scripts/push_branch_and_tag_to_github.sh ${{ github.event.inputs.release }}
- name: Download built docs
Expand Down Expand Up @@ -250,8 +261,29 @@ jobs:

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

- name: Update Redmine
run: bash .ci/scripts/update_redmine.sh

- name: Create release on GitHub
run: bash .github/workflows/scripts/create_release_from_tag.sh ${{ github.event.inputs.release }}

- name: Cleanup repository before making changelog PR
run: rm -rf .lock generation pulp_2to3_migration_client* *-client.tar pulp-2to3-migration.tar todo web docs.tar

- name: Stage changelog for master branch
run: python .github/workflows/scripts/stage-changelog-for-master.py ${{ github.event.inputs.release }}

- name: Create Pull Request for Changelog
uses: peter-evans/create-pull-request@v3
with:
committer: pulpbot <pulp-infra@redhat.com>
author: pulpbot <pulp-infra@redhat.com>
branch: ${{ github.event.inputs.release }}-changelog
base: master
title: 'Building changelog for ${{ github.event.inputs.release }}'
body: '[noissue]'
commit-message: |
Building changelog for ${{ github.event.inputs.release }}
[noissue]
delete-branch: true
2 changes: 1 addition & 1 deletion .github/workflows/scripts/install_python_client.sh
Expand Up @@ -37,7 +37,7 @@ then
fi

cd ../pulp-openapi-generator

rm -rf pulp_2to3_migration-client
./generate.sh pulp_2to3_migration python $VERSION
cd pulp_2to3_migration-client
python setup.py sdist bdist_wheel --python-tag py3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scripts/install_ruby_client.sh
Expand Up @@ -35,7 +35,7 @@ then
fi

cd ../pulp-openapi-generator

rm -rf pulp_2to3_migration-client
./generate.sh pulp_2to3_migration ruby $VERSION
cd pulp_2to3_migration-client
gem build pulp_2to3_migration_client
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/scripts/script.sh
Expand Up @@ -77,7 +77,8 @@ if [[ "$TEST" = 'bindings' ]]; then
./generate.sh pulp_file ruby 0
cd pulp_file-client
gem build pulp_file_client.gemspec
gem install --bot ./pulp_file_client-0.gem
gem install --both ./pulp_file_client-0.gem
cd ..
fi
./generate.sh pulp_container python
pip install ./pulp_container-client
Expand All @@ -86,7 +87,8 @@ if [[ "$TEST" = 'bindings' ]]; then
./generate.sh pulp_container ruby 0
cd pulp_container-client
gem build pulp_container_client.gemspec
gem install --bot ./pulp_container_client-0.gem
gem install --both ./pulp_container_client-0.gem
cd ..
fi
./generate.sh pulp_rpm python
pip install ./pulp_rpm-client
Expand All @@ -95,7 +97,8 @@ if [[ "$TEST" = 'bindings' ]]; then
./generate.sh pulp_rpm ruby 0
cd pulp_rpm-client
gem build pulp_rpm_client.gemspec
gem install --bot ./pulp_rpm_client-0.gem
gem install --both ./pulp_rpm_client-0.gem
cd ..
fi
./generate.sh pulp_deb python
pip install ./pulp_deb-client
Expand All @@ -104,7 +107,8 @@ if [[ "$TEST" = 'bindings' ]]; then
./generate.sh pulp_deb ruby 0
cd pulp_deb-client
gem build pulp_deb_client.gemspec
gem install --bot ./pulp_deb_client-0.gem
gem install --both ./pulp_deb_client-0.gem
cd ..
fi
cd $REPO_ROOT

Expand Down
57 changes: 57 additions & 0 deletions .github/workflows/scripts/stage-changelog-for-master.py
@@ -0,0 +1,57 @@
# WARNING: DO NOT EDIT!
#
# This file was generated by plugin_template, and is managed by it. Please use
# './plugin-template --github pulp_2to3_migration' to update this file.
#
# For more info visit https://github.com/pulp/plugin_template

import argparse
import os
import textwrap

from git import Repo


helper = textwrap.dedent(
"""\
Stage the changelog for a release on master branch.
Example:
$ python .github/workflows/scripts/stage-changelog-for-master.py 3.4.0
"""
)

parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter, description=helper)

parser.add_argument(
"release_version",
type=str,
help="The version string for the release.",
)

args = parser.parse_args()

release_version_arg = args.release_version

release_path = os.path.dirname(os.path.abspath(__file__))
plugin_path = release_path.split("/.github")[0]

print(f"\n\nRepo path: {plugin_path}")
repo = Repo(plugin_path)

changelog_commit = None
# Look for a commit with the requested release version
for commit in repo.iter_commits():
if f"Building changelog for {release_version_arg}\n" in commit.message:
changelog_commit = commit
break

if not changelog_commit:
raise RuntimeError("Changelog commit for {release_version_arg} was not found.")

git = repo.git
git.stash()
git.checkout("origin/master")
git.cherry_pick(changelog_commit.hexsha)
git.reset("origin/master")

0 comments on commit eff5426

Please sign in to comment.