|
| 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" |
| 38 | + for packageListPath in sorted(Path(".").glob(f"{getenv("LISTS_DIR")}/**/*.txt")): |
| 39 | + releaseNotes += f""" |
| 40 | +
|
| 41 | + <details><summary><b>{packageListPath.stem.removeprefix("dependencies-")}</b> packages</summary> |
| 42 | +
|
| 43 | + {open(packageListPath, "r").read()} |
| 44 | + </details>""" |
| 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