33  push :
44    branches :
55      - ' **'   #  every branch
6+       - ' !gh-pages'   #  exclude gh-pages branch
67      - ' !stage*'   #  exclude branches beginning with stage
8+     tags :
9+       - ' \d+\.\d+\.\d+'   #  only semver tags
710  pull_request :
811    branches :
912      - ' **'   #  every branch
1013      - ' !stage*'   #  exclude branches beginning with stage
1114jobs :
12-   build-docs  :
15+   build :
1316    runs-on : ubuntu-latest 
17+     strategy :
18+       matrix :
19+         include :
20+           - py_ver : 3.8 
21+             distro : alpine 
22+             image : djbase 
1423    env :
24+       PY_VER : ${{matrix.py_ver}} 
25+       DISTRO : ${{matrix.distro}} 
26+       IMAGE : ${{matrix.image}} 
1527      DOCKER_CLIENT_TIMEOUT : " 120" 
1628      COMPOSE_HTTP_TIMEOUT : " 120" 
1729    steps :
1830      - uses : actions/checkout@v2 
19-       - name : Compile docs static  artifacts
31+       - name : Build pip  artifacts
2032        run : | 
33+           export DJ_VERSION=$(grep -oP '\d+\.\d+\.\d+' datajoint/version.py) 
2134          export HOST_UID=$(id -u) 
22-           docker-compose -f ./docs-api/docker-compose.yaml up --exit-code-from docs-builder --build  
23-        - name : Add docs static artifacts 
35+           docker-compose -f docker-compose-build.yaml up --exit-code-from app --build 
36+           echo "DJ_VERSION=${DJ_VERSION}" >> $GITHUB_ENV 
37+        - if : matrix.py_ver == '3.8' && matrix.distro == 'alpine' 
38+         name : Add pip artifacts 
2439        uses : actions/upload-artifact@v2 
2540        with :
26-           name : docs-api-static 
27-           path : docs-api/build/html 
41+           name : pip-datajoint-${{env.DJ_VERSION}} 
42+           path : dist 
2843          retention-days : 1 
2944  test :
30-     if : github.event_name == 'push' || github.event_name == 'pull_request' 
3145    runs-on : ubuntu-latest 
3246    strategy :
3347      matrix :
3953    steps :
4054      - uses : actions/checkout@v2 
4155      - name : Set up Python ${{matrix.py_ver}} 
42-         uses : actions/setup-python@v2  
56+         uses : actions/setup-python@v4  
4357        with :
4458          python-version : ${{matrix.py_ver}} 
4559      - name : Install dependencies 
@@ -50,58 +64,119 @@ jobs:
5064        run : flake8 datajoint --count --select=E9,F63,F7,F82 --show-source --statistics 
5165      - name : Run primary tests 
5266        env :
53-           UID : " 1001" 
54-           GID : " 121" 
5567          PY_VER : ${{matrix.py_ver}} 
5668          MYSQL_VER : ${{matrix.mysql_ver}} 
5769          ALPINE_VER : " 3.10" 
5870          MINIO_VER : RELEASE.2021-09-03T03-56-13Z 
5971          COMPOSE_HTTP_TIMEOUT : " 120" 
6072          COVERALLS_SERVICE_NAME : travis-ci 
6173          COVERALLS_REPO_TOKEN : fd0BoXG46TPReEem0uMy7BJO5j0w1MQiY 
62-         run : docker-compose -f LNX-docker-compose.yml up --build --exit-code-from app 
74+         run : | 
75+           export HOST_UID=$(id -u) 
76+           export HOST_GID=$(id -g) 
77+           docker-compose -f LNX-docker-compose.yml up --build --exit-code-from app 
6378       - name : Run style tests 
6479        run : | 
65-           flake8 --ignore=E203,E722,F401, W503 datajoint \ 
80+           flake8 --ignore=E203,E722,W503 datajoint \ 
6681                 --count --max-complexity=62 --max-line-length=127 --statistics 
6782          black datajoint --check -v 
6883          black tests --check -v 
6984   publish-docs :
7085    if : | 
7186      github.event_name == 'push' && 
72-       ( 
73-         github.repository_owner == 'datajoint' || 
74-         github.repository_owner == 'datajoint-company' || 
75-         github.repository_owner == 'dj-sciops' 
76-       ) 
77-      needs : build-docs 
87+       startsWith(github.ref, 'refs/tags') 
88+      needs : test 
89+     runs-on : ubuntu-latest 
90+     env :
91+       DOCKER_CLIENT_TIMEOUT : " 120" 
92+       COMPOSE_HTTP_TIMEOUT : " 120" 
93+     steps :
94+       - uses : actions/checkout@v2 
95+       - name : Deploy docs 
96+         run : | 
97+           export MODE=BUILD 
98+           export PACKAGE=datajoint 
99+           export UPSTREAM_REPO=https://github.com/${GITHUB_REPOSITORY}.git 
100+           export HOST_UID=$(id -u) 
101+           docker compose -f docs/docker-compose.yaml up --exit-code-from docs --build 
102+           git push origin gh-pages 
103+    publish-release :
104+     if : | 
105+       github.event_name == 'push' && 
106+       startsWith(github.ref, 'refs/tags') 
107+      needs : test 
78108    runs-on : ubuntu-latest 
109+     strategy :
110+       matrix :
111+         include :
112+           - py_ver : 3.8 
113+             distro : alpine 
114+             image : djbase 
115+     env :
116+       PY_VER : ${{matrix.py_ver}} 
117+       DISTRO : ${{matrix.distro}} 
118+       IMAGE : ${{matrix.image}} 
119+       TWINE_USERNAME : ${{secrets.twine_username}} 
120+       TWINE_PASSWORD : ${{secrets.twine_password}} 
121+       DOCKER_CLIENT_TIMEOUT : " 120" 
122+       COMPOSE_HTTP_TIMEOUT : " 120" 
123+     outputs :
124+       release_upload_url : ${{steps.create_gh_release.outputs.upload_url}} 
79125    steps :
80126      - uses : actions/checkout@v2 
81-       - name : Fetch docs static artifacts 
127+       - name : Set up Python ${{matrix.py_ver}} 
128+         uses : actions/setup-python@v4 
129+         with :
130+           python-version : ${{matrix.py_ver}} 
131+       - name : Determine package version 
132+         run : | 
133+           DJ_VERSION=$(grep -oP '\d+\.\d+\.\d+' datajoint/version.py) 
134+           RELEASE_BODY=$(python -c \ 
135+             'print(open("./CHANGELOG.md").read().split("\n\n")[1].split("\n", 1)[1])' \ 
136+           ) 
137+           echo "DJ_VERSION=${DJ_VERSION}" >> $GITHUB_ENV 
138+           echo "RELEASE_BODY=${RELEASE_BODY}" >> $GITHUB_ENV 
139+        - name : Create GH release 
140+         id : create_gh_release 
141+         uses : actions/create-release@v1 
142+         env :
143+           GITHUB_TOKEN : ${{secrets.GITHUB_TOKEN}} 
144+         with :
145+           tag_name : ${{env.DJ_VERSION}} 
146+           release_name : Release ${{env.DJ_VERSION}} 
147+           body : ${{env.RELEASE_BODY}} 
148+           prerelease : false 
149+           draft : false 
150+       - name : Fetch pip artifacts 
82151        uses : actions/download-artifact@v2 
83152        with :
84-           name : docs-api-static 
85-           path : docs-api/build/html 
86-       - name : Commit documentation changes 
153+           name : pip-datajoint-${{env.DJ_VERSION}} 
154+           path : dist 
155+       - name : Determine pip artifact paths 
87156        run : | 
88-           git clone https://github.com/${GITHUB_REPOSITORY}.git \ 
89-               --branch gh-pages --single-branch gh-pages 
90-           rm -R gh-pages/* 
91-           cp -r docs-api/build/html/* gh-pages/ 
92-           cp .gitignore gh-pages/ 
93-           touch gh-pages/.nojekyll 
94-           echo "docs-api.datajoint.org" > gh-pages/CNAME 
95-           cd gh-pages 
96-           git config --local user.email "[email protected] " 97-           git config --local user.name "GitHub Action" 
98-           git add . --all 
99-           git commit -m "Update documentation" -a || true  
100-           # The above command will fail if no changes were present, so we ignore 
101-           # the return code. 
102-        - name : Push changes 
103-         uses : ad-m/github-push-action@master 
157+           echo "DJ_WHEEL_PATH=$(ls dist/datajoint-*.whl)" >> $GITHUB_ENV 
158+           echo "DJ_SDIST_PATH=$(ls dist/datajoint-*.tar.gz)" >> $GITHUB_ENV 
159+        - name : Upload pip wheel asset to release 
160+         uses : actions/upload-release-asset@v1 
161+         env :
162+           GITHUB_TOKEN : ${{secrets.GITHUB_TOKEN}} 
104163        with :
105-           branch : gh-pages 
106-           directory : gh-pages 
107-           github_token : ${{secrets.GITHUB_TOKEN}} 
164+           upload_url : ${{steps.create_gh_release.outputs.upload_url}} 
165+           asset_path : ${{env.DJ_WHEEL_PATH}} 
166+           asset_name : pip-datajoint-${{env.DJ_VERSION}}.whl 
167+           asset_content_type : application/zip 
168+       - name : Upload pip sdist asset to release 
169+         uses : actions/upload-release-asset@v1 
170+         env :
171+           GITHUB_TOKEN : ${{secrets.GITHUB_TOKEN}} 
172+         with :
173+           upload_url : ${{steps.create_gh_release.outputs.upload_url}} 
174+           asset_path : ${{env.DJ_SDIST_PATH}} 
175+           asset_name : pip-datajoint-${{env.DJ_VERSION}}.tar.gz 
176+           asset_content_type : application/gzip 
177+       - name : Publish pip release 
178+         run : | 
179+           export HOST_UID=$(id -u) 
180+           docker-compose -f docker-compose-build.yaml run \ 
181+             -e TWINE_USERNAME=${TWINE_USERNAME} -e TWINE_PASSWORD=${TWINE_PASSWORD} app \ 
182+             sh -lc "pip install twine && python -m twine upload dist/*" 
0 commit comments