Skip to content

Commit ee8d9bf

Browse files
committed
Fix mirroring logic
Signed-off-by: Bernát Gábor <[email protected]>
1 parent 80e8b57 commit ee8d9bf

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

.github/workflows/mirror.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,20 @@ on:
99

1010
concurrency:
1111
group: ${{ github.workflow }}-${{ github.ref }}
12-
cancel-in-progress: true
12+
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
1313

1414
jobs:
1515
mirror:
1616
permissions:
1717
contents: write
18+
environment:
19+
name: mirror
1820
runs-on: ubuntu-latest
1921
steps:
2022
- uses: actions/checkout@v4
2123
with:
2224
fetch-depth: 0
25+
token: ${{ secrets.PA_TOKEN }}
2326
- name: Install the latest version of uv
2427
uses: astral-sh/setup-uv@v3
2528
with:

tasks/mirror.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,24 @@ def run() -> None:
3131
missing_tags = sorted(Version(i) for i in released_tags - existing_tags)
3232

3333
if missing_tags and os.environ.get("GITHUB_ACTIONS"):
34-
check_call(["git", "config", "--global", "user.email", "[email protected]"])
35-
check_call(["git", "config", "--global", "user.name", "Mirroring Mike"])
34+
check_call(["git", "config", "--global", "user.email", "[email protected]"])
35+
check_call(["git", "config", "--global", "user.name", "Bernat Gabor"])
3636
toml = ROOT / "pyproject.toml"
3737

3838
for tag in missing_tags:
39-
print(f"Mirror {tag}")
39+
print(f"\n\nMirror {tag}")
4040
text = toml.read_text(encoding="utf-8")
4141
text = re.sub(r'version = ".*?"', f'version = "{tag}"', text)
42-
text = re.sub(r'"pyproject-fmt==.*"', f"pyproject-fmt=={tag}", text)
42+
text = re.sub(r'"pyproject-fmt==.*"', f'"pyproject-fmt=={tag}"', text)
4343
toml.write_text(text, encoding="utf-8")
4444
check_call(["git", "add", "pyproject.toml"])
45+
check_call(["git", "diff", "HEAD", "-u"])
4546
check_call(["git", "commit", "-m", f"Mirror {tag}"])
4647
check_call(["git", "tag", str(tag)])
4748

4849
if missing_tags and sys.argv[1] == "true":
49-
check_call(["git", "push", "--tags"])
50+
print("\n\nPush")
51+
check_call(["git", "push", "--tags", "-f"])
5052
check_call(["git", "push"])
5153

5254

0 commit comments

Comments
 (0)