-
Notifications
You must be signed in to change notification settings - Fork 0
62 lines (62 loc) · 2.12 KB
/
release.yml
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
name: "Release new version"
on:
workflow_run:
workflows:
- "CI Tests"
branches:
- master
types:
- completed
jobs:
github:
name: "Create GitHub Release"
runs-on: ubuntu-22.04
permissions:
contents: write
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- uses: actions/checkout@v4
- name: "Get version"
run: echo "PLUGIN_VERSION=$(cat streamflow_postgresql/version.py | grep -oP '(?<=VERSION = \")(.*)(?=\")')" >> $GITHUB_ENV
- name: "Check tag existence"
uses: mukunku/[email protected]
id: check-tag
with:
tag: ${{ env.PLUGIN_VERSION }}
- name: "Create Release"
id: create-release
uses: actions/create-release@v1
if: ${{ steps.check-tag.outputs.exists == 'false' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.PLUGIN_VERSION }}
release_name: ${{ env.PLUGIN_VERSION }}
draft: false
prerelease: false
pypi:
name: "Publish on PyPI"
runs-on: ubuntu-22.04
environment:
name: pypi
url: https://pypi.org/project/streamflow-postgresql
permissions:
id-token: write
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: "Get local version"
run: echo "PLUGIN_VERSION=$(cat streamflow_postgresql/version.py | grep -oP '(?<=VERSION = \")(.*)(?=\")')" >> $GITHUB_ENV
- name: "Get PyPI version"
run: echo "PYPI_VERSION=$(pip index versions --pre streamflow-postgresql | grep streamflow-postgresql | sed 's/.*(\(.*\))/\1/')" >> $GITHUB_ENV
- name: "Build Python packages"
if: ${{ env.PLUGIN_VERSION != env.PYPI_VERSION }}
run: |
python -m pip install build --user
python -m build --sdist --wheel --outdir dist/ .
- name: "Publish package to PyPI"
uses: pypa/gh-action-pypi-publish@release/v1
if: ${{ env.PLUGIN_VERSION != env.PYPI_VERSION }}