-
Notifications
You must be signed in to change notification settings - Fork 0
129 lines (104 loc) · 3.84 KB
/
release.yml
File metadata and controls
129 lines (104 loc) · 3.84 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: PyPI release
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
env:
DEFAULT_PYTHON: '3.14'
jobs:
release:
name: Release package
runs-on: ubuntu-latest
if: github.repository == 'MTSWebServices/horizon' # prevent running on forks
environment:
name: pypi
url: https://pypi.org/p/data-horizon
permissions:
id-token: write # to auth in PyPI
contents: write # to create Github release
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
id: python
uses: actions/setup-python@v6
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Install system dependencies
# this step is needed for successful installation of "bonsai" library in python dependencies
run: sudo apt-get update && sudo apt-get install -y libldap2-dev libsasl2-dev
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: 'false'
- name: Install dependencies
run: |
uv sync --extras backend --group docs
- name: Generate OpenAPI Schema
run: |
make docs-openapi
- name: Fix logo in Readme
run: |
sed -i "s#image:: docs/#image:: https://raw.githubusercontent.com/MTSWebServices/horizon/$GITHUB_SHA/docs/#g" README.rst
- name: Patch version template
# Due to change above, git stage area is dirty, so we need to patch the template
run: sed -i 's#dirty_template = ".*"#dirty_template = "{tag}"#' pyproject.toml
- name: Build package
run: uv build
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
- name: Generate SBOM
run: |
uv pip install cyclonedx-bom
uv export --extra backend --extra postgres --extra ldap --format requirements.txt | uv run cyclonedx-py requirements - > sbom.cyclonedx.json
- name: Get changelog
run: |
cat docs/changelog/$GITHUB_REF_NAME.rst > changelog.rst
- name: Prepare rST syntax for conversion to Markdown
run: |
# Replace Github links from Sphinx syntax with Markdown
sed -i -E 's/:github:issue:`(.*)`/#\1/g' changelog.rst
sed -i -E 's/:github:pull:`(.*)`/#\1/g' changelog.rst
sed -i -E 's/:github:user:`(.*)`/@\1/g' changelog.rst
sed -i -E 's/:github:org:`(.*)`/@\1/g' changelog.rst
- name: Convert rST to Markdown
uses: docker://pandoc/core:2.9
with:
args: >-
--output=changelog.md
--from=rst
--to=gfm
--wrap=none
changelog.rst
- name: Fixing Markdown syntax after conversion
run: |
# Replace ``` {.python caption="abc"} with ```python caption="abc"
sed -i -E 's/``` \{\.(.*)\}/```\1/g' changelog.md
# Replace ``` python with ```python
sed -i -E 's/``` (\w+)/```\1/g' changelog.md
# Replace \# with #
sed -i -E 's/\\#/#/g' changelog.md
- name: Get release name
id: release-name
run: |
# Release name looks like: 0.7.0 (2023-05-15)
echo -n name= > "$GITHUB_OUTPUT"
cat changelog.md | head -1 | sed -E "s/#+\s*//g" >> "$GITHUB_OUTPUT"
- name: Fix headers
run: |
# Remove header with release name
sed -i -e '1,2d' changelog.md
- name: Create Github release
id: create_release
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
draft: false
prerelease: false
name: ${{ steps.release-name.outputs.name }}
body_path: changelog.md
files: |
dist/*.tar.gz
dist/*.whl
docs/_static/openapi.json
sbom.cyclonedx.json