mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 01:30:20 +00:00
Add release diff action
This commit is contained in:
parent
f4a572b603
commit
a4be22e9e1
6 changed files with 112 additions and 31 deletions
11
.github/actions/build-source-tarball/action.yml
vendored
11
.github/actions/build-source-tarball/action.yml
vendored
|
@ -18,6 +18,17 @@ runs:
|
|||
run: |
|
||||
nox --version || python3 -m pip install nox==${{ inputs.nox-version }}
|
||||
|
||||
- name: Download Release Changes
|
||||
uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: salt-${{ env.SALT_VERSION }}.diff
|
||||
|
||||
- name: Apply release changes
|
||||
shell: bash
|
||||
run: |
|
||||
git apply salt-${{ env.SALT_VERSION }}.diff
|
||||
rm salt-${{ env.SALT_VERSION }}.diff
|
||||
|
||||
- name: Create Source Tarball
|
||||
shell: bash
|
||||
run: |
|
||||
|
|
50
.github/actions/release-changes/action.yml
vendored
Normal file
50
.github/actions/release-changes/action.yml
vendored
Normal file
|
@ -0,0 +1,50 @@
|
|||
---
|
||||
name: release-changes
|
||||
description: Create release changes diff
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
|
||||
steps:
|
||||
|
||||
- name: Pip Install Tools Requirements
|
||||
shell: bash
|
||||
run: |
|
||||
pip3 install -r $(pwd)/requirements/static/ci/py3.10/tools.txt
|
||||
pip3 install -r $(pwd)/requirements/static/ci/py3.10/changelog.txt
|
||||
|
||||
- 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: |
|
||||
git diff --no-color > salt-${{ env.SALT_VERSION }}.diff
|
||||
|
||||
- name: Upload Source Tarball as an Artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: salt-${{ env.SALT_VERSION }}.diff
|
||||
path: salt-${{ env.SALT_VERSION }}.diff
|
||||
retention-days: 7
|
6
.github/workflows/build-deb-packages.yml
vendored
6
.github/workflows/build-deb-packages.yml
vendored
|
@ -42,18 +42,12 @@ jobs:
|
|||
apt update
|
||||
apt install -y python3 python3-venv python3-pip build-essential devscripts debhelper bash-completion
|
||||
|
||||
- name: Pip Install Tools Requirements
|
||||
run: |
|
||||
pip3 install -r $(pwd)/requirements/static/ci/py3.10/tools.txt
|
||||
pip3 install -r $(pwd)/requirements/static/ci/py3.10/changelog.txt
|
||||
|
||||
- name: Build Deb
|
||||
env:
|
||||
SALT_ONEDIR_ARCHIVE: "${{ github.workspace }}/build-deb-pkg/artifacts/salt-${{ inputs.salt-version }}-onedir-linux-${{ matrix.arch }}.tar.xz"
|
||||
run: |
|
||||
cd build-deb-pkg
|
||||
echo "${{ inputs.salt-version }}" > salt/_version.txt
|
||||
tools changelog update-deb
|
||||
ln -sf pkg/debian/ .
|
||||
debuild -e SALT_ONEDIR_ARCHIVE -uc -us
|
||||
|
||||
|
|
6
.github/workflows/build-rpm-packages.yml
vendored
6
.github/workflows/build-rpm-packages.yml
vendored
|
@ -40,17 +40,11 @@ jobs:
|
|||
yum -y update
|
||||
yum -y install python3 python3-pip openssl git rpmdevtools rpmlint systemd-units libxcrypt-compat
|
||||
|
||||
- name: Pip Install Tools Requirements
|
||||
run: |
|
||||
pip3 install -r $(pwd)/requirements/static/ci/py3.10/tools.txt
|
||||
pip3 install -r $(pwd)/requirements/static/ci/py3.10/changelog.txt
|
||||
|
||||
- name: Build RPM
|
||||
env:
|
||||
SALT_ONEDIR_ARCHIVE: "${{ github.workspace }}/artifacts/salt-${{ inputs.salt-version }}-onedir-linux-${{ matrix.arch }}.tar.xz"
|
||||
run: |
|
||||
echo "${{ inputs.salt-version }}" > salt/_version.txt
|
||||
tools changelog update-rpm
|
||||
rpmbuild -bb --define="_salt_src $(pwd)" $(pwd)/pkg/rpm/salt.spec
|
||||
|
||||
- name: Upload RPMs
|
||||
|
|
27
.github/workflows/ci.yml
vendored
27
.github/workflows/ci.yml
vendored
|
@ -219,11 +219,38 @@ jobs:
|
|||
with:
|
||||
changed-files: ${{ needs.prepare-workflow.outputs.changed-files }}
|
||||
|
||||
release-changes:
|
||||
name: Create release diff
|
||||
if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['github-hosted-runners'] }}
|
||||
needs:
|
||||
- prepare-workflow
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- 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
|
||||
|
||||
build-source-tarball:
|
||||
name: Build Source Tarball
|
||||
if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['github-hosted-runners'] }}
|
||||
needs:
|
||||
- prepare-workflow
|
||||
- release-changes
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
|
|
@ -25,13 +25,12 @@ def changelog(version):
|
|||
"""
|
||||
Return the full changelog generated by towncrier.
|
||||
"""
|
||||
proc = subprocess.run(
|
||||
return subprocess.run(
|
||||
["towncrier", "build", "--draft", f"--version={version}"],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
check=True,
|
||||
)
|
||||
return proc.stdout.decode()
|
||||
).stdout.decode()
|
||||
|
||||
|
||||
def pkg_changelog(version):
|
||||
|
@ -94,10 +93,13 @@ def pkg_changelog(version):
|
|||
|
||||
|
||||
def version():
|
||||
proc = subprocess.run(
|
||||
["python3", "-m", "salt.version"], stdout=subprocess.PIPE, check=True
|
||||
return (
|
||||
subprocess.run(
|
||||
["python3", "salt/version.py"], stdout=subprocess.PIPE, check=True
|
||||
)
|
||||
.stdout.decode()
|
||||
.strip()
|
||||
)
|
||||
return proc.stdout.decode().strip()
|
||||
|
||||
|
||||
@cl.command(
|
||||
|
@ -120,13 +122,14 @@ def update_rpm(ctx: Context, salt_version: str, draft: bool = False):
|
|||
if salt_version is None:
|
||||
salt_version = version()
|
||||
changes = pkg_changelog(salt_version)
|
||||
proc = subprocess.run(
|
||||
["sed", f"s/Version: .*/Version: {salt_version}/g", "pkg/rpm/salt.spec"],
|
||||
stdout=subprocess.PIPE,
|
||||
ctx.info("Salt version is %s", salt_version)
|
||||
orig = ctx.run(
|
||||
"sed",
|
||||
f"s/Version: .*/Version: {salt_version}/g",
|
||||
"pkg/rpm/salt.spec",
|
||||
capture=True,
|
||||
check=True,
|
||||
)
|
||||
orig = proc.stdout.decode()
|
||||
|
||||
).stdout.decode()
|
||||
dt = datetime.datetime.utcnow()
|
||||
date = dt.strftime("%a %b %d %Y")
|
||||
header = f"* {date} Salt Project Packaging <saltproject-packaging@vmware.com> - {salt_version}\n"
|
||||
|
@ -186,7 +189,7 @@ def update_deb(ctx: Context, salt_version: str, draft: bool = False):
|
|||
if draft:
|
||||
ctx.info(rfp.read())
|
||||
else:
|
||||
with open("pkg/deb/changelog", "w") as wfp:
|
||||
with open("pkg/debian/changelog", "w") as wfp:
|
||||
wfp.write(rfp.read())
|
||||
finally:
|
||||
os.remove(tmpchanges)
|
||||
|
@ -214,7 +217,7 @@ def update_release_notes(ctx: Context, salt_version: str, draft: bool = False):
|
|||
if "+" in salt_version:
|
||||
major_version = salt_version.split("+", 1)[0]
|
||||
else:
|
||||
major_vesrion = salt_version
|
||||
major_version = salt_version
|
||||
changes = changelog(salt_version)
|
||||
changes = "\n".join(changes.split("\n")[2:])
|
||||
tmpnotes = f"doc/topics/releases/{version}.rst.tmp"
|
||||
|
@ -231,14 +234,14 @@ def update_release_notes(ctx: Context, salt_version: str, draft: bool = False):
|
|||
if draft:
|
||||
ctx.info(rfp.read())
|
||||
else:
|
||||
with open(f"doc/topics/releases/{version}.rst", "w") as wfp:
|
||||
with open(f"doc/topics/releases/{salt_version}.rst", "w") as wfp:
|
||||
wfp.write(rfp.read())
|
||||
finally:
|
||||
os.remove(tmpnotes)
|
||||
|
||||
|
||||
@cl.command(
|
||||
name="generate-changelog-md",
|
||||
name="update-changelog-md",
|
||||
arguments={
|
||||
"salt_version": {
|
||||
"help": (
|
||||
|
@ -256,8 +259,10 @@ def update_release_notes(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:
|
||||
salt_version = version()
|
||||
cmd = ["towncrier", "build", "--version={version}"]
|
||||
cmd = ["towncrier", "build", f"--version={version}"]
|
||||
if draft:
|
||||
cmd += ["--draft"]
|
||||
proc = subprocess.run(cmd, stdout=subprocess.PIPE, check=True)
|
||||
return proc.stdout.decode()
|
||||
else:
|
||||
cmd += ["--yes"]
|
||||
ctx.run(*cmd, check=True)
|
||||
ctx.run("git", "restore", "--staged", "CHANGELOG.md", "changelog/", check=True)
|
||||
|
|
Loading…
Add table
Reference in a new issue