-
-
Notifications
You must be signed in to change notification settings - Fork 0
39 lines (36 loc) · 1.37 KB
/
githubRelease.yml
File metadata and controls
39 lines (36 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
name: Make GitHub Release
on:
workflow_run:
workflows: ['Python Tests']
types: [completed]
workflow_dispatch:
permissions:
contents: write
actions: write
jobs:
release:
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: '>=3.13'
- name: Ensure GitHub Release exists
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
python -c "
import json, os, pathlib, tomllib, urllib.error, urllib.request
tag=tomllib.loads(pathlib.Path('pyproject.toml').read_text())['project']['version']
repo=os.environ['GITHUB_REPOSITORY']
token=os.environ['GITHUB_TOKEN']
url=f'https://api.github.com/repos/{repo}/releases'
headers={'Authorization': f'Bearer {token}', 'X-GitHub-Api-Version': '2026-03-10'}
try:
urllib.request.urlopen(urllib.request.Request(f'{url}/tags/{tag}', headers=headers))
except urllib.error.HTTPError as thisIsAStupidSystem:
if thisIsAStupidSystem.code != 404:
raise
urllib.request.urlopen(urllib.request.Request(url,json.dumps({'tag_name': tag, 'name': tag}).encode(),headers, method='POST'))
"