Skip to content
################################################################################################################
#
# 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, Publish, and Restart Jobs
on:
push:
branches:
- test-ci
jobs:
combined_job:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.bump_version_and_set_output.outputs.new_version }}
changelog: ${{ steps.generate.outputs.changelog }}
version_changes: ${{ steps.extract_changes.outputs.version_changes }}
steps:
# Checkout
- name: Checkout code
uses: actions/checkout@v2
# Check commit message
- 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
# If commit message doesn't contain "[skip ci]", continue to the next steps
- name: Set up Python
if: steps.check.outputs.skip != 'true'
uses: actions/setup-python@v2
with:
python-version: 3.9
- uses: actions/setup-node@v3
if: steps.check.outputs.skip != 'true'
with:
node-version: 16
- name: Install Ganesh-CLI
if: steps.check.outputs.skip != 'true'
run: npm install -g ganache
- name: Install Dependencies
if: steps.check.outputs.skip != 'true'
run: |
python -m pip install --upgrade pip
pip install poetry
poetry install
env:
TENDERLY_FORK: '${{ secrets.TENDERLY_FORK }}'
WEB3_ALCHEMY_PROJECT_ID: '${{ secrets.WEB3_ALCHEMY_PROJECT_ID }}'
ETHERSCAN_TOKEN: '${{ secrets.ETHERSCAN_TOKEN }}'
- name: Bump version and set output
if: steps.check.outputs.skip != 'true'
id: bump_version_and_set_output
run: |
poetry version patch
git checkout test-ci
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add pyproject.toml
git commit -m "Bump version [skip ci]"
- name: Generate changelog
if: steps.check.outputs.skip != 'true'
uses: heinrichreimer/[email protected]
with:
token: ${{ secrets.GH_TOKEN }}
output: 'CHANGELOG.md'
configureSections: '{"Merged pull requests": {"labels": ["pull-request","Merge pull request"]}, "Fixed bugs": {"labels": ["bug","bugfix"]}, "Implemented enhancements": {"labels": ["enhancement","feature"]}, "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: Commit changelog update
if: steps.check.outputs.skip != 'true'
run: |
git checkout test-ci
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add CHANGELOG.md
git commit -m "Update changelog [skip ci]"
# push to main branch using CasperWA/push-protected@v2 action
- name: Push to protected branch
if: steps.check.outputs.skip != 'true'
uses: CasperWA/push-protected@v2
with:
token: ${{ secrets.GH_TOKEN }}
branch: test-ci
- name: Create Release
if: steps.check.outputs.skip != 'true'
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
with:
tag_name: v${{ steps.bump_version_and_set_output.outputs.new_version }}
release_name: Release v${{ steps.bump_version_and_set_output.outputs.new_version }}
body: ${{ steps.extract_changes.outputs.version_changes }}
draft: false
prerelease: false
- 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: Build
run: |
poetry build
# - 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/