Skip to content

Commit 030f96d

Browse files
heiruwuHeiru Wu
authored andcommitted
ci(workflows): adopt release workflows (#17)
Because - build and release wheels for sdk package This commit - rename module from `instill_sdk` to `instill` - adopt release-please workflows to publish to both `test` and `official` instance of PyPI
1 parent 86c0e85 commit 030f96d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+227
-123
lines changed

.github/workflows/publish.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Publish Wheels
2+
3+
on:
4+
push:
5+
branches:
6+
- release-please--branches--main
7+
release:
8+
types: [published]
9+
10+
jobs:
11+
pypi:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
with:
16+
token: ${{ secrets.botGitHubToken }}
17+
18+
- name: Set up Python
19+
uses: actions/setup-python@v4
20+
with:
21+
python-version: "3.11"
22+
23+
- uses: Gr1N/setup-poetry@v8
24+
25+
- name: Build and push (test)
26+
if: github.ref == 'refs/heads/release-please--branches--main'
27+
run: |
28+
poetry config repositories.testpypi https://test.pypi.org/legacy/
29+
poetry config pypi-token.testpypi ${{ secrets.pypiTestToken }}
30+
make upload TEST_REPO=true
31+
32+
- name: Build and push (release)
33+
if: github.event_name == 'release'
34+
run: |
35+
poetry config pypi-token.pypi ${{ secrets.pypiTestToken }}
36+
make upload

.github/workflows/releases.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Release Please
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
12+
jobs:
13+
release-please:
14+
runs-on: ubuntu-latest
15+
outputs:
16+
RELEASE_CREATED: ${{ steps.release.outputs.release_created }}
17+
TAG_NAME: ${{ steps.release.outputs.tag_name }}
18+
SHA: ${{ steps.release.outputs.sha }}
19+
steps:
20+
- uses: google-github-actions/release-please-action@v3
21+
id: release
22+
with:
23+
token: ${{ secrets.botGitHubToken }}
24+
release-type: python
25+
command: manifest
26+
config-file: release-please/config.json
27+
manifest-file: release-please/manifest.json
28+
- uses: actions/checkout@v3
29+
if: ${{ steps.release.outputs.release_created }}
30+
with:
31+
token: ${{ secrets.botGitHubToken }}
32+
- name: Import GPG Key
33+
if: ${{ steps.release.outputs.release_created }}
34+
uses: crazy-max/ghaction-import-gpg@v5
35+
with:
36+
gpg_private_key: ${{ secrets.botGPGPrivateKey }}
37+
passphrase: ${{ secrets.botGPGPassphrase }}
38+
git_user_signingkey: true
39+
git_commit_gpgsign: true
40+
git_tag_gpgsign: true
41+
- name: Tag major and minor versions
42+
if: ${{ steps.release.outputs.release_created }}
43+
run: |
44+
git tag -d v${{ steps.release.outputs.major }} || true
45+
git tag -d v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} || true
46+
git push origin :v${{ steps.release.outputs.major }} || true
47+
git push origin :v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} || true
48+
git tag -a v${{ steps.release.outputs.major }} -m "Release v${{ steps.release.outputs.major }} pointing to tag ${{ steps.release.outputs.tag_name }}"
49+
git tag -a v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} -m "Release v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} pointing to tag ${{ steps.release.outputs.tag_name }}"
50+
git push origin v${{ steps.release.outputs.major }}
51+
git push origin v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}

.github/workflows/test.yml

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,44 @@ on: [push]
44

55
jobs:
66
build:
7-
87
runs-on: ubuntu-latest
98
strategy:
109
matrix:
11-
python-version: ['3.8', '3.9', '3.10', '3.11']
10+
python-version: ["3.8", "3.9", "3.10", "3.11"]
1211

1312
steps:
14-
- uses: actions/checkout@v3
13+
- uses: actions/checkout@v3
1514

16-
- name: Set up Python ${{ matrix.python-version }}
17-
uses: actions/setup-python@v4
18-
with:
19-
python-version: ${{ matrix.python-version }}
15+
- name: Set up Python ${{ matrix.python-version }}
16+
uses: actions/setup-python@v4
17+
with:
18+
python-version: ${{ matrix.python-version }}
2019

21-
- uses: Gr1N/setup-poetry@v8
20+
- uses: Gr1N/setup-poetry@v8
2221

23-
- name: Check dependencies
24-
run: make doctor
22+
- name: Check dependencies
23+
run: make doctor
2524

26-
- uses: actions/cache@v3
27-
with:
28-
path: .venv
29-
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
25+
- uses: actions/cache@v3
26+
with:
27+
path: .venv
28+
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
3029

31-
- name: Install dependencies
32-
run: make install
30+
- name: Install dependencies
31+
run: make install
3332

34-
- name: Check code
35-
run: make check
33+
- name: Check code
34+
run: make check
3635

37-
- name: Test code
38-
run: make test
36+
- name: Test code
37+
run: make test
3938

40-
- name: Upload coverage to Codecov
41-
uses: codecov/codecov-action@v3
42-
with:
43-
directory: ./
44-
env_vars: OS,PYTHON
45-
fail_ci_if_error: true
46-
files: ./coverage.xml
47-
name: codecov-umbrella
48-
verbose: true
39+
- name: Upload coverage to Codecov
40+
uses: codecov/codecov-action@v3
41+
with:
42+
directory: ./
43+
env_vars: OS,PYTHON
44+
fail_ci_if_error: true
45+
files: ./coverage.xml
46+
name: codecov-umbrella
47+
verbose: true

.gitmodules

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
[submodule "instill_sdk/protogen"]
2-
path = instill_sdk/protogen
3-
url = https://github.com/instill-ai/protogen-python
1+
[submodule "instill/protogen"]
2+
path = instill/protogen
3+
url = https://github.com/instill-ai/protogen-python.git
44
ignore = dirty
5+

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
PROJECT := instill-sdk
2-
PACKAGE := instill_sdk
2+
PACKAGE := instill
33
MODULES := $(wildcard $(PACKAGE)/*.py)
44

55
# MAIN TASKS ##################################################################
@@ -170,8 +170,11 @@ $(PACKAGE).spec:
170170
.PHONY: upload
171171
upload: dist ## Upload the current version to PyPI
172172
git diff --name-only --exit-code
173+
ifeq (${TEST_REPO}, true)
174+
poetry publish -r testpypi
175+
else
173176
poetry publish
174-
open https://pypi.org/project/$(PROJECT)
177+
endif
175178

176179
# CLEANUP #####################################################################
177180

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ After installation, the package can be imported:
3838

3939
```text
4040
$ python
41-
>>> import instill_sdk
42-
>>> instill_sdk.__version__
41+
>>> import instill
42+
>>> instill.__version__
4343
```
4444

4545
### You can find a [_notebook example_](notebooks/model_usage.ipynb) here

instill_sdk/__init__.py renamed to instill/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import sys
33
from importlib.metadata import PackageNotFoundError, version
44

5-
from instill_sdk.utils.logger import Logger
5+
from instill.utils.logger import Logger
66

77
Logger.initialize()
88

instill_sdk/__main__.py renamed to instill/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""Package entry point."""
44
import pprint
55

6-
from instill_sdk.configuration import global_config
6+
from instill.configuration import global_config
77

88
if __name__ == "__main__": # pragma: no cover
99
# main() # pylint: disable=no-value-for-parameter

instill/clients/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from instill.clients.client import InstillClient, get_client
2+
from instill.clients.connector import ConnectorClient
3+
from instill.clients.mgmt import MgmtClient
4+
from instill.clients.model import ModelClient
5+
from instill.clients.pipeline import PipelineClient
File renamed without changes.

0 commit comments

Comments
 (0)