Skip to content

Commit

Permalink
build: try using release output version
Browse files Browse the repository at this point in the history
  • Loading branch information
jjjermiah committed Mar 9, 2024
1 parent b5f5cb4 commit 2d7508a
Showing 1 changed file with 19 additions and 35 deletions.
54 changes: 19 additions & 35 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, macos-14]
python-version: ["3.12", "3.11"] # "3.10",
os: [ubuntu-latest]
python-version: ["3.12"]
# os: [ubuntu-latest, macos-latest, macos-14]
# python-version: ["3.12", "3.11"]

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -95,10 +97,10 @@ jobs:
issues: write
pull-requests: write

needs: [Unit-Tests]
# needs: [Unit-Tests]

# if pulling to main, deploy to PyPI
if: github.ref == 'refs/heads/main'
# if: github.ref == 'refs/heads/main'

# Set up operating system
runs-on: ubuntu-latest
Expand Down Expand Up @@ -133,6 +135,12 @@ jobs:
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Test Outputs of semantic release step
run: |
echo "${{ steps.release.outputs.released }}"
echo "${{ steps.release.outputs.version }}"
echo "${{ steps.release.outputs.tag }}"
- name: Install packaging-related tool
run:
python3 -m pip install build twine
Expand All @@ -145,9 +153,8 @@ jobs:
- name: Build package
if: steps.release.outputs.released == 'true'
run: |
poetry version $(git describe --tags --abbrev=0 | sed 's/^v//')
poetry version ${{ steps.release.outputs.version }}
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'
Expand All @@ -157,23 +164,6 @@ jobs:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}

- 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: Print outputs from semantic release
run: |
# Semantic release gha provides the following outputs:
# - released: true if a new release was created, false otherwise
# - version: the new version number
# - tag: The Git tag that was created
echo "${{ steps.release.outputs.released }}"
echo "${{ steps.release.outputs.version }}"
echo "${{ steps.release.outputs.tag }}"
echo "${{ steps.release.outputs.release_notes }}"
- name: Set up QEMU
if: steps.release.outputs.released == 'true'
uses: docker/setup-qemu-action@v3
Expand Down Expand Up @@ -202,8 +192,8 @@ jobs:
uses: docker/metadata-action@v3
with:
images: |
${{ secrets.DOCKERHUB_USERNAME }}/nbiatoolkit:${{ env.DOCKER_IMAGE_TAG }}
ghcr.io/${{ github.repository }}/nbiatoolkit:${{ env.DOCKER_IMAGE_TAG }}
${{ secrets.DOCKERHUB_USERNAME }}/nbiatoolkit:${{ steps.release.outputs.tag }}
ghcr.io/${{ github.repository }}/nbiatoolkit:${{ steps.release.outputs.tag }}
- name: Build
if: steps.release.outputs.released == 'true'
Expand All @@ -214,9 +204,9 @@ jobs:
file: ./Dockerfile
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/nbiatoolkit:${{ env.DOCKER_IMAGE_TAG }}
${{ secrets.DOCKERHUB_USERNAME }}/nbiatoolkit:${{ steps.release.outputs.tag }}
${{ secrets.DOCKERHUB_USERNAME }}/nbiatoolkit:latest
ghcr.io/${{ github.repository }}/nbiatoolkit:${{ env.DOCKER_IMAGE_TAG }}
ghcr.io/${{ github.repository }}/nbiatoolkit:${{ steps.release.outputs.tag }}
ghcr.io/${{ github.repository }}/nbiatoolkit:latest
labels: ${{ steps.meta.outputs.labels }}

Expand Down Expand Up @@ -251,15 +241,9 @@ jobs:

- 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} \
${{ secrets.DOCKERHUB_USERNAME }}/nbiatoolkit:${{ steps.release.outputs.tag }} \
NBIAToolkit
Expand All @@ -279,7 +263,7 @@ jobs:
Update-README:
needs: Continuous-Deployment
runs-on: ubuntu-latest
# if: github.ref == 'refs/heads/development'
if: steps.release.outputs.released == 'true' # only run if the branch is main and a new release has been made
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand Down

0 comments on commit 2d7508a

Please sign in to comment.