Skip to content

darts release workflow #297

darts release workflow

darts release workflow #297

Workflow file for this run

name: darts release workflow
on:
workflow_dispatch:
inputs:
bump_type:
description: "Bump type (#major, #minor, #patch)"
required: true
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: "1. Clone repository"
uses: actions/checkout@v2
with:
token: ${{ secrets.RELEASE_WORKFLOW_TOKEN_NEW_FINE_GRAINED }}
fetch-depth: '1'
- name: "2. Set up Python 3.9"
uses: actions/setup-python@v1
with:
python-version: '3.9'
- name: "3. Update pip"
run: |
python -m pip install --upgrade pip
- name: "4. Attach cache for pip"
uses: actions/cache@v1
id: cache
with:
path: ~/.cache/pip
key: release-${{ runner.os }}-pip-${{ hashFiles('requirements/release.txt') }}
restore-keys: |
release-${{ runner.os }}-pip-
- name: "5. Install release dependencies"
run: |
pip install -q -r requirements/release.txt
- name: "6. Determine next version"
uses: hrzn/github-tag-action@master
id: bump_dry
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DRY_RUN: true
BUMP_TYPE: ${{ github.event.inputs.bump_type}}
- name: "7. Bump version"
run: |
bump2version --new-version ${{ steps.bump_dry.outputs.new_tag }} patch
- name: "8. Commit new version"
uses: stefanzweifel/[email protected]
with:
commit_message: Release ${{ steps.bump_dry.outputs.new_tag }}
branch: master
push_options: --force
commit_user_name: Unit8 Bot
commit_user_email: [email protected]
- name: "9. Publish new tag"
uses: hrzn/github-tag-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CUSTOM_TAG: ${{steps.bump_dry.outputs.new_tag}}
- name: "10. Create new release"
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.bump_dry.outputs.new_tag }}
release_name: Darts ${{steps.bump_dry.outputs.part}} ${{ steps.bump_dry.outputs.new_tag }}
draft: false
body_path: .github/RELEASE_TEMPLATE/release_body.md
deploy-docker:
needs: [release]
runs-on: ubuntu-latest
steps:
- name: "1. Clone repository"
uses: actions/checkout@v2
- name: "2. Determine current version"
uses: hrzn/github-tag-action@master
id: bump_dry
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DRY_RUN: true
BUMP_TYPE: ${{ github.event.inputs.bump_type}}
- name: "3. Login to docker hub"
run: docker login -u $DOCKER_HUB_USER -p $DOCKER_HUB_TOKEN
env:
DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }}
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
# downloading gradle multiple times in parallel can yield to connection errors
- name: "4. Cache gradle distribution"
uses: actions/cache@v2
with:
path: ~/.gradle/wrapper/dists
key: release-${{ runner.os }}-gradle-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}
- name: "4.1 Cache gradle packages"
uses: actions/cache@v2
with:
path: ~/.gradle/caches
key: release-${{ runner.os }}-gradle-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties', 'build.gradle') }}
#check build.gradle file for explanation of next steps
- name: "5. Publish image with tag corresponding to current version"
run: |
./gradlew dockerPushVersion -P version=${{ steps.bump_dry.outputs.tag }}
- name: "6. Publish image with tag 'latest' if not hotfix"
if: ${{ !contains(github.event.head_commit.message, '#hotfix') }}
run: |
./gradlew dockerPushLatest
deploy-docs:
runs-on: ubuntu-latest
needs: [release]
steps:
- name: "1. Clone repository"
uses: actions/checkout@v2
- name: "2. Set up Python 3.9"
uses: actions/setup-python@v1
with:
python-version: '3.9'
- name: "3. Install pandoc"
run: |
sudo apt-get install -y pandoc
# downloading gradle multiple times in parallel can yield to connection errors
- name: "4. Cache gradle distribution"
uses: actions/cache@v2
with:
path: ~/.gradle/wrapper/dists
key: release-${{ runner.os }}-gradle-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}
- name: "4.1 Cache gradle packages"
uses: actions/cache@v2
with:
path: ~/.gradle/caches
key: release-${{ runner.os }}-gradle-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties', 'build.gradle') }}
- name: "5. Setup pip"
run: |
./gradlew setupPip
- name: "6. Attach cache for pip"
uses: actions/cache@v1
id: cache
with:
path: ~/.cache/pip
key: release-${{ runner.os }}-pip-${{ hashFiles('requirements/core.txt', 'requirements/release.txt') }}
restore-keys: |
release-${{ runner.os }}-pip-
- name: "7. Build docs"
run: |
./gradlew buildDocs
- name: "8. Publish documentation to gh-pages"
uses: s0/[email protected]
env:
REPO: self
BRANCH: gh-pages
FOLDER: docs/build/html
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}