From 86437a7fce08523b691d6903026e6a85deafa921 Mon Sep 17 00:00:00 2001 From: Sahithi Reddy Velma <46659774+sahithi03@users.noreply.github.com> Date: Fri, 5 Mar 2021 09:10:35 -0800 Subject: [PATCH] chore: Automate releases (#9) Signed-off-by: Sahithi Velma Co-authored-by: Sahithi Velma --- .github/workflows/monthly_release.yml | 48 +++++++++++++++++++++++++++ .github/workflows/publish_release.yml | 43 ++++++++++++++++++++++++ setup.cfg | 8 +++++ 3 files changed, 99 insertions(+) create mode 100644 .github/workflows/monthly_release.yml create mode 100644 .github/workflows/publish_release.yml diff --git a/.github/workflows/monthly_release.yml b/.github/workflows/monthly_release.yml new file mode 100644 index 0000000..1f58350 --- /dev/null +++ b/.github/workflows/monthly_release.yml @@ -0,0 +1,48 @@ +name: Monthly Release + +on: + schedule: + - cron: 0 0 1 * * + workflow_dispatch: + logLevel: + description: "Log level" + required: true + default: "warning" + +jobs: + release: + runs-on: ubuntu-latest + env: + BRANCH_NAME: new-release-${{ github.run_id }} + steps: + - uses: actions/setup-python@v2 + with: + python-version: 3.6 + - name: Checkout master + uses: actions/checkout@v2 + with: + fetch-depth: "0" + - name: Semantic release + id: semantic-release + run: | + pip install python-semantic-release + git config user.name github-actions + git config user.email github-actions@github.com + semantic-release version + echo ::set-output name=version::$(semantic-release print-version --current) + semantic-release changelog > './CHANGELOG.md' + - name: Create release pull request + uses: peter-evans/create-pull-request@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: Bumped version to ${{ steps.semantic-release.outputs.version }} + committer: github-actions + author: github-actions + signoff: true + branch: ${{ env.BRANCH_NAME }} + delete-branch: true + title: | + chore: Bumped version for release ${{ steps.semantic-release.outputs.version }} + body: | + Bumped version to ${{ steps.semantic-release.outputs.version }} + team-reviewers: amundsen-io/amundsen-committers diff --git a/.github/workflows/publish_release.yml b/.github/workflows/publish_release.yml new file mode 100644 index 0000000..f4c6e5a --- /dev/null +++ b/.github/workflows/publish_release.yml @@ -0,0 +1,43 @@ +name: Publish Monthly Release + +on: + push: + branches: + - master + paths: + # triggered when version is bumped + - "setup.py" + - "CHANGELOG.md" +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Setup python 3.6 + uses: actions/setup-python@v1 + with: + python-version: 3.6 + - name: Get version + id: vers + run: | + pip install python-semantic-release + echo ::set-output name=version::$(semantic-release print-version --current) + - name: Create release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.vers.outputs.version }} + release_name: New Features & Bug Fixes + body_path: ./CHANGELOG.md + - name: Add wheel dependency + run: pip install wheel + - name: Generate dist + run: python setup.py sdist bdist_wheel + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@master + with: + user: __token__ + password: ${{ secrets.pypi_password }} diff --git a/setup.cfg b/setup.cfg index c67e6ec..301a4bc 100644 --- a/setup.cfg +++ b/setup.cfg @@ -23,3 +23,11 @@ ignore_missing_imports = True [isort] multi_line_output=5 skip=venv + +[semantic_release] +version_variable = "./setup.py:__version__" +upload_to_pypi = true +upload_to_release = true +commit_subject = New release for {version} +commit_message = Signed-off-by: github-actions +commit_author = github-actions