Merge pull request #46 from ewdurbin/arm64_images #22
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: Publish | |
on: [push] | |
permissions: | |
contents: write | |
packages: write | |
jobs: | |
unit-tests: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Set up environment & install dependencies | |
run: | | |
python -m pip install pip-tools | |
pip-compile --quiet --generate-hashes --extra mainapp > requirements.txt | |
python -m pip install --requirement requirements.txt | |
python -m pip install .[test] | |
- name: Run tests | |
run: tox | |
- name: Check file contents | |
run: cat requirements.txt | |
- name: Create GitHub Release | |
if: startsWith(github.ref, 'refs/tags/release-') | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: | | |
requirements.txt | |
Dockerfile | |
- name: Store tested requirements.txt file as artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: requirements.txt | |
path: | | |
requirements.txt | |
publish-docker-image: | |
runs-on: ubuntu-latest | |
needs: [unit-tests] | |
steps: | |
- name: System Dependencies for Packaging | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y python3-pip python3-venv | |
python3 -m venv /tmp/tomlq | |
/tmp/tomlq/bin/pip install --upgrade pip | |
/tmp/tomlq/bin/pip install yq | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set Environment | |
run: | | |
echo "APP_VERSION=$(/tmp/tomlq/bin/tomlq -r .project.version pyproject.toml)" >> $GITHUB_ENV | |
echo "APP_DESC=$(/tmp/tomlq/bin/tomlq -r .project.description pyproject.toml)" >> $GITHUB_ENV | |
- name: Retrieve tested requirements file | |
uses: actions/download-artifact@v3 | |
with: | |
name: requirements.txt | |
- name: Check file contents | |
run: cat requirements.txt | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: 'arm64' | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GHCR | |
if: startsWith(github.ref, 'refs/tags/release-') | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and Push Docker Images | |
if: startsWith(github.ref, 'refs/tags/release-') | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
build-args: | | |
APP_VERSION=${{ env.APP_VERSION }} | |
APP_DESC=${{ env.APP_DESC }} | |
tags: | | |
ghcr.io/${{ github.repository }}:${{ env.APP_VERSION }} | |
ghcr.io/${{ github.repository }}:latest | |
pypi-publish: | |
needs: [unit-tests] | |
if: startsWith(github.ref, 'refs/tags/release-') | |
name: Upload release to PyPI | |
runs-on: ubuntu-latest | |
environment: | |
name: pypi | |
url: https://pypi.org/p/httpbin | |
permissions: | |
id-token: write | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Build distribution | |
run: | | |
python -m pip install --upgrade pip build | |
pyproject-build | |
- name: Publish package distributions to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 |