-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add build to pypi and github release tag (#15)
* Initial deploy-pre-release and versions.py file * Added output of new version * Added another branch event for testing * fixed file version * only upload wheels * Only put release in github if under 'VOLTTRON' repository_owner * Remove testing branch from release * Bump version of actions
- Loading branch information
Showing
2 changed files
with
138 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
--- | ||
name: Deploy Pre-Release Artifacts | ||
|
||
on: | ||
push: | ||
branches: | ||
- develop | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
env: | ||
LANG: en_US.utf-8 | ||
LC_ALL: en_US.utf-8 | ||
PYTHON_VERSION: "3.8" | ||
|
||
jobs: | ||
bump_version: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." | ||
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" | ||
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." | ||
|
||
#---------------------------------------------- | ||
# check-out repo and set-up python | ||
#---------------------------------------------- | ||
- name: Checkout code | ||
uses: actions/[email protected] | ||
with: | ||
submodules: recursive | ||
fetch-depth: 0 | ||
|
||
- name: Set up Python ${{ env.PYTHON_VERSION }} | ||
id: setup-python | ||
uses: actions/[email protected] | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
|
||
#---------------------------------------------- | ||
# install cmake to allow us to build the wheel | ||
#---------------------------------------------- | ||
- name: Install Libraries | ||
run: | | ||
pip install cmake wheel packaging | ||
- name: Bump version | ||
run: | | ||
# current version in the setup.py file | ||
current_version=$(sed -n -e 's/^.*__version__ = //p' setup.py) | ||
current_version=$(echo ${current_version} | sed -e "s/'//g") | ||
# current_tag is the last tagged relese in the repository. From there | ||
# we need to remove the v from the begining of the tag. | ||
if ! $(git tag -l "v*" = ''); then | ||
# uses -V which is version sort to keep it monotonically increasing. | ||
current_tag=$(git tag -l "v*" | grep --invert-match '-' | sort --reverse -V | sed -n 1p) | ||
else | ||
current_tag=v$current_version | ||
fi | ||
current_tag=${current_tag#?} | ||
new_version=$(python .github/workflows/versions.py ${current_tag} --prerelease) | ||
new_tag=v${new_version} | ||
sed -i "s/^.*-__version__ = /__version__ = $new_version/" setup.py | ||
echo "New version is: ${new_version}" | ||
# Finally because we want to be able to use the variable in later | ||
# steps we set a NEW_TAG environmental variable | ||
echo "NEW_TAG=$(echo ${new_tag})" >> $GITHUB_ENV | ||
#---------------------------------------------- | ||
# Build wheel | ||
#---------------------------------------------- | ||
- name: Build wheel | ||
run: | | ||
python setup.py install | ||
python setup.py bdist_wheel --plat-name=manylinux1_x86_64 | ||
- uses: ncipollo/release-action@v1 | ||
if: github.repository_owner == 'VOLTTRON' | ||
with: | ||
artifacts: "dist/*.whl" | ||
artifactErrorsFailBuild: true | ||
generateReleaseNotes: true | ||
commit: ${{ github.ref }} | ||
prerelease: true | ||
tag: ${{ env.NEW_TAG }} | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Publish pre-release to pypi | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
if: github.repository_owner == 'VOLTTRON' | ||
with: | ||
password: ${{ secrets.PYPI_TOKEN}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import argparse | ||
import sys | ||
|
||
from packaging.version import Version | ||
|
||
if __name__ == '__main__': | ||
|
||
parser = argparse.ArgumentParser() | ||
|
||
parser.add_argument("current_version") | ||
group = parser.add_mutually_exclusive_group() | ||
group.add_argument("--major", action='store_true', help="Increment to minor release version.") | ||
group.add_argument("--minor", action='store_true', help="Increment to minor release version.") | ||
group.add_argument("--patch", action='store_true', help="Increment to patch release") | ||
group.add_argument("--prerelease", action='store_true', help="Increment a pre-release") | ||
|
||
opts = parser.parse_args() | ||
|
||
current_version = Version(opts.current_version) | ||
|
||
#print(current_version.__dict__) | ||
#sys.exit(0) | ||
if current_version.is_prerelease and opts.prerelease: | ||
new_version = f"{current_version.major}.{current_version.minor}.{current_version.micro}{current_version.pre[0]}{current_version.pre[1] + 1}" | ||
else: | ||
if opts.patch: | ||
new_version = f"{current_version.major}.{current_version.minor}.{current_version.micro + 1}" | ||
elif opts.minor: | ||
new_version = f"{current_version.major}.{current_version.minor + 1}.0" | ||
elif opts.major: | ||
new_version = f"{current_version.major + 1}.0.0" | ||
elif opts.prerelease: | ||
new_version = f"{current_version.major}.{current_version.minor}.{current_version.micro + 1}b0" | ||
else: | ||
raise ValueError("Invalid option specified!") | ||
|
||
print(new_version) | ||
#current_version.pre = (current_version.pre[0], current_version.pre[1] + 1) | ||
#print(current_version.__dict__) |