Merge pull request #905 from InfuseAI/chore/sc-32404/chore-update-pip… #178
Workflow file for this run
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 workflow will install Python dependencies, run tests and lint with a variety of Python versions | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | |
name: Release to PyPI | |
on: | |
push: | |
tags: 'v*' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python 3.9 | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.9 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | |
- name: Run tests | |
run: | | |
make test | |
- name: Release | |
id: release_pypi | |
run: | | |
# get version from GITHUB_REF | |
# input: "refs/tags/v0.1.0" | |
# output: "0.1.0" | |
# update version number | |
echo "${GITHUB_REF:11}" > ./piperider_cli/VERSION | |
echo "::set-output name=version::$(cat piperider_cli/VERSION)" | |
# put config includes tracking api key | |
echo "$CONFIG" > ./piperider_cli/data/CONFIG | |
# set sentry environment | |
if [[ "$(cat piperider_cli/VERSION)" == *"a"* ]]; then | |
echo "::set-output name=sentry_env::alpha" | |
elif [[ "$(cat piperider_cli/VERSION)" == *"b"* ]]; then | |
echo "::set-output name=sentry_env::beta" | |
elif [[ "$(cat piperider_cli/VERSION)" == *"rc"* ]]; then | |
echo "::set-output name=sentry_env::release-candidate" | |
else | |
echo "::set-output name=sentry_env::production" | |
fi | |
# generate pypirc | |
echo "$PYPIRC" > $HOME/.pypirc | |
# release to PyPI | |
make release | |
env: | |
PYPIRC: ${{ secrets.PYPI }} | |
CONFIG: ${{ secrets.CONFIG }} | |
- name: Mark Sentry Release | |
uses: getsentry/action-release@v1 | |
env: | |
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
SENTRY_ORG: infuseai | |
SENTRY_PROJECT: piperider | |
with: | |
environment: ${{ steps.release_pypi.outputs.sentry_env || 'production' }} | |
ignore_empty: true | |
ignore_missing: true | |
version: ${{ steps.release_pypi.outputs.version }} | |
- name: Mark Amplitude Release | |
run: | | |
bash .github/scripts/bump_amplitude_release.sh $VERSION $ENVIRONMENT | |
env: | |
VERSION: ${{ steps.release_pypi.outputs.version }} | |
ENVIRONMENT: ${{ steps.release_pypi.outputs.sentry_env || 'production' }} | |
AMPLITUDE_API_KEY: ${{ secrets.AMPLITUDE_PROD_API_KEY }} | |
AMPLITUDE_SECRET_KEY: ${{ secrets.AMPLITUDE_PROD_SECRET_KEY }} | |
- name: Notify release to Slack | |
id: slack | |
uses: slackapi/[email protected] | |
with: | |
payload: | | |
{ | |
"text": ":chai_dog::chai_dog::chai_dog:*PipeRider Release*:chai_dog::chai_dog::chai_dog:\n*Version*: ${{ steps.release_pypi.outputs.version }}\n*GitHub Release*: <https://github.com/InfuseAI/piperider/releases/tag/v${{ steps.release_pypi.outputs.version }}|v${{ steps.release_pypi.outputs.version }}>" | |
} | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_API_TOKEN }} | |
outputs: | |
piperider_version: ${{ steps.release_pypi.outputs.version }} | |
sentry_env: ${{ steps.release_pypi.outputs.sentry_env || 'production' }} | |
deploy-docker: | |
runs-on: ubuntu-latest | |
needs: [ build ] | |
strategy: | |
fail-fast: false | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
- name: Sleep for 30 seconds | |
run: | | |
sleep 30 | |
- name: Build & deploy Docker images | |
run: | | |
echo "Build & deploy Docker images: piperider:$VERSION" | |
make docker-deploy VERSION=$VERSION | |
if [ "$SENTRY_ENV" == "production" ]; then | |
echo "Set piperider:$VERSION as piperider:latest" | |
make docker-deploy-latest VERSION=$VERSION | |
fi | |
env: | |
VERSION: ${{ needs.build.outputs.piperider_version }} | |
SENTRY_ENV: ${{ needs.build.outputs.sentry_env }} | |
generate-sample-report: | |
runs-on: ubuntu-latest | |
needs: [ build ] | |
strategy: | |
fail-fast: false | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Sleep for 30 seconds | |
run: | | |
sleep 30 | |
- name: Generate Sample Report by Repository Dispatch | |
uses: peter-evans/repository-dispatch@v2 | |
with: | |
token: ${{ secrets.PIPERIDER_INTERNAL_PROJECTS_GITHUB_TOKEN }} | |
repository: InfuseAI/git-repo-analytics | |
event-type: generate-sample-report | |
client-payload: '{"piperider_version": "${{ needs.build.outputs.piperider_version }}"}' |