Skip to content

Commit

Permalink
Merge pull request #79 from jjjermiah/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
jjjermiah committed Feb 3, 2024
2 parents 0c69c5c + ea39ee4 commit 90ad78d
Showing 1 changed file with 123 additions and 115 deletions.
238 changes: 123 additions & 115 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,127 +118,127 @@ jobs:
github_token: ${{ secrets.GITHUB_TOKEN }}
git_commit_message: 'chore(release): release ${next_version}'

- name: Install packaging-related tool
run:
python3 -m pip install build twine

# Build Package step:
# After semantic release, we should have a new tag if the commit history
# has been updated. If there isnt a new tag, then we dont need to build
# a new package. If there is a new tag, then we need to build a new package
# and publish it to PyPI
- name: Build package
if: steps.release.outputs.released == 'true'
run: |
poetry version $(git describe --tags --abbrev=0 | sed 's/^v//')
python -m build --sdist --wheel --outdir dist/ .
echo "LATEST_TAG=$(poetry version | sed 's/^nbiatoolkit //')" >> "$GITHUB_ENV"
- name: Publish package distributions to PyPI
if: steps.release.outputs.released == 'true'
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}

- name: Print latest tag name
run: |
printf "%s\n" "${LATEST_TAG}"
- name: Print branch name
run: |
printf "LATEST TAG: %s\n" "${LATEST_TAG}"
echo "DOCKER_IMAGE_TAG=${LATEST_TAG}" >> "$GITHUB_ENV"
printf "DOCKER_IMAGE_TAG: %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: Login to the GitHub Container Registry
if: steps.release.outputs.released == 'true'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: |
${{ secrets.DOCKERHUB_USERNAME }}/nbiatoolkit:${{ env.DOCKER_IMAGE_TAG }}
ghcr.io/${{ github.repository }}/nbiatoolkit:${{ env.DOCKER_IMAGE_TAG }}
- name: Build
if: steps.release.outputs.released == 'true'
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
file: ./Dockerfile
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/nbiatoolkit:${{ env.DOCKER_IMAGE_TAG }}
${{ secrets.DOCKERHUB_USERNAME }}/nbiatoolkit:latest
ghcr.io/${{ github.repository }}/nbiatoolkit:${{ env.DOCKER_IMAGE_TAG }}
ghcr.io/${{ github.repository }}/nbiatoolkit:latest
labels: ${{ steps.meta.outputs.labels }}

test_install_withPyPi:
needs: Continuous-Deployment
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, macos-14]
python-version: ["3.12", "3.11"]
# - name: Install packaging-related tool
# run:
# python3 -m pip install build twine

# # Build Package step:
# # After semantic release, we should have a new tag if the commit history
# # has been updated. If there isnt a new tag, then we dont need to build
# # a new package. If there is a new tag, then we need to build a new package
# # and publish it to PyPI
# - name: Build package
# if: steps.release.outputs.released == 'true'
# run: |
# poetry version $(git describe --tags --abbrev=0 | sed 's/^v//')
# python -m build --sdist --wheel --outdir dist/ .
# echo "LATEST_TAG=$(poetry version | sed 's/^nbiatoolkit //')" >> "$GITHUB_ENV"

# - name: Publish package distributions to PyPI
# if: steps.release.outputs.released == 'true'
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# verbose: true
# user: __token__
# password: ${{ secrets.PYPI_API_TOKEN }}

# - name: Print latest tag name
# run: |
# printf "%s\n" "${LATEST_TAG}"

# - name: Print branch name
# run: |
# printf "LATEST TAG: %s\n" "${LATEST_TAG}"
# echo "DOCKER_IMAGE_TAG=${LATEST_TAG}" >> "$GITHUB_ENV"
# printf "DOCKER_IMAGE_TAG: %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: Login to the GitHub Container Registry
# if: steps.release.outputs.released == 'true'
# uses: docker/login-action@v3
# with:
# registry: ghcr.io
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}

# - name: Extract metadata (tags, labels) for Docker
# id: meta
# uses: docker/metadata-action@v3
# with:
# images: |
# ${{ secrets.DOCKERHUB_USERNAME }}/nbiatoolkit:${{ env.DOCKER_IMAGE_TAG }}
# ghcr.io/${{ github.repository }}/nbiatoolkit:${{ env.DOCKER_IMAGE_TAG }}

# - name: Build
# if: steps.release.outputs.released == 'true'
# uses: docker/build-push-action@v5
# with:
# context: .
# platforms: linux/amd64,linux/arm64
# file: ./Dockerfile
# push: true
# tags: |
# ${{ secrets.DOCKERHUB_USERNAME }}/nbiatoolkit:${{ env.DOCKER_IMAGE_TAG }}
# ${{ secrets.DOCKERHUB_USERNAME }}/nbiatoolkit:latest
# ghcr.io/${{ github.repository }}/nbiatoolkit:${{ env.DOCKER_IMAGE_TAG }}
# ghcr.io/${{ github.repository }}/nbiatoolkit:latest
# labels: ${{ steps.meta.outputs.labels }}

# test_install_withPyPi:
# needs: Continuous-Deployment
# runs-on: ${{ matrix.os }}
# strategy:
# matrix:
# os: [ubuntu-latest, macos-latest, macos-14]
# python-version: ["3.12", "3.11"]

steps:
- uses: actions/checkout@v3
# steps:
# - uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
# - name: Set up Python ${{ matrix.python-version }}
# uses: actions/setup-python@v4
# with:
# python-version: ${{ matrix.python-version }}

- name: Install using PyPi
run: |
pip install nbiatoolkit;
NBIAToolkit
# - name: Install using PyPi
# run: |
# pip install nbiatoolkit;
# NBIAToolkit


test_image_with_new_tag:
needs: Continuous-Deployment
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
# test_image_with_new_tag:
# needs: Continuous-Deployment
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v3

- name: Test Image With new Tag
run: |
# get latest tag
LATEST_TAG=$(curl -s \
"https://api.github.com/repos/${{ github.repository }}/releases/latest" \
| jq -r .tag_name | sed 's/^v//')
echo "LATEST_TAG=${LATEST_TAG}"
# - name: Test Image With new Tag
# run: |
# # get latest tag
# LATEST_TAG=$(curl -s \
# "https://api.github.com/repos/${{ github.repository }}/releases/latest" \
# | jq -r .tag_name | sed 's/^v//')
# echo "LATEST_TAG=${LATEST_TAG}"

# test image with latest tag
docker run --rm \
${{ secrets.DOCKERHUB_USERNAME }}/nbiatoolkit:${LATEST_TAG} \
NBIAToolkit
# # test image with latest tag
# docker run --rm \
# ${{ secrets.DOCKERHUB_USERNAME }}/nbiatoolkit:${LATEST_TAG} \
# NBIAToolkit


test_image_with_latest_tag:
Expand Down Expand Up @@ -322,7 +322,15 @@ jobs:
git commit -m "Update README with latest version: $LATEST_TAG"
# Push changes to the remote repository
git push origin HEAD:${{ github.head_ref }}
# if github.head_ref is not null
# then push to the branch
# else push to the base branch
if [ -n "${{ github.head_ref }}" ]; then
git push origin HEAD:${{ github.head_ref }}
else
git push origin HEAD:${{ github.ref }}
fi
echo "Changes committed and pushed successfully."
else
Expand Down

0 comments on commit 90ad78d

Please sign in to comment.