From 776d57ba0e868e0ab8548932872b00c3a1fb5d2e Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Mon, 3 Feb 2020 18:11:32 -0500 Subject: [PATCH] Add automatic release structure --- .github/workflows/release.yml | 60 +++++++++++++++++++++++++++++++++++ .mergify.yml | 22 +++++++++++-- requirements/release.txt | 2 ++ 3 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 requirements/release.txt diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..dacfa00 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,60 @@ +name: Cut release automatically + +on: + schedule: + - cron: "0 16 * * 2" + +jobs: + check-changes: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + ref: master + - name: Check commits since last release + id: count-commits + run: | + git fetch --depth=1 origin +refs/tags/*:refs/tags/* + commits_since=$(git log $(git describe --tags --always --abbrev=0)..HEAD --oneline | wc -l) + echo "Commits since last release: $commits_since" + if [ "${commits_since}" == "0" ]; then + echo "No release needed" + exit 1 + else + echo "Release needed" + fi + + bump-and-pull-request: + needs: check-changes + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + ref: master + - name: Bump version + uses: actions/setup-python@v1 + with: + python-version: '3.x' + - run: | + pip install -r $GITHUB_WORKSPACE/requirements/release.txt + newver=$(bumpversion --dry-run --list patch | grep new_version= | sed -r s,"^.*=",,) + echo "::set-env name=NEW_VERSION::$newver" + echo "New version will be ${{ env.NEW_VERSION }}" + bumpversion patch + - name: Create Pull Request + id: cpr + uses: peter-evans/create-pull-request@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + branch: autorelease/${{ env.NEW_VERSION }} + commit-message: Release version ${{ env.NEW_VERSION }} + title: Release version ${{ env.NEW_VERSION }} + body: This is an automated release that updates dependencies. + - name: Show outputs + run: | + echo "Pull Request Number - ${{ steps.cpr.outputs.pr_number }}" diff --git a/.mergify.yml b/.mergify.yml index 68b095c..0633313 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -1,5 +1,5 @@ pull_request_rules: - - name: automatic approve dependabot pull requests + - name: automatically approve dependabot pull requests conditions: - author~=dependabot\[bot\]|dependabot-preview\[bot\] - status-success=continuous-integration/appveyor/branch @@ -10,10 +10,28 @@ pull_request_rules: review: type: APPROVE - - name: automatic merge for dependabot pull requests + - name: automatically merge dependabot pull requests conditions: - author~=dependabot\[bot\]|dependabot-preview\[bot\] - "#approved-reviews-by>=1" actions: merge: method: merge + +pull_request_rules: + - name: automatically approve gha-bot pull requests + conditions: + - author~=github-actions\[bot\] + - status-success=continuous-integration/appveyor/pr + - status-success=continuous-integration/travis-ci/pr + actions: + review: + type: APPROVE + + - name: automatically merge gha-bot pull requests + conditions: + - author~=github-actions\[bot\] + - "#approved-reviews-by>=1" + actions: + merge: + method: merge diff --git a/requirements/release.txt b/requirements/release.txt new file mode 100644 index 0000000..2a9e80d --- /dev/null +++ b/requirements/release.txt @@ -0,0 +1,2 @@ +pip==20.0.2 +bumpversion==0.5.3