11name : Development
22on :
3- push :
43 pull_request :
4+ push :
5+ tags :
6+ - ' *.*.*'
57jobs :
68 build :
79 runs-on : ubuntu-latest
@@ -15,27 +17,35 @@ jobs:
1517 PY_VER : ${{matrix.py_ver}}
1618 DISTRO : ${{matrix.distro}}
1719 IMAGE : ${{matrix.image}}
18- HOST_UID : " 1001"
1920 DOCKER_CLIENT_TIMEOUT : " 120"
2021 COMPOSE_HTTP_TIMEOUT : " 120"
2122 AS_SCRIPT : " TRUE"
2223 steps :
2324 - uses : actions/checkout@v2
2425 - name : Compile image
2526 run : |
26- export DJGUI_API_VERSION =$(cat dj_gui_api_server /version.py | tail -1 | \
27- awk -F\' '{print $2}' )
28- docker-compose -f LNX- docker-compose.yaml build
29- IMAGE=$(docker images --filter "reference=datajoint/djgui *" \
27+ export PHARUS_VERSION =$(cat pharus /version.py | tail -1 | awk -F\' '{print $2}')
28+ export HOST_UID=$(id -u )
29+ docker-compose -f docker-compose-build .yaml up --exit-code-from pharus -- build
30+ IMAGE=$(docker images --filter "reference=datajoint/pharus *" \
3031 --format "{{.Repository}}")
31- TAG=$(docker images --filter "reference=datajoint/djgui*" --format "{{.Tag}}")
32- docker save "${IMAGE}:${TAG}" | gzip > "djgui_api-py${PY_VER}-${DISTRO}.tar.gz"
32+ TAG=$(docker images --filter "reference=datajoint/pharus*" --format "{{.Tag}}")
33+ docker save "${IMAGE}:${TAG}" | \
34+ gzip > "image-pharus-${PHARUS_VERSION}-py${PY_VER}-${DISTRO}.tar.gz"
35+ echo "PHARUS_VERSION=${PHARUS_VERSION}" >> $GITHUB_ENV
3336 - name : Add image artifact
3437 uses : actions/upload-artifact@v2
3538 with :
36- name : ${{format('{0}-py{1}-{2}', 'djgui_api', matrix.py_ver, matrix.distro)}}
37- path : >
38- ${{format('{0}-py{1}-{2}.tar.gz', 'djgui_api', matrix.py_ver, matrix.distro)}}
39+ name : image-pharus-${{env.PHARUS_VERSION}}-py${{matrix.py_ver}}-${{matrix.distro}}
40+ path : " image-pharus-${{env.PHARUS_VERSION}}-py${{matrix.py_ver}}-\
41+ ${{matrix.distro}}.tar.gz"
42+ retention-days : 1
43+ - if : matrix.py_ver == '3.8' && matrix.distro == 'alpine'
44+ name : Add pip artifacts
45+ uses : actions/upload-artifact@v2
46+ with :
47+ name : pip-pharus-${{env.PHARUS_VERSION}}
48+ path : dist
3949 retention-days : 1
4050 test :
4151 needs : build
@@ -50,56 +60,133 @@ jobs:
5060 PY_VER : ${{matrix.py_ver}}
5161 DISTRO : ${{matrix.distro}}
5262 IMAGE : ${{matrix.image}}
53- HOST_UID : " 1001"
5463 DOCKER_CLIENT_TIMEOUT : " 120"
5564 COMPOSE_HTTP_TIMEOUT : " 120"
5665 AS_SCRIPT : " TRUE"
5766 steps :
5867 - uses : actions/checkout@v2
68+ - name : Determine package version
69+ run : |
70+ PHARUS_VERSION=$(cat pharus/version.py | tail -1 | awk -F\' '{print $2}')
71+ echo "PHARUS_VERSION=${PHARUS_VERSION}" >> $GITHUB_ENV
5972 - name : Fetch image artifact
6073 uses : actions/download-artifact@v2
6174 with :
62- name : ${{format('{0} -py{1}-{2}','djgui_api', matrix.py_ver, matrix.distro) }}
75+ name : image-pharus- ${{env.PHARUS_VERSION}} -py${{ matrix.py_ver}}-${{ matrix.distro}}
6376 - name : Run primary tests
6477 run : |
65- docker load < "djgui_api-py${PY_VER}-${DISTRO}.tar.gz"
66- export DJGUI_API_VERSION=$(cat dj_gui_api_server/version.py | tail -1 | \
67- awk -F\' '{print $2}')
68- docker-compose -f LNX-docker-compose.yaml up --exit-code-from dj-gui-api-test
69- # publish:
70- # if: github.event_name == 'push' && github.ref == 'refs/heads/master'
71- # needs: test
72- # runs-on: ubuntu-latest
73- # strategy:
74- # matrix:
75- # include:
76- # - py_ver: 3.8
77- # distro: alpine
78- # image: djbase
79- # env:
80- # PY_VER: ${{matrix.py_ver}}
81- # DISTRO: ${{matrix.distro}}
82- # IMAGE: ${{matrix.image}}
83- # DOCKER_USERNAME: ${{secrets.docker_username}}
84- # DOCKER_PASSWORD: ${{secrets.docker_password}}
85- # steps:
86- # - name: Fetch image artifact
87- # uses: actions/download-artifact@v2
88- # with:
89- # name: ${{format('{0}-py{1}-{2}', matrix.conda_ver, matrix.py_ver, matrix.distro)}}
90- # - name: Publish image
91- # run: |
92- # echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
93- # docker load < "${CONDA_VER}-py${PY_VER}-${DISTRO}.tar.gz"
94- # IMAGE=$(docker images --filter "reference=datajoint/*" --format "{{.Repository}}")
95- # TAG=$(docker images --filter "reference=datajoint/*" --format "{{.Tag}}")
96- # docker push "${IMAGE}:${TAG}"
97- # docker tag "${IMAGE}:${TAG}" "${IMAGE}:${TAG}-${GITHUB_SHA:0:7}"
98- # docker push "${IMAGE}:${TAG}-${GITHUB_SHA:0:7}"
99- # [ "$PY_VER" == "3.9" ] && [ "$DISTRO" == "debian" ] \
100- # && docker tag "${IMAGE}:${TAG}" "${IMAGE}:latest" \
101- # && docker push "${IMAGE}:latest" \
102- # || echo "skipping 'latest' tag..."
78+ export HOST_UID=$(id -u)
79+ docker load < "image-pharus-${PHARUS_VERSION}-py${PY_VER}-${DISTRO}.tar.gz"
80+ docker-compose -f docker-compose-test.yaml up --exit-code-from pharus
81+ publish-release :
82+ if : github.event_name == 'push'
83+ needs : test
84+ runs-on : ubuntu-latest
85+ env :
86+ TWINE_USERNAME : ${{secrets.twine_username}}
87+ TWINE_PASSWORD : ${{secrets.twine_password}}
88+ steps :
89+ - uses : actions/checkout@v2
90+ - name : Determine package version
91+ run : |
92+ PHARUS_VERSION=$(cat pharus/version.py | tail -1 | awk -F\' '{print $2}')
93+ echo "PHARUS_VERSION=${PHARUS_VERSION}" >> $GITHUB_ENV
94+ - name : Fetch pip artifacts
95+ uses : actions/download-artifact@v2
96+ with :
97+ name : pip-pharus-${{env.PHARUS_VERSION}}
98+ - name : Publish pip release
99+ run : python -m twine upload dist/*
100+ - name : Get changelog entry
101+ id : changelog_reader
102+ uses : mindsers/changelog-reader-action@v2
103+ with :
104+ validation_depth : 10
105+ version : ${{steps.tag_name.outputs.current_version}}
106+ path : ./CHANGELOG.md
107+ - name : Create GH release
108+ id : create_gh_release
109+ uses : actions/create-release@v1
110+ env :
111+ GITHUB_TOKEN : ${{secrets.GITHUB_TOKEN}}
112+ with :
113+ tag_name : ${{github.ref}}
114+ release_name : Release ${{steps.changelog_reader.outputs.version}}
115+ body : ${{steps.changelog_reader.outputs.changes}}
116+ prerelease : ${{steps.changelog_reader.outputs.status == 'prereleased'}}
117+ draft : ${{steps.changelog_reader.outputs.status == 'unreleased'}}
118+ - name : Determine pip artifact paths
119+ run : |
120+ echo "PHARUS_WHEEL_PATH=$(ls dist/pharus-*.whl)" >> $GITHUB_ENV
121+ echo "PHARUS_SDIST_PATH=$(ls dist/pharus-*.tar.gz)" >> $GITHUB_ENV
122+ - name : Upload pip wheel asset to release
123+ uses : actions/upload-release-asset@v1
124+ env :
125+ GITHUB_TOKEN : ${{secrets.GITHUB_TOKEN}}
126+ with :
127+ upload_url : ${{steps.create_gh_release.outputs.upload_url}}
128+ asset_path : $${{env.PHARUS_WHEEL_PATH}}
129+ asset_name : pip-pharus-${{env.PHARUS_VERSION}}.whl
130+ asset_content_type : application/zip
131+ - name : Upload pip sdist asset to release
132+ uses : actions/upload-release-asset@v1
133+ env :
134+ GITHUB_TOKEN : ${{secrets.GITHUB_TOKEN}}
135+ with :
136+ upload_url : ${{steps.create_gh_release.outputs.upload_url}}
137+ asset_path : $${{env.PHARUS_SDIST_PATH}}
138+ asset_name : pip-pharus-${{env.PHARUS_VERSION}}.tar.gz
139+ asset_content_type : application/zip
140+ publish-images :
141+ if : github.event_name == 'push'
142+ needs : publish-release
143+ runs-on : ubuntu-latest
144+ strategy :
145+ matrix :
146+ include :
147+ - py_ver : 3.8
148+ distro : alpine
149+ image : djbase
150+ env :
151+ PY_VER : ${{matrix.py_ver}}
152+ DISTRO : ${{matrix.distro}}
153+ IMAGE : ${{matrix.image}}
154+ DOCKER_USERNAME : ${{secrets.docker_username}}
155+ DOCKER_PASSWORD : ${{secrets.docker_password}}
156+ steps :
157+ - uses : actions/checkout@v2
158+ - name : Determine package version
159+ run : |
160+ PHARUS_VERSION=$(cat pharus/version.py | tail -1 | awk -F\' '{print $2}')
161+ echo "PHARUS_VERSION=${PHARUS_VERSION}" >> $GITHUB_ENV
162+ - name : Fetch image artifact
163+ uses : actions/download-artifact@v2
164+ with :
165+ name : image-pharus-${{env.PHARUS_VERSION}}-py${{matrix.py_ver}}-${{matrix.distro}}
166+ - name : Publish image
167+ run : |
168+ echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
169+ docker load < "image-pharus-${PHARUS_VERSION}-py${PY_VER}-${DISTRO}.tar.gz"
170+ IMAGE=$(docker images --filter "reference=datajoint/*" --format "{{.Repository}}")
171+ TAG=$(docker images --filter "reference=datajoint/*" --format "{{.Tag}}")
172+ docker push "${IMAGE}:${TAG}"
173+ docker tag "${IMAGE}:${TAG}" "${IMAGE}:${TAG}-${GITHUB_SHA:0:7}"
174+ docker push "${IMAGE}:${TAG}-${GITHUB_SHA:0:7}"
175+ [ "$PY_VER" == "3.8" ] && [ "$DISTRO" == "alpine" ] \
176+ && docker tag "${IMAGE}:${TAG}" "${IMAGE}:latest" \
177+ && docker push "${IMAGE}:latest" \
178+ || echo "skipping 'latest' tag..."
179+ - name : Upload image to release
180+ uses : actions/upload-release-asset@v1
181+ env :
182+ GITHUB_TOKEN : ${{secrets.GITHUB_TOKEN}}
183+ with :
184+ upload_url : ${{needs.publish-release.steps.create_gh_release.outputs.upload_url}}
185+ asset_path : " image-pharus-${{env.PHARUS_VERSION}}-py${{matrix.py_ver}}-\
186+ ${{matrix.distro}}.tar.gz"
187+ asset_name : " image-pharus-${{env.PHARUS_VERSION}}-py${{matrix.py_ver}}-\
188+ ${{matrix.distro}}.tar.gz"
189+ asset_content_type : application/gzip
103190 # publish-docs:
104191 # if: github.event_name == 'push' && github.ref == 'refs/heads/master'
105192 # runs-on: ubuntu-latest
0 commit comments