π Armory Release Workflow #81
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
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 |