Skip to content

Commit

Permalink
use github_ref
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherhesse committed Jan 15, 2022
1 parent 108f161 commit 34ca8b6
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,14 @@ jobs:
run: mkdir dist && mv artifacts/wheels/* dist/

- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@master
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/

- name: Publish distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_API_TOKEN }}
run: echo "push to pypi"
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# password: ${{ secrets.PYPI_API_TOKEN }}
4 changes: 2 additions & 2 deletions procgen-build/procgen_build/build_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ def main():
}
)
if platform.system() == "Linux":
if "TRAVIS_TAG" in os.environ:
if "GITHUB_REF" in os.environ:
# pass TRAVIS_TAG to the container so that it can build wheels with the correct version number
os.environ["CIBW_ENVIRONMENT"] = (
os.environ["CIBW_ENVIRONMENT"]
+ " TRAVIS_TAG=" + os.environ["TRAVIS_TAG"]
+ " GITHUB_REF=" + os.environ["GITHUB_REF"]
)
os.environ["CIBW_ENVIRONMENT"] = (
os.environ["CIBW_ENVIRONMENT"]
Expand Down
22 changes: 22 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,35 @@
import os
import sys
import glob
import subprocess

SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
PACKAGE_ROOT = os.path.join(SCRIPT_DIR, "procgen")
README = open(os.path.join(SCRIPT_DIR, "README.md"), "rb").read().decode("utf8")

# dynamically determine version number based on git commit
version = open(os.path.join(PACKAGE_ROOT, "version.txt"), "r").read().strip()
sha = "unknown"

try:
sha = (
subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=SCRIPT_DIR)
.decode("ascii")
.strip()
)
except Exception:
pass

if "GITHUB_REF" in os.environ:
ref = os.environ["GITHUB_REF"]
tag = ref.split("/")[-1]
print(f"ref={ref} tag={tag}")
assert tag == version, "mismatch in tag vs version, expected: %s actual: %s" % (
tag,
version,
)
elif sha != "unknown":
version += "+" + sha[:7]


# build shared library
Expand Down

0 comments on commit 34ca8b6

Please sign in to comment.