diff --git a/.github/workflows/image.yaml b/.github/workflows/image.yaml new file mode 100644 index 00000000..8281ff5a --- /dev/null +++ b/.github/workflows/image.yaml @@ -0,0 +1,65 @@ +# This workflow will upload a Python Package using Twine when a release is created +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Upload Python Package + +on: + push: + tags: + - v*.*.* + +jobs: + deploy: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.8 + uses: actions/setup-python@v3 + with: + python-version: '3.8' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build + - name: Update setup script with version (tag) name + run : | + sed -i "s/PACKAGE_VERSION/${{ github.ref_name }}/" setup.py + - name: Update CHAP.version with version (tag) name + run : | + sed -i "s/PACKAGE_VERSION/${{ github.ref_name }}/" CHAP/__init__.py + - name: Build package + run: python -m build + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build image + run: | + docker buildx build --platform linux/amd64 \ + -t ghcr.io/chesscomputing/chap:${{ steps.branch_name.outputs.SOURCE_TAG }} . + + - name: Login to ghcr.io registry + uses: docker/login-action@v1.6.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Publish image + uses: docker/build-push-action@v2 + with: + push: true + platforms: linux/amd64 + tags: | + ghcr.io/chesscomputing/chap:latest + ghcr.io/chesscomputing/chap:${{ steps.branch_name.outputs.SOURCE_TAG }}