-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
197 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
name: Release | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
version: | ||
description: Release version | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
build: | ||
uses: ./.github/workflows/build.yaml | ||
with: | ||
check: true | ||
preview: true | ||
publish: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.head_ref }} | ||
ssh-key: ${{ secrets.RELEASE_PRIVATE_KEY }} | ||
fetch-depth: 0 | ||
persist-credentials: true | ||
|
||
- name: Setup GitHub Actions bot | ||
run: | | ||
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
git config --local user.name "github-actions[bot]" | ||
- name: Setup Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.11' | ||
|
||
- name: Setup release environment | ||
run: make configure | ||
|
||
- name: Download build | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: Lilex | ||
path: build | ||
|
||
- name: Generate source with new version | ||
run: python scripts/lilex.py generate --version "${{ inputs.version }}" | ||
|
||
- name: Save release notes | ||
run: python scripts/changelog.py notes Next > notes.md | ||
|
||
- name: Update changelog with new version | ||
run: python scripts/changelog.py release "${{ inputs.version }}" | ||
|
||
- name: Replace builded font files | ||
run: | | ||
rm -rf fonts | ||
mv build fonts | ||
- name: Create git commit and tag | ||
run: | | ||
git add sources/Lilex.glyphs | ||
git add CHANGELOG.md | ||
git add fonts | ||
git status | ||
git commit -m "chore: release ${{ inputs.version }} 🔥" | ||
git tag "${{ inputs.version }}" | ||
# - name: Push changes | ||
# uses: ad-m/github-push-action@master | ||
# with: | ||
# ssh: true | ||
# tags: true | ||
|
||
# - name: Create GitHub release | ||
# if: github.event_name == 'push' | ||
# uses: softprops/action-gh-release@v2 | ||
# with: | ||
# name: ${{ input.version }} | ||
# body_path: notes.md | ||
# token: ${{ secrets.USER_PAT }} | ||
# prerelease: ${{ contains(input.version, '-') }} | ||
# files: | | ||
# Lilex.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#!/usr/bin/env python3 | ||
"""Utility script release notes generation. | ||
Usage: release_notes.py <version> | ||
""" | ||
import datetime | ||
|
||
from arrrgs import arg, command, run | ||
|
||
NEXT_VERSION_HEADING = "Next" | ||
CHANGELOG_PATH = "CHANGELOG.md" | ||
REPO_URL = "https://github.com/mishamyrt/Lilex" | ||
|
||
def read_changelog() -> str: | ||
with open(CHANGELOG_PATH, mode="r", encoding="utf-8") as file: | ||
return file.read() | ||
|
||
def parse_version_heading(line: str) -> str: | ||
version = line[3:] | ||
if not version.startswith("["): | ||
return version | ||
end = version.find("]") | ||
if end == -1: | ||
return version | ||
return version[1:end] | ||
|
||
def format_version_heading(version: str) -> str: | ||
timestamp = datetime.date.today().strftime("%B %d, %Y") | ||
release_heading = f"## [{version}] — {timestamp}" | ||
return release_heading | ||
|
||
def format_version_url(version: str) -> str: | ||
return f"[{version}]: {REPO_URL}/releases/tag/{version}" | ||
|
||
def collect_notes() -> dict[str, str]: | ||
lines = read_changelog().split("\n") | ||
releases = {} | ||
version = "" | ||
notes = "" | ||
for line in lines: | ||
if line.startswith("## "): | ||
if version != "": | ||
releases[version] = notes.strip("\n ") | ||
notes = "" | ||
version = parse_version_heading(line) | ||
continue | ||
if version == "": | ||
continue | ||
notes += line + "\n" | ||
return releases | ||
|
||
@command( | ||
arg("version", help="Version number"), | ||
name="notes" | ||
) | ||
def print_notes(args): | ||
"""Saves the generated source file with features and classes""" | ||
releases = collect_notes() | ||
if args.version not in releases: | ||
print(f"Version {args.version} not found") | ||
print("Available versions:") | ||
for version in releases: | ||
print(f"- {version}") | ||
return | ||
for version, notes in releases.items(): | ||
if version == args.version: | ||
print(notes) | ||
|
||
@command( | ||
arg("version", help="Version number") | ||
) | ||
def release(args): | ||
"""Regenerates the changelog with the new version""" | ||
# May 10, 2024 | ||
timestamp = datetime.date.today().strftime("%B %d, %Y") | ||
release_heading = f"## [{args.version}] — {timestamp}" | ||
changelog = read_changelog() | ||
changelog = changelog.replace(f"## {NEXT_VERSION_HEADING}", release_heading) | ||
changelog += "\n" + format_version_url(args.version) + "\n" | ||
with open(CHANGELOG_PATH, mode="w", encoding="utf-8") as file: | ||
file.write(changelog) | ||
print("🟢 Changelog successfully updated") | ||
|
||
if __name__ == "__main__": | ||
run() |