-
Notifications
You must be signed in to change notification settings - Fork 23
145 lines (129 loc) · 4.95 KB
/
pypi.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# 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 }}"}'