Skip to content

Commit

Permalink
Added github action scripts to create tag automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
zhenghaven committed Feb 28, 2024
1 parent 88614e7 commit 549d22f
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 2 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/test-and-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: test_and_release

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
create_tag:
permissions:
contents: write
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
python-version: [ 3.11 ]

name: A job to test the functionalities of the code
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Installing Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Installing this repo as a Python package
run: |
python3 -m pip install ${{ github.workspace }}
- name: Installing GitHubApiHelper
run: |
python3 -m pip install git+https://github.com/zhenghaven/[email protected]
- name: Get latest version
id: latest_ver
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
python3 -m GitHubApiHelper --auth-token \
api_tags_latest_ver \
--repo ${{ github.repository }} \
-l $(python3 -m PyEthHelper --version) \
--github-out
- name: Create tag
if: ${{ startsWith(github.ref, 'refs/heads/main') && steps.latest_ver.outputs.remote != steps.latest_ver.outputs.all }}
uses: actions/github-script@v6
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/${{ steps.latest_ver.outputs.allV }}',
sha: context.sha
})
5 changes: 5 additions & 0 deletions PyEthHelper/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

from web3 import Web3

from . import _Meta
from .EthContractHelper import (
LoadContract,
DeployContract,
Expand All @@ -27,6 +28,10 @@ def main():
description='Deploy contracts to Ethereum blockchain',
prog='',
)
argParser.add_argument(
'--version',
action='version', version=f'{_Meta.__version__}',
)
argParser.add_argument(
'--config', '-c', type=str, default='project_conf.json', required=False,
help='Path to the project configuration file'
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
setup(
name = PyEthHelper._Meta.PKG_NAME,
version = PyEthHelper._Meta.__version__,
packages = find_packages(where='.', exclude=['main.py']),
packages = find_packages(where='.', exclude=['setup.py']),
url = 'https://github.com/lsd-ucsc/PyEthHelper',
license = PyEthHelper._Meta.PKG_LICENSE,
author = PyEthHelper._Meta.PKG_AUTHOR,
Expand All @@ -28,6 +28,6 @@
]
},
install_requires=[
'web3>=6.2.0',
'web3==6.2.0',
],
)

0 comments on commit 549d22f

Please sign in to comment.