-
Notifications
You must be signed in to change notification settings - Fork 48
Gt 337 GitHub workflow release finalize #326
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
Gt 337 GitHub workflow release finalize #326
Conversation
✅ Docs preview readyThe preview is ready to be viewed. View the preview File Changes 3 new, 4 changed, 9 removedBuild ID: 51cb02a820d24e69ed1ec6e4 URL: https://www.apollographql.com/docs/deploy-preview/51cb02a820d24e69ed1ec6e4 |
nicholascioli
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! I left a few nit comments, but feel free to ignore them
| paths-ignore: | ||
| - '.github/**' | ||
| - '.cargo/**' | ||
| - '.direnv/**' | ||
| - '.vscode/**' | ||
| - 'docs/**' | ||
| - 'Cargo.*' | ||
| - 'crates/**/Cargo.*' | ||
| - '*.md' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Do we want this to just be paths instead set to rust source files?
| python3 - <<'PY' > CHANGELOG_SECTION.md | ||
| try: | ||
| import os, re, sys, pathlib | ||
| new = os.environ["NEW"] | ||
| old = os.environ["OLD"] | ||
| p = pathlib.Path("CHANGELOG.md") | ||
| if not p.exists(): | ||
| raise FileNotFoundError("CHANGELOG.md not found at repo root") | ||
| text = p.read_text(encoding="utf-8") | ||
|
|
||
| # Find header for the new version | ||
| start = re.search(rf'(?m)^# \[{re.escape(new)}\]', text) | ||
| if not start: | ||
| print(f"::error::Could not find changelog entry for {new}", file=sys.stderr) | ||
| sys.exit(1) | ||
|
|
||
| # Prefer the *specific* previous version header if present; otherwise, next '# ['; else, EOF | ||
| segment = text[start.start():] | ||
| end_old = re.search(rf'(?m)^# \[{re.escape(old)}\]', segment) | ||
| if end_old: | ||
| segment = segment[:end_old.start()] | ||
| else: | ||
| nxt = re.search(r'(?m)^# \[', segment[len('# [' + new + ']'):]) | ||
| if nxt: | ||
| # adjust to absolute end | ||
| segment = segment[: (len('# [' + new + ']') + nxt.start())] | ||
|
|
||
| segment = segment.rstrip() + "\n" | ||
| print(segment) | ||
| except Exception: | ||
| import traceback | ||
| traceback.print_exc() | ||
| sys.exit(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: We might want this to just be a file that it includes and runs vs writing inline. Your choice
| # Try to create; if it already exists, update it | ||
| if ! gh pr create \ | ||
| --base main \ | ||
| --head "$HEAD" \ | ||
| --title "$TITLE" \ | ||
| --draft \ | ||
| --body-file CHANGELOG_SECTION.md \ | ||
| --label release | ||
| then | ||
| num=$(gh pr list --head "$HEAD" --base main --state open --json number -q '.[0].number' || true) | ||
| if [[ -n "$num" ]]; then | ||
| gh pr edit "$num" --title "$TITLE" --body-file CHANGELOG_SECTION.md --add-label release | ||
| else | ||
| echo "::error::Failed to create or find PR from $HEAD to main" | ||
| exit 1 | ||
| fi | ||
| fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: This works for now, but it might be more stable as a cargo xtask in the future since bash can be very finicky.
Finalizing the prep release workflow. Adding the following steps: