Skip to content

Commit

Permalink
ci: combine deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
jjjermiah committed Jan 22, 2024
1 parent e3fc18c commit 67c17f4
Showing 1 changed file with 9 additions and 28 deletions.
37 changes: 9 additions & 28 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ jobs:
run: |
poetry version $(git describe --tags --abbrev=0 | sed 's/^v//')
python -m build --sdist --wheel --outdir dist/ .
ls dist/
echo "LATEST_TAG=$(poetry version | sed 's/^nbiatoolkit //')" >> "$GITHUB_ENV"
- name: Publish package distributions to PyPI
if: steps.release.outputs.released == 'true'
Expand All @@ -115,33 +115,9 @@ jobs:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}


build:
needs: Continuous-Deployment
runs-on: ubuntu-latest
# first we need to check out the code
steps:
- name: Set up Python 3.12
uses: actions/setup-python@v2
with:
python-version: 3.12

- name: Check-out repository
uses: actions/checkout@v2
with:
fetch-depth: 0


# The docker image tag is the git release tag
# If there is no release tag, then we will use the branch name
# as the docker image tag
- name: Get latest tag name 2
run: |
echo "LATEST_TAG_NEW=$(git describe --tags --abbrev=0 | sed 's/^v//')" >> "$GITHUB_ENV"
- name: Print latest tag name
run: |
printf "%s\n" "${LATEST_TAG_NEW}"
printf "%s\n" "${LATEST_TAG}"
- name: Get branch name
run: |
Expand All @@ -153,29 +129,33 @@ jobs:
- name: Set docker image tag
run: |
if [ -z "${LATEST_TAG_NEW}" ]; then
if [ -z "${LATEST_TAG}" ]; then
echo "DOCKER_IMAGE_TAG=${BRANCH_NAME}" >> "$GITHUB_ENV"
else
echo "DOCKER_IMAGE_TAG=${LATEST_TAG_NEW}" >> "$GITHUB_ENV"
echo "DOCKER_IMAGE_TAG=${LATEST_TAG}" >> "$GITHUB_ENV"
fi
- name: Print docker image tag
run: |
printf "%s\n" "${DOCKER_IMAGE_TAG}"
- name: Set up QEMU
if: steps.release.outputs.released == 'true'
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
if: steps.release.outputs.released == 'true'
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
if: steps.release.outputs.released == 'true'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build
if: steps.release.outputs.released == 'true'
uses: docker/build-push-action@v5
with:
context: .
Expand All @@ -185,6 +165,7 @@ jobs:
tags: ${{ secrets.DOCKERHUB_USERNAME }}/nbiatoolkit:${{ env.DOCKER_IMAGE_TAG }}

- name: Test Image
if: steps.release.outputs.released == 'true'
run: |
docker run --rm \
${{ secrets.DOCKERHUB_USERNAME }}/nbiatoolkit:${{ env.DOCKER_IMAGE_TAG }} \
Expand Down

0 comments on commit 67c17f4

Please sign in to comment.