-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (60 loc) · 2.01 KB
/
python-package.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
63
64
65
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Python package
on:
push:
tags:
- "v*.*.*"
permissions:
contents: write
# THE PYTHON PACKAGE IS BUILT USING POETRY
# IF YOU WANT TO USE THIS WORKFLOW, CONFIGURE THESE
env:
# TODO use variable from somewhere to extract package name in kebab case
PKGNAME: example-package
REPO_URL: https://api.github.com/repos/zckv/pypi_in_pages_example/actions/workflows/addrepo.yml/dispatches
jobs:
build:
runs-on: ubuntu-latest
outputs:
ASSETS: ${{ steps.release.outputs.assets }}
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v3
with:
python-version: "3.8"
- name: Install poetry environement
run: |
cd ${{ env.PKGNAME }}
python -m pip install poetry
if [ -f pyproject.toml ]; then poetry install -n; fi
- name: Build package with poetry
id: "build"
run: |
cd ${{ env.PKGNAME }}
echo "BUILDING PACKAGE in $(pwd)"
poetry build
- name: Release
id: "release"
uses: softprops/action-gh-release@v1
with:
files: ${{ env.PKGNAME }}/dist/*
deploy:
runs-on: ubuntu-latest
needs: [build]
strategy:
matrix:
ASSET: ${{ fromJSON(needs.build.outputs.ASSETS) }}
env:
TOKEN: ${{ secrets.PAT_TOKEN }}
VERSION: ${{ matrix.ASSET.name }}
LINK: ${{ matrix.ASSET.browser_download_url }}
steps:
- name: Add to pages index
run: >
curl -L -X POST -H "Accept: application/vnd.github+json"
-H "Authorization: Bearer $TOKEN"
-H "X-GitHub-Api-Version: 2022-11-28"
${{ env.REPO_URL }}
-d "{\"ref\":\"master\",\"inputs\":{\"name\": \"$PKGNAME\", \"version\": \"$VERSION\", \"link\": \"$LINK\"}}"