From 3a34268e785f922c35bb099392adf90481e60d70 Mon Sep 17 00:00:00 2001 From: barak Date: Sun, 2 Aug 2020 15:05:38 +0300 Subject: [PATCH] create bc-python-hcl2 package --- .github/workflows/main.yml | 67 ++++++++++++++++++++++++++++++++++++++ bin/versionCheck.sh | 2 +- hcl2/version.py | 3 -- package-lock.json | 2 +- package.json | 2 +- setup.py | 2 +- 6 files changed, 71 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..9bb9d40 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,67 @@ +name: build + +on: + push: + branches: + - master +jobs: + + bump-version: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Set up Python 3.7 + uses: actions/setup-python@v1 + with: + python-version: 3.7 + - uses: dschep/install-pipenv-action@v1 + - name: Install dependencies + run: | + pipenv install --dev + - name: update docs and bump version + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git fetch --tags + latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`) + echo "latest tag: $latest_tag" + new_tag=$(echo $latest_tag | awk -F. -v a="$1" -v b="$2" -v c="$3" '{printf("%d.%d.%d", $1+a, $2+b , $3+1)}') + echo "new tag: $new_tag" + + ## update python version + echo "__version__ = '$new_tag'" > 'hcl2/version.py' + + git commit --reuse-message=HEAD@{1} hcl2/version.py || echo "No changes to commit" + git push origin + git tag $new_tag + git push origin $new_tag + publish-package: + needs: bump-version + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Set up Python 3.7 + uses: actions/setup-python@v1 + with: + python-version: 3.7 + - uses: dschep/install-pipenv-action@v1 + - name: Install dependencies + run: | + pipenv install --dev + - name: create python package + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git fetch --tags + git pull + pipenv run python setup.py sdist bdist_wheel + - name: Publish a Python distribution to PyPI + uses: pypa/gh-action-pypi-publish@master + with: + user: __token__ + password: ${{ secrets.pypi_password }} + - name: sleep and wait for package to refresh + run: | + sleep 2m \ No newline at end of file diff --git a/bin/versionCheck.sh b/bin/versionCheck.sh index a9280cc..9a03517 100755 --- a/bin/versionCheck.sh +++ b/bin/versionCheck.sh @@ -8,7 +8,7 @@ IS_PULL_REQUEST=$2 # false if not a pull request, # Makes sure travis does not check version if doing a pull request if [ "$IS_PULL_REQUEST" != "false" ]; then - if git diff --quiet "origin/${TARGET_BRANCH}...HEAD" 'python-hcl2' "test" setup.* ./*.pip; then + if git diff --quiet "origin/${TARGET_BRANCH}...HEAD" 'bc-python-hcl2' "test" setup.* ./*.pip; then echo "No changes found to main code or dependencies: no version change needed" exit 0 fi diff --git a/hcl2/version.py b/hcl2/version.py index 15032e0..493f741 100644 --- a/hcl2/version.py +++ b/hcl2/version.py @@ -1,4 +1 @@ -"""Place of record for the package version""" - __version__ = "0.3.0" -__git_hash__ = "GIT_HASH" diff --git a/package-lock.json b/package-lock.json index f9e3e24..c28b942 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "python-hcl2", + "name": "bc-python-hcl2", "requires": true, "lockfileVersion": 1, "dependencies": { diff --git a/package.json b/package.json index bd1ede4..d924063 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "python-hcl2", + "name": "bc-python-hcl2", "devDependencies": { "remark-cli": "^6.0.1", "remark-preset-lint-consistent": "^2.0.2", diff --git a/setup.py b/setup.py index 286b38c..66c8343 100644 --- a/setup.py +++ b/setup.py @@ -35,7 +35,7 @@ def get_requirements(): setup( - name='python-hcl2', + name='bc-python-hcl2', python_requires='>=3.6.0', version=get_version(), description="A parser for HCL2",