Skip to content

Commit

Permalink
GH action
Browse files Browse the repository at this point in the history
  • Loading branch information
shmocz committed Dec 22, 2023
1 parent d87b7ab commit 328cc13
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 2 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Build and release

on:
push:
tags:
- v*

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Store version number
run: |
VERSION=${GITHUB_REF_NAME#v}
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v3
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install deps and build wheel
run: |
./build.sh
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: latest-release
path: dist/
- name: Upload New Release.
uses: softprops/action-gh-release@v1
with:
name: v${{ env.VERSION }}
tag_name: v${{ env.VERSION }}
body: ra2yrproto .proto definitions and Python package.
files: |
dist/ra2yrproto-${{ env.VERSION }}-py3-none-any.whl
dist/ra2yrproto-${{ env.VERSION }}.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16 changes: 16 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
: ${PROTOBUF_VERSION:="25.1"}

PROTOC_EXE="$(which protoc)"
if [ -z "$PROTOC_EXE" ]; then
PROTOC_EXE="protoc/bin/protoc"
if [ ! -f "$PROTOC_EXE" ]; then
curl -LO "https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOBUF_VERSION}/protoc-${PROTOBUF_VERSION}-linux-x86_64.zip"
unzip "protoc-${PROTOBUF_VERSION}-linux-x86_64.zip" -d protoc
fi
PROTOC_EXE="$(realpath "protoc/bin/protoc")"
fi

python -m pip install --upgrade pip
python -m pip install build
PROTOC_EXE="$PROTOC_EXE" python -m build
7 changes: 5 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
import subprocess
from setuptools.command.build_py import build_py
from setuptools.command.sdist import sdist
from setuptools import setup
from setuptools import setup, find_packages
import shutil

SETUP_DIR = os.path.dirname(os.path.abspath(__file__))
PROTO_DIR = os.path.join(SETUP_DIR, "ra2yrproto")

PROTOC_EXE = os.environ.get("PROTOC_EXE", None) or shutil.which("protoc")

def get_proto_sources(p):
for d, _, ff in os.walk(p):
Expand All @@ -27,7 +29,7 @@ def run(self):
if (
subprocess.call(
[
"protoc",
PROTOC_EXE,
"--python_out",
SETUP_DIR,
"--pyi_out",
Expand All @@ -45,5 +47,6 @@ def run(self):

setup(
cmdclass={"sdist": _Sdist, "build_py": BuildProto},
packages=find_packages(include=["ra2yrproto"]),
package_data={"ra2yrproto": ["*.proto"]},
)

0 comments on commit 328cc13

Please sign in to comment.