Skip to content

Commit 41f5069

Browse files
Merge pull request #115 from easyscience/patch
Fix backmerge workflow and polish docs & tutorial output
2 parents 4b8c008 + abc62e3 commit 41f5069

3 files changed

Lines changed: 22 additions & 38 deletions

File tree

Lines changed: 20 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# This workflow creates a backmerge PR into `develop` whenever a new version tag is pushed (v*).
22
#
33
# Key points:
4-
# - The PR head is a temporary branch that points at the *tag commit* (refs/tags/vX.Y.Z).
5-
# After merging, `develop` can `git describe` as vX.Y.Z-... because the tag commit becomes an ancestor.
4+
# - Creates a PR from `master` to `develop` when a new tag is pushed.
65
# - The PR is auto-merged using a MERGE COMMIT (not squash) via a GitHub App token.
76
# The GitHub App must be added to the develop ruleset bypass list.
87
#
@@ -12,7 +11,7 @@
1211
# - Actions secret: ES_BACKMERGE_PRIVATE_KEY (GitHub App private key PEM)
1312
# - Actions variable: ES_BACKMERGE_APP_ID (GitHub App ID)
1413

15-
name: Backmerge PR (tag -> develop)
14+
name: Backmerge PR (master -> develop)
1615

1716
on:
1817
push:
@@ -34,64 +33,49 @@ jobs:
3433
app-id: ${{ vars.BACKMERGE_APP_ID }}
3534
private-key: ${{ secrets.BACKMERGE_PRIVATE_KEY }}
3635

37-
- name: Checkout tag commit
36+
- name: Checkout repository
3837
uses: actions/checkout@v5
3938
with:
40-
ref: ${{ github.ref }} # refs/tags/vX.Y.Z
4139
fetch-depth: 0
4240
token: ${{ steps.app-token.outputs.token }}
4341

44-
- name: Create and push backmerge branch at tag
45-
id: vars
42+
- name: Create PR from master to develop (or reuse if exists)
43+
id: pr
4644
run: |
4745
set -euo pipefail
4846
4947
TAG='${{ github.ref_name }}'
50-
BRANCH="backmerge/${TAG}"
5148
52-
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
53-
echo "branch=${BRANCH}" >> "$GITHUB_OUTPUT"
49+
TITLE="Backmerge: ${TAG} from master into develop"
5450
55-
git config user.name "github-actions[bot]"
56-
git config user.email "github-actions[bot]@users.noreply.github.com"
51+
BODY="⚠️ This PR is created automatically for backmerge of the release tag \`${TAG}\` from \`master\` into \`develop\`.
5752
58-
# Create/move branch to point exactly at the tag commit
59-
git checkout -B "$BRANCH"
53+
It is labeled \`[maintainer] auto-pull-request\` and is excluded from release notes and version bump logic."
6054
61-
# Push (force makes re-runs idempotent for the same tag)
62-
git push --force --set-upstream origin "$BRANCH"
63-
env:
64-
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
65-
66-
- name:
67-
Create PR from tag backmerge branch to develop (or reuse if exists)
68-
run: |
69-
set -euo pipefail
70-
71-
TITLE="Backmerge: ${{ steps.vars.outputs.tag }} into develop"
72-
73-
BODY="⚠️ This PR is created automatically for backmerge of a new release tag commit \`${{ steps.vars.outputs.tag }}\` into \`develop\`.
74-
75-
It is labeled `[maintainer] auto-pull-request` and is excluded from release notes and version bump logic."
55+
# Check if a PR from master to develop already exists
56+
EXISTING_PR=$(gh pr list --repo "${{ github.repository }}" --base develop --head master --state open --json number --jq '.[0].number // empty')
7657
77-
if gh pr view --repo "${{ github.repository }}" --head "${{ steps.vars.outputs.branch }}" >/dev/null 2>&1; then
78-
echo "PR already exists for head=${{ steps.vars.outputs.branch }}"
58+
if [ -n "$EXISTING_PR" ]; then
59+
echo "PR #${EXISTING_PR} already exists for master -> develop"
60+
echo "pr_number=${EXISTING_PR}" >> "$GITHUB_OUTPUT"
7961
else
80-
gh pr create \
62+
PR_URL=$(gh pr create \
8163
--repo "${{ github.repository }}" \
8264
--base develop \
83-
--head "${{ steps.vars.outputs.branch }}" \
65+
--head master \
8466
--title "$TITLE" \
8567
--label "[maintainer] auto-pull-request" \
86-
--body "$BODY"
68+
--body "$BODY")
69+
PR_NUMBER=$(echo "$PR_URL" | grep -oE '[0-9]+$')
70+
echo "Created PR #${PR_NUMBER}"
71+
echo "pr_number=${PR_NUMBER}" >> "$GITHUB_OUTPUT"
8772
fi
8873
env:
8974
GH_TOKEN: ${{ steps.app-token.outputs.token }}
9075

9176
- name: Enable auto-merge using MERGE COMMIT
9277
run: |
9378
set -euo pipefail
94-
# Merge the PR identified by its head branch.
95-
gh pr merge --repo "${{ github.repository }}" --merge --auto "${{ steps.vars.outputs.branch }}"
79+
gh pr merge --repo "${{ github.repository }}" --merge --auto "${{ steps.pr.outputs.pr_number }}"
9680
env:
9781
GH_TOKEN: ${{ steps.app-token.outputs.token }}

src/easydiffraction/utils/logging.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ def section(cls, title: str) -> None:
555555
"""Formats a section header with bold green text."""
556556
full_title = f'{title.upper()}'
557557
line = '━' * len(full_title)
558-
formatted = f'[bold green]{full_title}\n{line}[/bold green]'
558+
formatted = f'[bold green]\n{line}\n{full_title}\n{line}[/bold green]'
559559
if not in_jupyter():
560560
formatted = f'\n{formatted}'
561561
cls._console.print(formatted)

tools/tweak_notebooks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def _get_bootstrap_source() -> str:
5353
'\n'
5454
"if (hasattr(builtins, '__IPYTHON__') and\n"
5555
" importlib.util.find_spec('easydiffraction') is None):\n"
56-
f" !pip install '{pip_specifier}'\n"
56+
f" !pip install '{pip_specifier}'"
5757
)
5858

5959

0 commit comments

Comments
 (0)