mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 01:30:20 +00:00
Some improvements and fixes to the release diff step
Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
This commit is contained in:
parent
8d5a309fa0
commit
d235e83c15
4 changed files with 117 additions and 95 deletions
58
.github/actions/release-changes/action.yml
vendored
58
.github/actions/release-changes/action.yml
vendored
|
@ -1,58 +0,0 @@
|
||||||
---
|
|
||||||
name: release-changes
|
|
||||||
description: Create release changes diff
|
|
||||||
inputs:
|
|
||||||
salt-version:
|
|
||||||
type: string
|
|
||||||
required: true
|
|
||||||
description: The Salt version to set prior to creating the release changes
|
|
||||||
|
|
||||||
env:
|
|
||||||
COLUMNS: 160
|
|
||||||
|
|
||||||
runs:
|
|
||||||
using: composite
|
|
||||||
|
|
||||||
steps:
|
|
||||||
|
|
||||||
- name: Update Debian changelog
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
tools changelog update-deb --draft
|
|
||||||
tools changelog update-deb
|
|
||||||
|
|
||||||
- name: Update RPM changelog
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
tools changelog update-rpm --draft
|
|
||||||
tools changelog update-rpm
|
|
||||||
|
|
||||||
- name: Update Release Notes
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
tools changelog update-release-notes --draft
|
|
||||||
tools changelog update-release-notes
|
|
||||||
|
|
||||||
- name: Update CHANGELOG.md
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
tools changelog update-release-notes --draft
|
|
||||||
tools changelog update-release-notes
|
|
||||||
|
|
||||||
- name: Update CHANGELOG.md
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
tools docs man
|
|
||||||
|
|
||||||
- name: Create release changes diff
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
git diff --no-color > salt-${{ inputs.salt-version }}.diff
|
|
||||||
|
|
||||||
- name: Upload Source Tarball as an Artifact
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: salt-${{ inputs.salt-version }}.diff
|
|
||||||
path: salt-${{ inputs.salt-version }}.diff
|
|
||||||
retention-days: 7
|
|
||||||
if-no-files-found: error
|
|
30
.github/workflows/ci.yml
vendored
30
.github/workflows/ci.yml
vendored
|
@ -219,40 +219,22 @@ jobs:
|
||||||
with:
|
with:
|
||||||
changed-files: ${{ needs.prepare-workflow.outputs.changed-files }}
|
changed-files: ${{ needs.prepare-workflow.outputs.changed-files }}
|
||||||
|
|
||||||
release-changes:
|
prepare-release:
|
||||||
name: Create Release Diff
|
name: Create Release Diff
|
||||||
if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['github-hosted-runners'] }}
|
if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['github-hosted-runners'] }}
|
||||||
needs:
|
needs:
|
||||||
- prepare-workflow
|
- prepare-workflow
|
||||||
runs-on: ubuntu-latest
|
uses: ./.github/workflows/prepare-release.yml
|
||||||
steps:
|
with:
|
||||||
- uses: actions/checkout@v3
|
cache-seed: ${{ needs.prepare-workflow.outputs.cache-seed }}
|
||||||
|
salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}"
|
||||||
- name: Set up Python 3.10
|
|
||||||
uses: actions/setup-python@v4
|
|
||||||
with:
|
|
||||||
python-version: "3.10"
|
|
||||||
|
|
||||||
- name: Setup Python Tools Scripts
|
|
||||||
uses: ./.github/actions/setup-python-tools-scripts
|
|
||||||
|
|
||||||
- name: Setup Salt Version
|
|
||||||
id: setup-salt-version
|
|
||||||
uses: ./.github/actions/setup-salt-version
|
|
||||||
with:
|
|
||||||
salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}"
|
|
||||||
|
|
||||||
- name: Generate Changes Diff
|
|
||||||
uses: ./.github/actions/release-changes
|
|
||||||
with:
|
|
||||||
salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}"
|
|
||||||
|
|
||||||
build-source-tarball:
|
build-source-tarball:
|
||||||
name: Build Source Tarball
|
name: Build Source Tarball
|
||||||
if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['github-hosted-runners'] }}
|
if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['github-hosted-runners'] }}
|
||||||
needs:
|
needs:
|
||||||
- prepare-workflow
|
- prepare-workflow
|
||||||
- release-changes
|
- prepare-release
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
98
.github/workflows/prepare-release.yml
vendored
Normal file
98
.github/workflows/prepare-release.yml
vendored
Normal file
|
@ -0,0 +1,98 @@
|
||||||
|
name: Prepare Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
salt-version:
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
description: The Salt version to set prior to creating the release diff.
|
||||||
|
cache-seed:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
description: Seed used to invalidate caches
|
||||||
|
python-version:
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
default: "3.10"
|
||||||
|
|
||||||
|
env:
|
||||||
|
COLUMNS: 160
|
||||||
|
PIP_INDEX_URL: https://pypi-proxy.saltstack.net/root/local/+simple/
|
||||||
|
PIP_EXTRA_INDEX_URL: https://pypi.org/simple
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Prepare Release
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Set up Python ${{ inputs.python-version }}
|
||||||
|
uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: "${{ inputs.python-version }}"
|
||||||
|
|
||||||
|
- name: Cache Python Tools Virtualenvs
|
||||||
|
id: nox-dependencies-cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: .tools-venvs/
|
||||||
|
key: ${{ inputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ inputs.python-version }}|${{ hashFiles('requirements/**/*.txt') }}
|
||||||
|
|
||||||
|
- name: Setup Python Tools Scripts
|
||||||
|
uses: ./.github/actions/setup-python-tools-scripts
|
||||||
|
|
||||||
|
- name: Setup Salt Version
|
||||||
|
id: setup-salt-version
|
||||||
|
uses: ./.github/actions/setup-salt-version
|
||||||
|
with:
|
||||||
|
salt-version: "${{ inputs.salt-version }}"
|
||||||
|
|
||||||
|
- name: Update Debian changelog
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
tools changelog update-deb --draft
|
||||||
|
tools changelog update-deb
|
||||||
|
|
||||||
|
- name: Update RPM changelog
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
tools changelog update-rpm --draft
|
||||||
|
tools changelog update-rpm
|
||||||
|
|
||||||
|
- name: Update Release Notes
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
tools changelog update-release-notes --draft
|
||||||
|
tools changelog update-release-notes
|
||||||
|
|
||||||
|
- name: Generate MAN Pages
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
tools docs man
|
||||||
|
|
||||||
|
- name: Update Changelog
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
tools changelog update-changelog-md --draft
|
||||||
|
tools changelog update-changelog-md
|
||||||
|
|
||||||
|
- name: Show Changes Diff
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
git diff --color
|
||||||
|
|
||||||
|
- name: Create release changes diff
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
git diff --no-color > salt-${{ inputs.salt-version }}.diff
|
||||||
|
|
||||||
|
- name: Upload Source Tarball as an Artifact
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: salt-${{ inputs.salt-version }}.diff
|
||||||
|
path: salt-${{ inputs.salt-version }}.diff
|
||||||
|
retention-days: 7
|
||||||
|
if-no-files-found: error
|
|
@ -36,7 +36,7 @@ cl = command_group(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def changelog(ctx: Context, version: str):
|
def _get_changelog_contents(ctx: Context, version: str):
|
||||||
"""
|
"""
|
||||||
Return the full changelog generated by towncrier.
|
Return the full changelog generated by towncrier.
|
||||||
"""
|
"""
|
||||||
|
@ -49,11 +49,11 @@ def changelog(ctx: Context, version: str):
|
||||||
).stdout.decode()
|
).stdout.decode()
|
||||||
|
|
||||||
|
|
||||||
def pkg_changelog(ctx: Context, version: str):
|
def _get_pkg_changelog_contents(ctx: Context, version: str):
|
||||||
"""
|
"""
|
||||||
Return a version of the changelog entries suitable for packaged changelogs.
|
Return a version of the changelog entries suitable for packaged changelogs.
|
||||||
"""
|
"""
|
||||||
changes = changelog(ctx, version)
|
changes = _get_changelog_contents(ctx, version)
|
||||||
changes = "\n".join(changes.split("\n")[2:])
|
changes = "\n".join(changes.split("\n")[2:])
|
||||||
changes = changes.replace(
|
changes = changes.replace(
|
||||||
textwrap.dedent(
|
textwrap.dedent(
|
||||||
|
@ -108,7 +108,7 @@ def pkg_changelog(ctx: Context, version: str):
|
||||||
return changes
|
return changes
|
||||||
|
|
||||||
|
|
||||||
def version():
|
def _get_salt_version():
|
||||||
return (
|
return (
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["python3", "salt/version.py"], stdout=subprocess.PIPE, check=True
|
["python3", "salt/version.py"], stdout=subprocess.PIPE, check=True
|
||||||
|
@ -136,8 +136,8 @@ def version():
|
||||||
)
|
)
|
||||||
def update_rpm(ctx: Context, salt_version: str, draft: bool = False):
|
def update_rpm(ctx: Context, salt_version: str, draft: bool = False):
|
||||||
if salt_version is None:
|
if salt_version is None:
|
||||||
salt_version = version()
|
salt_version = _get_salt_version()
|
||||||
changes = pkg_changelog(ctx, salt_version)
|
changes = _get_pkg_changelog_contents(ctx, salt_version)
|
||||||
ctx.info("Salt version is %s", salt_version)
|
ctx.info("Salt version is %s", salt_version)
|
||||||
orig = ctx.run(
|
orig = ctx.run(
|
||||||
"sed",
|
"sed",
|
||||||
|
@ -186,8 +186,8 @@ def update_rpm(ctx: Context, salt_version: str, draft: bool = False):
|
||||||
)
|
)
|
||||||
def update_deb(ctx: Context, salt_version: str, draft: bool = False):
|
def update_deb(ctx: Context, salt_version: str, draft: bool = False):
|
||||||
if salt_version is None:
|
if salt_version is None:
|
||||||
salt_version = version()
|
salt_version = _get_salt_version()
|
||||||
changes = pkg_changelog(ctx, salt_version)
|
changes = _get_pkg_changelog_contents(ctx, salt_version)
|
||||||
formated = "\n".join([f" {_.replace('-', '*', 1)}" for _ in changes.split("\n")])
|
formated = "\n".join([f" {_.replace('-', '*', 1)}" for _ in changes.split("\n")])
|
||||||
dt = datetime.datetime.utcnow()
|
dt = datetime.datetime.utcnow()
|
||||||
date = dt.strftime("%a, %d %b %Y %H:%M:%S +0000")
|
date = dt.strftime("%a, %d %b %Y %H:%M:%S +0000")
|
||||||
|
@ -229,14 +229,14 @@ def update_deb(ctx: Context, salt_version: str, draft: bool = False):
|
||||||
)
|
)
|
||||||
def update_release_notes(ctx: Context, salt_version: str, draft: bool = False):
|
def update_release_notes(ctx: Context, salt_version: str, draft: bool = False):
|
||||||
if salt_version is None:
|
if salt_version is None:
|
||||||
salt_version = version()
|
salt_version = _get_salt_version()
|
||||||
if "+" in salt_version:
|
if "+" in salt_version:
|
||||||
major_version = salt_version.split("+", 1)[0]
|
major_version = salt_version.split("+", 1)[0]
|
||||||
else:
|
else:
|
||||||
major_version = salt_version
|
major_version = salt_version
|
||||||
changes = changelog(ctx, salt_version)
|
changes = _get_changelog_contents(ctx, salt_version)
|
||||||
changes = "\n".join(changes.split("\n")[2:])
|
changes = "\n".join(changes.split("\n")[2:])
|
||||||
tmpnotes = f"doc/topics/releases/{version}.rst.tmp"
|
tmpnotes = f"doc/topics/releases/{salt_version}.rst.tmp"
|
||||||
try:
|
try:
|
||||||
with open(f"doc/topics/releases/{major_version}.rst") as rfp:
|
with open(f"doc/topics/releases/{major_version}.rst") as rfp:
|
||||||
existing = rfp.read()
|
existing = rfp.read()
|
||||||
|
@ -274,8 +274,8 @@ def update_release_notes(ctx: Context, salt_version: str, draft: bool = False):
|
||||||
)
|
)
|
||||||
def generate_changelog_md(ctx: Context, salt_version: str, draft: bool = False):
|
def generate_changelog_md(ctx: Context, salt_version: str, draft: bool = False):
|
||||||
if salt_version is None:
|
if salt_version is None:
|
||||||
salt_version = version()
|
salt_version = _get_salt_version()
|
||||||
cmd = ["towncrier", "build", f"--version={version}"]
|
cmd = ["towncrier", "build", f"--version={salt_version}"]
|
||||||
if draft:
|
if draft:
|
||||||
cmd += ["--draft"]
|
cmd += ["--draft"]
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Reference in a new issue