Skip to content

Merge branch 'develop' #11

Merge branch 'develop'

Merge branch 'develop' #11

Workflow file for this run

name: Release
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
env:
DEFAULT_PYTHON: '3.11'
jobs:
release:
name: Release package
runs-on: ubuntu-latest
if: github.repository == 'MobileTeleSystems/onetl' # prevent running on forks
environment:
name: pypi
url: https://pypi.org/p/onetl
permissions:
id-token: write # to auth in PyPI
contents: write # to create Github release
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
id: python
uses: actions/setup-python@v4
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Cache pip
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-python-${{ env.DEFAULT_PYTHON }}-release-${{ hashFiles('requirements/core.txt', 'requirements/docs.txt') }}
restore-keys: |
${{ runner.os }}-python-${{ env.DEFAULT_PYTHON }}-release-${{ hashFiles('requirements/core.txt', 'requirements/docs.txt') }}
${{ runner.os }}-python-${{ env.DEFAULT_PYTHON }}-release-
- name: Upgrade pip
run: python -m pip install --upgrade pip setuptools wheel
- name: Install dependencies
run: |
pip install -I -r requirements/core.txt -r requirements/docs.txt
- name: Build package
run: python setup.py sdist bdist_wheel
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
- name: Get changelog
run: |
cat docs/changelog/${{ github.ref_name }}.rst > changelog.rst
- name: Fix Github links
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 changelog to markdown
uses: docker://pandoc/core:2.9
with:
args: >-
--output=changelog.md
--from=rst
--to=gfm
--wrap=none
changelog.rst
- name: Fix Github code blocks
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
- 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@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
draft: false
prerelease: false
name: ${{ steps.release-name.outputs.name }}
body_path: changelog.md
files: |
dist/*