Skip to content

Commit 399e1c0

Browse files
committed
ci: publish to pypi workflow added
1 parent 5e6a204 commit 399e1c0

File tree

3 files changed

+105
-0
lines changed

3 files changed

+105
-0
lines changed

.github/workflows/comp_ver.sh

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/bash
2+
vercomp () {
3+
if [[ $1 == $2 ]]
4+
then
5+
return 0
6+
fi
7+
local IFS=.
8+
local i ver1=($1) ver2=($2)
9+
# fill empty fields in ver1 with zeros
10+
for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
11+
do
12+
ver1[i]=0
13+
done
14+
for ((i=0; i<${#ver1[@]}; i++))
15+
do
16+
if [[ -z ${ver2[i]} ]]
17+
then
18+
# fill empty fields in ver2 with zeros
19+
ver2[i]=0
20+
fi
21+
if ((10#${ver1[i]} > 10#${ver2[i]}))
22+
then
23+
return 1
24+
fi
25+
if ((10#${ver1[i]} < 10#${ver2[i]}))
26+
then
27+
return 2
28+
fi
29+
done
30+
return 0
31+
}
32+
33+
testvercomp () {
34+
vercomp $1 $2
35+
case $? in
36+
0) op='=';;
37+
1) op='>';;
38+
2) op='<';;
39+
esac
40+
if [[ $op != $3 ]]
41+
then
42+
echo "FAIL: Expected '$3', Actual '$op', Arg1 '$1', Arg2 '$2'" && exit 1
43+
else
44+
echo "Pass: '$1 $op $2'"
45+
fi
46+
}
47+
48+
if [[ $# == 2 ]]
49+
then
50+
testvercomp $1 $2 '>'
51+
else
52+
echo "Requires two args <version_1> and <version_2>"
53+
fi

.github/workflows/publish-package.yml

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: PYPI
2+
3+
on:
4+
pull_request:
5+
branches: [ "main" ]
6+
7+
jobs:
8+
publish:
9+
runs-on: ubuntu-20.04
10+
11+
steps:
12+
- name: Checkout Repo
13+
uses: actions/checkout@v3
14+
- name: Set Up Python
15+
uses: actions/setup-python@v3
16+
with:
17+
python-version: '3.10'
18+
- name: Install PyPI Package
19+
run: pip install manim-data-structures
20+
- name: Fetch PyPI Package Version
21+
id: mds_pypi_ver
22+
run: "echo MDS_PYPI_VER=$(pip show manim-data-structures | grep 'Version: ' | sed 's/^.*: //') >> $GITHUB_ENV"
23+
- name: Uninstall PyPI Package
24+
run: pip uninstall -y manim-data-structures
25+
- name: Install Poetry
26+
uses: abatilo/actions-poetry@v2
27+
with:
28+
poetry-version: '1.2.2'
29+
- name: Install Repo Package
30+
run: |
31+
poetry install
32+
pip install .
33+
- name: Fetch Repo Package Version
34+
id: mds_repo_ver
35+
run: "echo MDS_REPO_VER=$(pip show manim-data-structures | grep 'Version: ' | sed 's/^.*: //') >> $GITHUB_ENV"
36+
- name: Check Version
37+
run: |
38+
chmod +x .github/workflows/comp_ver.sh
39+
.github/workflows/comp_ver.sh "${{ env.MDS_REPO_VER }}" "${{ env.MDS_PYPI_VER }}"
40+
- name: Build Package
41+
run: poetry build
42+
- name: Create Release
43+
uses: ncipollo/release-action@v1
44+
with:
45+
artifacts: ${{ format('dist/manim_data_structures-{0}*', env.MDS_REPO_VER) }}
46+
name: ${{ format('Manim Data Structures v{0}', env.MDS_REPO_VER) }}
47+
tag: ${{ env.MDS_REPO_VER }}
48+
- name: Publish to PYPI
49+
run: |
50+
poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }} --local
51+
poetry publish

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<a href="https://github.com/psf/black"><img src="https://img.shields.io/badge/code%20style-black-000000.svg?style=plastic" alt="Code style: black">
1111
<a href="https://manim-data-structures.readthedocs.io/en/latest/"><img src="https://readthedocs.org/projects/manim-data-structures/badge/?version=latest&style=plastic" alt="Documentation Status"></a>
1212
<a href="https://pepy.tech/project/manim-data-structures"><img src="https://pepy.tech/badge/manim-data-structures/month?style=plastic" alt="Downloads"> </a>
13+
<a href=""><img src="https://github.com/drageelr/manim-data-structures/actions/workflows/publish-package.yml/badge.svg?style=plastic&branch=main"></a>
1314
<br />
1415
<br />
1516
<i>A plugin that contains common data structures to create Manimations.</i>

0 commit comments

Comments
 (0)