Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Refactor) Switch to latest release message builder #121

Merged
merged 3 commits into from
Nov 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.9.13
- run: pip install pipenv
- run: pipenv run install_linters
- run: pipenv run check
2 changes: 0 additions & 2 deletions .github/workflows/package-updates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ jobs:
ssh-key: ${{ secrets.SSH_PRIVATE_KEY }}

- uses: actions/setup-python@v4
with:
python-version: 3.9.13

- run: cp Pipfile.lock{,.bak}
- run: pip install pipenv wheel --upgrade
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/release-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ jobs:

steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4

- run: pip install semver
Expand Down
23 changes: 16 additions & 7 deletions .github/workflows/release_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
).get(DEPLOY_STATUS or "pending")
action_url = f"{github_url}/actions/runs/{GITHUB_RUN_ID}"

image_html_re = re.compile(r'<img.*?alt="(.*?)".*?src="(.*?)".*?>')
image_md_re = re.compile(r"!\[(.*?)\]\((.*?)\)")

release_re = re.compile(
r"""
^\#+\s
Expand Down Expand Up @@ -68,10 +71,10 @@ def build_message():
"type": "plain_text",
"text": text,
},
"image_url": image,
"image_url": url,
"alt_text": text,
}
for text, image in images
for text, url in images
],
}

Expand All @@ -97,6 +100,10 @@ def build_message():
}


def find_images(text):
return image_html_re.findall(text) + image_md_re.findall(text)


def get_images(release):
images = []

Expand All @@ -118,10 +125,9 @@ def get_images(release):

images.extend(
[
(f"{pull['title']} #{pull['number']}: {text}".strip(": "), image)
for text, image in re.findall(
r"!\[(.*?)\]\((.*?)\)", pull["body"] or ""
)
(f"{pull['title']} #{pull['number']}: {text}".strip(": "), url)
for text, url in find_images(pull["body"] or "")
if "badge" not in url
]
)

Expand Down Expand Up @@ -161,7 +167,10 @@ def transform_markdown(text):
text = re.sub(r"!?\[([^\[\]]*?)\]\(([^\(\)]*?)\)", r"<\2|\1>", text)
# convert lists into bullets
text = re.sub(
r"(?<=^) *[·•●\-\*➤]+ *(.*)", r" *•* \1", text, flags=re.MULTILINE
r"(?<=^) *[·•●\-\*➤]+\s*(.*)",
r" *•*  \1",
text,
flags=re.MULTILINE,
)
# convert headings into bold
text = re.sub(
Expand Down
153 changes: 8 additions & 145 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,145 +1,8 @@
### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
pytestdebug.log

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/
doc/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
#poetry.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
# .env
.env/
.venv/
env/
venv/
ENV/
env.bak/
venv.bak/
pythonenv*

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# operating system-related files
*.DS_Store #file properties cache/storage on macOS
Thumbs.db #thumbnail cache on Windows

# profiling data
.prof
.coverage*
.DS_Store
.env
.venv
.vscode
/build
/coverage
/dist
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.9.13