Skip to content

Commit

Permalink
Check in dist summary changes
Browse files Browse the repository at this point in the history
  • Loading branch information
scarletcafe committed Jul 22, 2022
1 parent 13dbeeb commit 78069f8
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 9 deletions.
21 changes: 14 additions & 7 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
python-version: [ '3.8', '3.9', '3.10' ]
python-version: [ '3.8', '3.9', '3.10', '3.11.0-alpha - 3.11.0' ]
discord-py:
- {NAME: 'pypi', PIP_TARGET: 'discord.py[voice]'}
- {NAME: 'git', PIP_TARGET: 'discord.py[voice] @ git+https://github.com/Rapptz/discord.py@master'}
Expand Down Expand Up @@ -73,12 +73,6 @@ jobs:
run: |
cd docs && make html
- name: Create distribution manifest
shell: bash
run: |
export tag_name="${GITHUB_REF##*/}"
python create_dist_summary.py
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
Expand All @@ -97,6 +91,17 @@ jobs:
fetch-depth: 0
submodules: true

- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: 3.10

- name: Install dependencies
shell: bash
run: |
python -m pip install --upgrade pip setuptools wheel
pip install -U -r requirements/publish.txt
- name: Download artifacts
uses: actions/download-artifact@v2
with:
Expand All @@ -109,6 +114,8 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -x
export tag_name="${GITHUB_REF##*/}"
python create_dist_summary.py
assets=()
for asset in ./dist/*.{whl,egg,tar.gz}; do
assets+=("-a" "$asset")
Expand Down
54 changes: 54 additions & 0 deletions create_dist_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,65 @@
SOFTWARE.
"""

import hashlib
import os
import pathlib
import subprocess
import typing

import pkg_resources
from jinja2 import Environment
from jinja2.environment import Template
from jinja2.loaders import BaseLoader


class File(typing.NamedTuple):
"""
Artifact file descriptor
"""
name: str
md5: str
sha1: str
sha256: str


ENVIRONMENT = Environment(loader=BaseLoader())
FILES: typing.List[File] = []

for file in pathlib.Path('dist').iterdir():
if file.is_file() and file.name.lower().endswith(('.whl', '.egg', '.tar.gz')):
with open(file, 'rb') as fp:
data = fp.read()

FILES.append(File(
name=file.name,
md5=hashlib.md5(data).hexdigest(),
sha1=hashlib.sha1(data).hexdigest(),
sha256=hashlib.sha256(data).hexdigest()
))

process = subprocess.Popen(
['git', 'tag', '-l', '--sort=version:refname'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)

tags, err = process.communicate()
tags = tags.decode('utf-8').strip().split('\n')

while tags[-1].lower().strip() == (os.getenv('tag_name') or '').lower().strip():
tags.pop(-1)

last_version = tags[-1]

process = subprocess.Popen(
['git', 'rev-parse', '--short', 'HEAD'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)

commit_hash, err = process.communicate()
commit_hash = commit_hash.decode('utf-8').strip()

with open('dist_summary.jinja2', 'r', encoding='utf-8') as fp:
template: Template = ENVIRONMENT.from_string(fp.read())
Expand All @@ -41,6 +92,9 @@
output = template.render(
env=os.getenv,
package=pkg_resources.get_distribution('jishaku'),
files=FILES,
last_version=last_version,
commit_hash=commit_hash,
)

# Jinja loves obliterating trailing newlines
Expand Down
22 changes: 21 additions & 1 deletion dist_summary.jinja2
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
jishaku {{ package.version }}

https://pypi.org/project/jishaku/{{ package.version }}/
https://github.com/Gorialis/jishaku/tree/{{ env('tag_name') }}
{{ env('GITHUB_SERVER_URL') }}/{{ env('GITHUB_REPOSITORY') }}/tree/{{ env('tag_name') }}

https://jishaku.readthedocs.io/en/latest/whatsnew.html#version-{{ package.version.replace('.', '-') }}

Built by {{ env('GITHUB_SERVER_URL') }}/{{ env('GITHUB_REPOSITORY') }}/actions/runs/{{ env('GITHUB_RUN_ID') }} (triggered by {{ env('GITHUB_ACTOR') }})

[New commits since {{ last_version }}]({{ env('GITHUB_SERVER_URL') }}/{{ env('GITHUB_REPOSITORY') }}/compare/{{ last_version }}...{{ commit_hash }})

It is advised that you install jishaku directly through the pip package manager.

Install the latest version of jishaku:
Expand All @@ -17,3 +22,18 @@ pip install -U jishaku=={{ package.version }}
```

Artifacts are included with this release for debugging convenience.

<details>
<summary>Artifact hashes</summary>
{% for file in files %}
### {{file.name}}

MD5: `{{file.md5}}`

SHA1: `{{file.sha1}}`

SHA256: `{{file.sha256}}`

{% endfor %}

</details>
2 changes: 1 addition & 1 deletion jishaku/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class VersionInfo(typing.NamedTuple):
serial: int


version_info = VersionInfo(major=2, minor=5, micro=0, releaselevel='final', serial=0)
version_info = VersionInfo(major=2, minor=5, micro=1, releaselevel='final', serial=0)

__author__ = 'Gorialis'
__copyright__ = 'Copyright 2021 Devon (Gorialis) R'
Expand Down

0 comments on commit 78069f8

Please sign in to comment.