-
Notifications
You must be signed in to change notification settings - Fork 8
177 lines (172 loc) · 5.62 KB
/
ci.yml
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
name: dao-analyzer CI
on: [push]
jobs:
dao_analyzer_components:
runs-on: ubuntu-latest
defaults:
run:
working-directory: dao_analyzer_components
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'
- name: Install dash and other deps
run: pip install -r requirements.txt
- name: Runtime versions
run: |
node --version
npm --version
- name: 📦 Install npm dependencies and build package
run: |
npm clean-install
npm run build
- name: Validate init
run: npm run validate-init
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: dao_analyzer_components
path: |
./dao_analyzer_components/dao_analyzer_components/
!**/__pycache__
dao_analyzer_components_publish:
runs-on: ubuntu-latest
needs: [dao_analyzer_components]
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master'
defaults:
run:
working-directory: dao_analyzer_components
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
registry-url: 'https://registry.npmjs.org'
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: dao_analyzer_components
path: ./dao_analyzer_components/dao_analyzer_components/
- name: Publish package
run: npx is-published || npm publish --ignore-scripts
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
testing_python:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8","3.9","3.10"]
env:
DEBUG: TRUE
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel tox tox-gh-actions
- name: Test with tox
run: tox
package:
runs-on: ubuntu-latest
needs: [dao_analyzer_components, testing_python]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Downloading tags to gen version name
- uses: actions/download-artifact@v3
with:
name: dao_analyzer_components
path: ./dao_analyzer_components/dao_analyzer_components/
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'
- name: Install build deps
run: python -m pip install --upgrade pip build wheel
- name: Build package
run: python -m build
- name: Archive built package
uses: actions/upload-artifact@v3
with:
name: dist
path: ./dist/
pypi:
runs-on: ubuntu-latest
needs: [package,dao_analyzer_components_publish]
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master'
steps:
- name: Download built package
uses: actions/download-artifact@v3
with:
name: dist
path: ./dist/
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
docker:
runs-on: ubuntu-latest
needs: [package,dao_analyzer_components_publish]
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master'
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- uses: actions/checkout@master
- name: Getting built package
uses: actions/download-artifact@v3
with:
name: dist
path: ./dist/
- name: Get DAOA_VERSION and PYTHON_PKG
run: |
pip install pkginfo
PYTHON_PKG=$(ls -t dist/*.whl | head -1)
echo PYTHON_PKG="$PYTHON_PKG" >> $GITHUB_ENV
echo DAOA_VERSION=$(python -c "from pkginfo import Wheel as W; print(W(r'$PYTHON_PKG').version)") >> $GITHUB_ENV
echo CREATED=$(date --rfc-3339=seconds) >> $GITHUB_ENV
echo REVISION=$(git rev-parse HEAD) >> $GITHUB_ENV
- name: Check env variables
run: |
echo PYTHON_PKG: $PYTHON_PKG && [ ! -z "$PYTHON_PKG" ]
echo DAOA_VERSION: $DAOA_VERSION && [ ! -z "$DAOA_VERSION" ]
- name: "Get tag names"
run: |
branch=$(git branch --show-current)
[[ "$branch" = "master" ]] && branch=latest
echo "::set-output name=tag::$branch"
echo "::set-output name=tag_sv::v$DAOA_VERSION"
id: tags
- name: Publish to Docker Hub
uses: elgohr/Publish-Docker-Github-Action@v5
env:
DOCKER_BUILDKIT: "1"
with:
name: grasia/dao-analyzer
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
buildargs: DAOA_VERSION,PYTHON_PKG,CREATED,REVISION
tags: ${{ steps.tags.outputs.tag }},${{ steps.tags.outputs.tag_sv }}
- name: Publish to Github Registry
uses: elgohr/Publish-Docker-Github-Action@v5
env:
DOCKER_BUILDKIT: "1"
with:
name: grasia/dao-analyzer
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
buildargs: DAOA_VERSION,PYTHON_PKG,CREATED,REVISION
tags: ${{ steps.tags.outputs.tag }},${{ steps.tags.outputs.tag_sv }}
- name: Trigger update in server
continue-on-error: true
run: |
curl -f -H "Authorization: Bearer ${{ secrets.WATCHTOWER_HTTP_API_TOKEN }}" dao-analyzer.science:8042/v1/update