xemu-test/.github/workflows/build_docker_image.yml
2022-03-22 15:21:55 -07:00

93 lines
2.6 KiB
YAML

name: Build Docker image
on: [push, pull_request]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-container:
name: Build and Publish Image
if: github.repository_owner == 'mborgerson'
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Clone Tree
uses: actions/checkout@v2
with:
submodules: recursive
- name: Extract image metadata (tags, labels)
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push image
uses: docker/build-push-action@v2
with:
context: .
push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-wheel:
runs-on: ubuntu-latest
needs: [build-container]
steps:
- uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Clone Tree
uses: actions/checkout@v2
with:
submodules: recursive
- name: Build Test Data
run: bash ./scripts/build_test_data.sh
- name: Build wheel
run: |
pip install wheel
pip install .
mkdir /tmp/wheels
pip wheel -w /tmp/wheels .
mv /tmp/wheels/xemutest-*.whl .
- name: Get package info
run: |
echo "TAG_NAME=wheel-$(date -u +'%Y%m%d%H%M')" >> $GITHUB_ENV
echo "WHEEL_FILENAME=$(ls *.whl)" >> $GITHUB_ENV
- name: Publish release
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.TAG_NAME }}
name: ${{ env.TAG_NAME }}
prerelease: false
draft: false
files: ${{ env.WHEEL_FILENAME }}
- name: Drop outdated wheels
uses: dev-drprasad/delete-older-releases@v0.2.0
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
with:
keep_latest: 1
delete_tag_pattern: wheel-
delete_tags: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}