adding .ipynb to gitignore #2
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
################################################################################################################ | |
# | |
# This GitHub Action workflow automates several processes for the 'fastlane_bot' Python project. | |
# It consists of four main jobs: version bumping, release creation, changelog generation, and PyPi package publishing. | |
# | |
# 1. Version Bumping ('bump_version'): This job automatically increments the minor version of the project, as defined in 'fastlane_bot/__init__.py'. | |
# This is done using 'bumpversion', a Python library for version bumping. | |
# | |
# 2. Release Creation ('release'): Upon successful version bumping, a new GitHub release is created, | |
# using the incremented version number as the release's tag. | |
# | |
# 3. Changelog Generation ('generate_changelog'): After the creation of the new release, | |
# this job generates a changelog that provides a record of changes made to the project, including new features, bug fixes, and more. | |
# The generation is handled by the 'github-changelog-generator-action' GitHub Action. | |
# | |
# 4. PyPi Package Publishing ('publish'): The final job publishes the new version of the project to PyPi, | |
# making the new version accessible via pip install. This job is executed after the successful completion of all previous jobs, | |
# ensuring that all changes are included in the published package. | |
# | |
# (c) Copyright Bprotocol foundation 2023. | |
# Licensed under MIT | |
# | |
################################################################################################################ | |
name: Bump Version, Generate Changelog, Create Release, and Publish | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
check_commit: | |
runs-on: ubuntu-latest | |
outputs: | |
skip: ${{ steps.check.outputs.skip }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- id: check | |
run: | | |
MESSAGE=$(git log -1 --pretty=%B) | |
if [[ "$MESSAGE" == *"[skip ci]"* ]]; then | |
echo "::set-output name=skip::true" | |
else | |
echo "::set-output name=skip::false" | |
fi | |
bump_version: | |
runs-on: ubuntu-latest | |
needs: check_commit | |
if: needs.check_commit.outputs.skip != 'true' | |
outputs: | |
version: ${{ steps.bump_version_and_set_output.outputs.new_version }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.9 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
- name: Install Ganesh-CLI | |
run: npm install -g ganache | |
- name: Install Dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt --force-reinstall | |
- name: Setup Brownie | |
run: | | |
brownie networks import ./brownie-config.yaml true | |
brownie networks delete mainnet | |
brownie networks add "Ethereum Mainnet" "mainnet" host="https://eth-mainnet.alchemyapi.io/v2/$WEB3_ALCHEMY_PROJECT_ID" chainid=1 | |
brownie networks set_provider alchemy | |
env: | |
TENDERLY_FORK: '${{ secrets.TENDERLY_FORK }}' | |
WEB3_ALCHEMY_PROJECT_ID: '${{ secrets.WEB3_ALCHEMY_PROJECT_ID }}' | |
ETHERSCAN_TOKEN: '${{ secrets.ETHERSCAN_TOKEN }}' | |
- name: Install bumpversion | |
run: pip install bumpversion | |
- name: Bump version and set output | |
id: bump_version_and_set_output | |
run: | | |
CURRENT_VERSION=$(python -c "import fastlane_bot; print(fastlane_bot.__version__)") | |
MAJOR=$(echo $CURRENT_VERSION | cut -d. -f1) | |
MINOR=$(echo $CURRENT_VERSION | cut -d. -f2) | |
PATCH=$(echo $CURRENT_VERSION | cut -d. -f3) | |
NEW_VERSION="${MAJOR}.$((MINOR + 1)).${PATCH}" | |
echo new_version=$NEW_VERSION >> $GITHUB_OUTPUT | |
BRANCH_NAME="version-bump-$NEW_VERSION-run-$GITHUB_RUN_NUMBER" | |
git checkout -b $BRANCH_NAME | |
sed -i "s/$CURRENT_VERSION/$NEW_VERSION/" fastlane_bot/__init__.py | |
git config --local user.email "action@github.com" | |
git config --local user.name "GitHub Action" | |
git commit -m "Bump version [skip ci]" -a | |
- name: Push changes | |
run: | | |
git config --global push.autoSetupRemote true | |
git push origin $BRANCH_NAME | |
env: | |
GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
- name: Create Pull Request | |
id: create_pull_request | |
run: | | |
gh pr create --title "Bump version [skip ci]" --body "Automatic version bump" --head "$BRANCH_NAME" --base "main" > pr.txt | |
env: | |
GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
- name: Merge pull request | |
run: | | |
PR_URL=$(cat pr.txt) | |
PR_NUMBER=$(echo $PR_URL | awk -F'/' '{print $NF}') | |
gh pr merge $PR_NUMBER --admin --merge | |
env: | |
GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
generate_changelog: | |
if: needs.check_commit.outputs.skip != 'true' | |
needs: [ bump_version,check_commit ] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Generate changelog | |
uses: heinrichreimer/github-changelog-generator-action@v2.3 | |
with: | |
token: ${{ secrets.GH_TOKEN }} | |
output: 'CHANGELOG.md' | |
configureSections: '{"Merged pull requests": {"labels": ["pull-request"]}, "Fixed bugs": {"labels": ["bug"]}, "Implemented enhancements": {"labels": ["enhancement"]}, "Closed issues": {"labels": ["closed-issue"]}}' | |
bugsLabel: 'Fixed bugs' | |
enhancementLabel: 'Implemented enhancements' | |
issuesLabel: 'Closed issues' | |
prLabel: 'Merged pull requests' | |
compareLink: true | |
addSections: '{"Security fixes": {"labels": ["security"]}, "Breaking changes": {"labels": ["breaking"]}}' | |
- name: Create branch for changelog update | |
run: | | |
BRANCH_NAME="update-changelog-${{ github.run_number }}" | |
git checkout -b $BRANCH_NAME | |
- name: Commit and push changelog update | |
run: | | |
git config --local user.email "action@github.com" | |
git config --local user.name "GitHub Action" | |
git config --global push.autoSetupRemote true | |
git add CHANGELOG.md | |
git commit -m "Bump version [skip ci]" | |
git push origin HEAD | |
env: | |
GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
- name: Create Pull Request for changelog update | |
run: | | |
gh pr create --title "Bump version [skip ci]" --body "Automatic update of CHANGELOG.md" --head "$(git rev-parse --abbrev-ref HEAD)" --base "main" > pr.txt | |
env: | |
GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
- name: Merge pull request | |
run: | | |
PR_URL=$(cat pr.txt) | |
PR_NUMBER=$(echo $PR_URL | awk -F'/' '{print $NF}') | |
gh pr merge $PR_NUMBER --admin --merge | |
env: | |
GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
clean_changelog: | |
needs: [generate_changelog,check_commit] | |
if: needs.check_commit.outputs.skip != 'true' | |
runs-on: ubuntu-latest | |
outputs: | |
changelog: ${{ steps.generate.outputs.changelog }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Clean changelog | |
run: | | |
sed -i '/Bump version/d' CHANGELOG.md | |
- name: Create branch for changelog cleaning | |
run: | | |
BRANCH_NAME="clean-changelog-${{ github.run_number }}" | |
git checkout -b $BRANCH_NAME | |
- name: Commit and push changelog cleaning | |
run: | | |
git config --local user.email "action@github.com" | |
git config --local user.name "GitHub Action" | |
git config --global push.autoSetupRemote true | |
git add CHANGELOG.md | |
git commit -m "Bump version [skip ci]" | |
git push origin HEAD | |
env: | |
GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
- name: Create Pull Request for changelog cleaning | |
run: | | |
gh pr create --title "Bump version [skip ci]" --body "Automatic cleaning of CHANGELOG.md" --head "$(git rev-parse --abbrev-ref HEAD)" --base "main" > pr.txt | |
env: | |
GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
- name: Merge pull request | |
run: | | |
PR_URL=$(cat pr.txt) | |
PR_NUMBER=$(echo $PR_URL | awk -F'/' '{print $NF}') | |
gh pr merge $PR_NUMBER --admin --merge | |
env: | |
GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
release: | |
needs: [ bump_version,check_commit,generate_changelog,clean_changelog ] | |
if: needs.check_commit.outputs.skip != 'true' | |
runs-on: ubuntu-latest | |
outputs: | |
version_changes: ${{ steps.extract_changes.outputs.version_changes }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.9 | |
- name: Extract version changes from CHANGELOG.md | |
id: extract_changes | |
run: | | |
VERSION_CHANGES=$(sed -n "/\[v${{ needs.bump_version.outputs.version }}\]/,/\[v.*\]/p" CHANGELOG.md | head -n -2) | |
echo "::set-output name=version_changes::$VERSION_CHANGES" | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | |
with: | |
tag_name: v${{ needs.bump_version.outputs.version }} | |
release_name: Release v${{ needs.bump_version.outputs.version }} | |
body: ${{ steps.extract_changes.outputs.version_changes }} | |
draft: false | |
prerelease: false | |
publish: | |
if: needs.check_commit.outputs.skip != 'true' | |
needs: [release,check_commit] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.9 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
- name: Install Ganesh-CLI | |
run: npm install -g ganache | |
- name: Install Dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt --force-reinstall | |
- name: Setup Brownie | |
run: | | |
brownie networks import ./brownie-config.yaml true | |
brownie networks delete mainnet | |
brownie networks add "Ethereum Mainnet" "mainnet" host="https://eth-mainnet.alchemyapi.io/v2/$WEB3_ALCHEMY_PROJECT_ID" chainid=1 | |
brownie networks set_provider alchemy | |
env: | |
TENDERLY_FORK: '${{ secrets.TENDERLY_FORK }}' | |
WEB3_ALCHEMY_PROJECT_ID: '${{ secrets.WEB3_ALCHEMY_PROJECT_ID }}' | |
ETHERSCAN_TOKEN: '${{ secrets.ETHERSCAN_TOKEN }}' | |
- name: Create .env file | |
run: | | |
echo TENDERLY_FORK=$TENDERLY_FORK > .env | |
echo WEB3_ALCHEMY_PROJECT_ID=$WEB3_ALCHEMY_PROJECT_ID >> .env | |
echo ETHERSCAN_TOKEN=$ETHERSCAN_TOKEN >> .env | |
echo DEFAULT_MIN_PROFIT_BNT=$DEFAULT_MIN_PROFIT_BNT >> .env | |
echo ETH_PRIVATE_KEY_BE_CAREFUL=$ETH_PRIVATE_KEY_BE_CAREFUL >> .env | |
echo TENDERLY_FORK_ID=$TENDERLY_FORK_ID >> .env | |
env: | |
TENDERLY_FORK: '${{ secrets.TENDERLY_FORK }}' | |
TENDERLY_FORK_ID: '${{ secrets.TENDERLY_FORK }}' | |
WEB3_ALCHEMY_PROJECT_ID: '${{ secrets.WEB3_ALCHEMY_PROJECT_ID }}' | |
ETHERSCAN_TOKEN: '${{ secrets.ETHERSCAN_TOKEN }}' | |
DEFAULT_MIN_PROFIT_BNT: '${{ secrets.DEFAULT_MIN_PROFIT_BNT }}' | |
ETH_PRIVATE_KEY_BE_CAREFUL: '${{ secrets.ETH_PRIVATE_KEY_BE_CAREFUL }}' | |
- name: Install package | |
run: | | |
python setup.py install | |
- name: Build package | |
run: python setup.py sdist | |
- name: Build wheel | |
run: | | |
pip install wheel | |
python setup.py bdist_wheel | |
- name: Publish package to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
password: ${{ secrets.FASTLANE_PYPI_API_TOKEN }} | |
repository-url: https://upload.pypi.org/legacy/ |