-
Notifications
You must be signed in to change notification settings - Fork 131
58 lines (51 loc) · 1.84 KB
/
contrib-auto-build-publish.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
name: Publish SF Hamilton Contrib Python Package
on:
push:
branches:
- main # or the branch of your choice
paths:
- 'contrib/**'
jobs:
publish-to-pypi:
runs-on: ubuntu-latest
# Specifying a GitHub environment is optional, but strongly encouraged
environment: sf-hamilton-contrib-publishing-environment
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
defaults:
run:
working-directory: contrib/
steps:
- uses: actions/checkout@v3
# Setup Python
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10' # Set up your required Python version
# Check current published version
- name: Check if version is greater than the one on PyPI
id: check_version
run: |
# Use a script or a method to get the current version and the PyPI version
# For example, use a Python script that uses the `packaging` library to compare versions
# Set the output `version_is_greater` to `true` or `false`
pip install requests packaging
python scripts/version_check.py
# Install dependencies required to build
- name: Install dependencies
if: steps.check_version.outputs.version_is_greater == 'true'
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine build
# If the version is greater, build
- name: Build
if: steps.check_version.outputs.version_is_greater == 'true'
run: |
python -m build
# Use the trusted publisher set up to remove the need for tokens
- name: Publish package distributions to PyPI
if: steps.check_version.outputs.version_is_greater == 'true'
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: contrib/dist/