Skip to content

Commit

Permalink
action: Add pypi release pipeline (#277)
Browse files Browse the repository at this point in the history
* try

* try

* fix

* add dependency

* add list

* fix

* fix

* fix permission

* typo

* fix

* add way to specify manually

* use dispatch

* try fix

* fix

* remove

* remove
  • Loading branch information
VoVAllen committed Jun 13, 2022
1 parent 35e6e1b commit 3bf2710
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 10 deletions.
52 changes: 51 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,54 @@ jobs:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
- name: upload gobin
uses: actions/upload-artifact@v3
with:
name: gobin_${{ github.event.release.tag_name }}
retention-days: 1
path: |
dist/envd_linux_amd64_v1/envd
dist/envd-ssh_linux_amd64_v1/envd-ssh
if-no-files-found: error
pypi_publish:
needs: goreleaser
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v') # only trigger when tag starts with v
steps:
- uses: actions/checkout@v3
- name: Get gobin
uses: actions/download-artifact@v3
with:
name: gobin_${{ github.event.release.tag_name }}
path: dist/
- name: Move file to
run: |
mkdir -p bin
mv dist/envd_linux_amd64_v1/envd bin/envd
mv dist/envd-ssh_linux_amd64_v1/envd-ssh bin/envd-ssh
chmod +x bin/envd
chmod +x bin/envd-ssh
- uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Build wheel
run: |
ls bin/
python -m pip install --upgrade pip
python -m pip install twine wheel auditwheel setuptools_scm
python setup.py bdist_wheel
auditwheel repair dist/*.whl
ls wheelhouse/
pushd wheelhouse
for file in *.whl ; do mv $file ${file//"cp39-cp39"/"py2.py3-none"} ; done
popd
- name: Upload to Pypi
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
twine upload wheelhouse/*
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ DEBUG_DIR := ./debug-bin
BUILD_DIR := ./build

# Current version of the project.
VERSION ?= $(shell git describe --match 'v[0-9]*' --always --tags)
VERSION ?= $(shell git describe --match 'v[0-9]*' --always --tags --abbrev=0)
BUILD_DATE=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
GIT_COMMIT=$(shell git rev-parse HEAD)
GIT_TAG=$(shell if [ -z "`git status --porcelain`" ]; then git describe --exact-match --tags HEAD 2>/dev/null; fi)
Expand Down
25 changes: 17 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,18 @@
from setuptools import setup, Extension, find_packages
from setuptools.command.build_ext import build_ext
import subprocess

import logging

with open("README.md", "r", encoding="utf-8") as f:
readme = f.read()


def build_envd_if_not_found():
if not os.path.exists("bin/envd"):
logging.info("envd not found. Build from scratch")
errno = subprocess.call(["make", "build"])
assert errno == 0, "Failed to build envd"

class EnvdExtension(Extension):
"""Extension for `envd`"""

Expand All @@ -33,32 +39,35 @@ def build_extension(self, ext: Extension) -> None:
return super().build_extension(ext)

bin_path = os.path.join(self.build_lib, "envd", "bin")
errno = subprocess.call(["make", "build"])
assert errno == 0, "Failed to build envd"
build_envd_if_not_found()
os.makedirs(bin_path, exist_ok=True)
shutil.copy("bin/envd", bin_path)


def get_version():
subprocess.call(["make", "build"])
# Remove prefix v in versioning
build_envd_if_not_found()
version = subprocess.check_output(
["./bin/envd", "-v"], universal_newlines=True
["./bin/envd", "version", "--short"], universal_newlines=True
).strip()
return version.rsplit(" ", 1)[-1]
ver = version.rsplit(" ", 1)[-1][1:]
return ver


setup(
name="envd",
version=get_version(),
use_scm_version = True,
setup_requires=['setuptools_scm'],
description="A development environment management tool for data scientists.",
long_description=readme,
long_description=readme,
long_description_content_type="text/markdown",
url="https://github.com/tensorchord/envd",
license="Apache License 2.0",
author="TensorChord",
author_email="envd-maintainers@tensorchord.ai",
packages=find_packages(),
include_package_data=True,
python_requires=">=3.6",
entry_points={
"console_scripts": [
"envd=envd.cmd:envd",
Expand Down

0 comments on commit 3bf2710

Please sign in to comment.