Skip to content

Commit dbec022

Browse files
add workflow to create release from a given Actions run
1 parent 9f9f7d2 commit dbec022

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

.github/workflows/releaseFromRun.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Create release from Actions run
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
run_id:
6+
description: 'Actions run ID which to get artifacts from'
7+
required: true
8+
type: number
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
env:
13+
LISTS_DIR: lists
14+
DEPENDENCIES_DIR: deps
15+
GH_TOKEN: ${{ github.token }}
16+
steps:
17+
- name: Download artifacts
18+
run: |
19+
gh run download ${{ github.event.inputs.run_id }} \
20+
--repo ${{ github.repository }} \
21+
--dir "$LISTS_DIR" \
22+
--pattern "list of*"
23+
gh run download ${{ github.event.inputs.run_id }} \
24+
--repo ${{ github.repository }} \
25+
--dir "$DEPENDENCIES_DIR" \
26+
--pattern "dependencies-*"
27+
28+
- name: Create release
29+
shell: python
30+
run: |
31+
from datetime import date
32+
from glob import glob
33+
from os import getenv
34+
from pathlib import Path
35+
from subprocess import run
36+
37+
releaseNotes = "Generated from [this](https://github.com/${{ github.repository }}/actions/runs/${{ github.event.inputs.run_id }}) Actions run\n"
38+
for packageListPath in sorted(Path(".").glob(f"{getenv("LISTS_DIR")}/**/*.txt")):
39+
releaseNotes += f""" \
40+
<details><summary><b>{packageListPath.stem.removeprefix("dependencies-")}</b> packages</summary>
41+
42+
{open(packageListPath, "r").read()}
43+
</details>
44+
"""
45+
46+
tag = str(date.today())
47+
dependencies = glob(f"{getenv("DEPENDENCIES_DIR")}/**/*.tgz")
48+
run([
49+
"gh", "release", "create", tag,
50+
"--repo", "${{ github.repository }}",
51+
"--prerelease",
52+
"--title", tag,
53+
"--notes", releaseNotes,
54+
] + dependencies, check=True)

0 commit comments

Comments
 (0)