Skip to content

🎁 Armory Release Workflow #82

🎁 Armory Release Workflow

🎁 Armory Release Workflow #82

Workflow file for this run

---
name: 🎁 Armory Release Workflow
on:
repository_dispatch:
types: build-and-release
workflow_dispatch:
inputs:
dry_run:
type: boolean
description: Execute a dry-run(no uploads) of the workflow
required: true
default: true
# Limit workflow to one job per branch.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
RELEASE_DRY_RUN: "${{ github.event_name != 'repository_dispatch' && github.event.inputs.dry_run }}"
jobs:
release-wheel:
name: πŸ›ž Build release wheel
runs-on: ubuntu-latest
steps:
- name: 🐍 Setup Python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: πŸ“© Checkout Armory w/ full depth(for tags and SCM)
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: πŸ”¨ Build wheel
run: |
pip install pip==22.2.2
# Ensure `hatch` is installed
pip install hatch
hatch build --clean --target wheel
# TODO: Add pre-release steps; e.g. publish to TestPyPI
- name: 🐦 Release wheel
if: ${{ env.RELEASE_DRY_RUN == 'false' }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
# user: __token__
password: ${{ secrets.pypi_token }}
packages_dir: dist
verbose: true
- name: πŸ“ Archiving Artifacts
uses: actions/upload-artifact@v3
if: ${{ !failure() }}
continue-on-error: true
with:
name: armory-release-artifacts
retention-days: 1
path: |
dist/*.whl
release-base-image:
name: Build and Release Base Image
needs: [release-wheel]
runs-on: ubuntu-latest
steps:
- name: πŸ’Ώ Maximize build space
uses: easimon/maximize-build-space@master
with:
root-reserve-mb: 35000
swap-size-mb: 1024
remove-dotnet: 'true'
remove-android: 'true'
- name: 🐍 Setup Python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: πŸ“© Checkout Armory w/ full depth(for tags and SCM)
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: 🌎 Setup Build Environment
run: |
pip install pip>=22.2.2
pip install .
armory configure --use-defaults
- name: ☁️ Login to DockerHub
if: ${{ env.RELEASE_DRY_RUN == 'false' }}
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: πŸ”¨ Build and Push Base Image
run: |
echo "Building Base Image"
sed -i 's/\r$//' docker/build-base.sh
bash docker/build-base.sh
release-docker:
name: Build and Release Docker Images
needs: [release-wheel]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- image: armory
- image: pytorch-deepspeech
- image: yolo
steps:
- name: πŸ’Ώ Maximize build space
uses: easimon/maximize-build-space@master
with:
root-reserve-mb: 35000
swap-size-mb: 1024
remove-dotnet: 'true'
remove-android: 'true'
- name: 🐍 Setup Python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: πŸ“© Checkout Armory w/ full depth(for tags and SCM)
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: 🌎 Setup Build Environment
run: |
pip install pip>=22.2.2
pip install .
armory configure --use-defaults
ARMORY_VERSION=`python -m armory --version 2> /dev/null | sed -r 's/\+/\./g'`
echo "ARMORY_VERSION=${ARMORY_VERSION}" >> $GITHUB_ENV
- name: ☁️ Login to DockerHub
if: ${{ env.RELEASE_DRY_RUN == 'false' }}
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# run: |
# docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
# TODO: Build Base Image
- name: πŸ”¨ Build Release Image
run: |
echo "Armory Version: ${{ env.ARMORY_VERSION }}"
echo "Building Armory ${{ matrix.image }} Image"
python docker/build.py --framework ${{ matrix.image }} >> /tmp/build.log
- name: πŸ“ Archiving Artifacts
uses: actions/upload-artifact@v3
if: ${{ !failure() }}
continue-on-error: true
with:
name: armory-release-artifacts
retention-days: 1
path: |
/tmp/build.log
- name: πŸ“¦ Push Release Images
if: ${{ env.RELEASE_DRY_RUN == 'false' }}
run: |
ARMORY_VERSION="${{ env.ARMORY_VERSION }}"
echo "Pushing ${{ matrix.image }}:${ARMORY_VERSION}"
docker push twosixarmory/${{ matrix.image }}:${ARMORY_VERSION}
echo "Tagging ${{ matrix.image }}:${ARMORY_VERSION} as ${{ matrix.image }}:latest"
docker tag twosixarmory/${{ matrix.image }}:${ARMORY_VERSION} twosixarmory/${{ matrix.image }}:latest
echo "Pushing ${{ matrix.image }}:latest"
docker push twosixarmory/${{ matrix.image }}:latest
# Workflow Test:
# act --detect-event -j release-wheel
# act workflow_dispatch -j release-docker --eventpath .github/workflows/tests/release-dry-run.json