Skip to content

Commit

Permalink
build cache
Browse files Browse the repository at this point in the history
  • Loading branch information
v-chen_data committed Oct 19, 2024
1 parent ba8bb45 commit 16ed652
Showing 1 changed file with 26 additions and 51 deletions.
77 changes: 26 additions & 51 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,54 +7,8 @@ on:
workflow_dispatch:

jobs:
code-quality:
uses: ./.github/workflows/code-quality.yaml

pypi-packaging:
name: Build and Publish llm-foundry PyPI Package
needs:
- code-quality
runs-on: linux-ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: "3.9"

- name: Build source and wheel distributions
run: |
if [[ "${{ github.ref }}" =~ refs\/tags\/v ]]; then
PYPI_PACKAGE_NAME="llm-foundry"
else
PYPI_PACKAGE_NAME="llm-foundry-test-$(date +%Y%m%d%H%M%S)"
fi
python -m pip install --upgrade build twine
python -m build
twine check --strict dist/*
- name: Publish 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
if: contains(github.ref, 'refs/tags/v')
with:
user: __token__
password: ${{ secrets.PROD_PYPI_API_TOKEN }}

- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
if: contains(github.ref, 'refs/heads/') || contains(github.ref, 'refs/pull/')
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/

build-docker:
name: Build llm-foundry Release Docker Image
needs:
- code-quality
runs-on: mosaic-8wide
if: github.repository_owner == 'mosaicml'
steps:
Expand All @@ -70,18 +24,39 @@ jobs:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}

- name: Calculate Docker Image Variables
run: |
set -euxo pipefail
###################
# Calculate the tag
###################
GIT_SHA=$(echo ${{ github.sha }} | cut -c1-7)
echo "IMAGE_TAG=${GIT_SHA}" >> ${GITHUB_ENV}
if [ "${{ github.event_name }}" == "pull_request" ]; then
echo "Triggered by pull_request event."
STAGING_REPO="mosaicml/ci-staging"
IMAGE_CACHE="${STAGING_REPO}:${{matrix.name}}-buildcache"
else
# Triggered by push or workflow_dispatch event
echo "Triggered by ${{ github.event_name }} event, releasing to prod"
PROD_REPO="mosaicml/llm-foundry"
IMAGE_CACHE="${PROD_REPO}:${{matrix.name}}-buildcache"
fi
echo "IMAGE_TAG=${IMAGE_TAG}" >> ${GITHUB_ENV}
echo "IMAGE_CACHE=${IMAGE_CACHE}" >> ${GITHUB_ENV}
- name: Define Docker tags
id: define-tags
run: |
BRANCH_NAME="${{ github.ref_name }}"
TAG_NAME=$(echo "${BRANCH_NAME}" | sed 's/\//_/g')
echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_ENV
echo "DOCKER_TAG=mosaicml/llm-foundry:release_${TAG_NAME}" >> $GITHUB_ENV
echo "AWS_DOCKER_TAG=mosaicml/llm-foundry:release_${TAG_NAME}_aws" >> $GITHUB_ENV
echo "LATEST_TAG=mosaicml/llm-foundry:release-latest" >> $GITHUB_ENV
echo "AWS_LATEST_TAG=mosaicml/llm-foundry:release_aws-latest" >> $GITHUB_ENV
echo "DOCKER_TAG=mosaicml/llm-foundry:test-release_${TAG_NAME}" >> $GITHUB_ENV
echo "AWS_DOCKER_TAG=mosaicml/llm-foundry:test-release_${TAG_NAME}_aws" >> $GITHUB_ENV
- name: Build and push AWS Docker image
uses: docker/build-push-action@v3
Expand Down

0 comments on commit 16ed652

Please sign in to comment.