Skip to content

Commit d1b5884

Browse files
Add packaging CI (#266)
This commits adds in infrastructure to push package builds to Pypi nightly and on command. This all changes the versioning of the python package from a single fixed value to a dynamically generated value that includes the current date/time.
1 parent 88ed39b commit d1b5884

File tree

3 files changed

+52
-1
lines changed

3 files changed

+52
-1
lines changed

.github/workflows/packaging.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: MLGO Packaging CI
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '0 0 * * *'
7+
8+
jobs:
9+
BuildAndPublich:
10+
runs-on: ubuntu-latest
11+
name: Build and Publish Package
12+
steps:
13+
- uses: actions/checkout@v3
14+
name: Checkout repository
15+
- uses: actions/setup-python@v4
16+
name: Setup Python
17+
with:
18+
python-version: '3.10'
19+
cache: 'pip'
20+
- run: pip3 install build==0.1.0 setuptools==67.8.0 twine==4.0.2
21+
name: Install Packaging Dependencies
22+
# TODO(boomanaiden154): Switch this install step over to using pipenv
23+
# once regenerating the lockfile has been fixed.
24+
- run: python3 -m build
25+
name: Build package
26+
- run: twine upload dist/*
27+
env:
28+
TWINE_USERNAME: __token__
29+
TWINE_PASSWORD: ${{secrets.PYPI_TOKEN}}
30+
name: Publish the package

compiler_opt/package_config.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# coding=utf-8
2+
# Copyright 2020 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
"""Setup version information for the package."""
16+
17+
from datetime import timezone, datetime
18+
19+
__version__ = '0.0.1.dev' + datetime.now(tz=timezone.utc).strftime('%Y%m%d%H%M')

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ dependencies = [
1515
"tensorflow>=2.12.0",
1616
"dm-reverb>=0.11.0"
1717
]
18-
version="0.0.1"
18+
dynamic = ["version"]
1919

2020
[tool.setuptools.packages.find]
2121
include = ["compiler_opt*"]
2222

23+
[tool.setuptools.dynamic]
24+
version = {attr = "compiler_opt.package_config.__version__"}

0 commit comments

Comments
 (0)