Re-add importlib_metadata to dependencies. #93
Workflow file for this run
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 to PyPI and Docker | |
on: | |
push: | |
tags: | |
- 'v*.*.*' | |
workflow_dispatch: | |
jobs: | |
pypi: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/[email protected] | |
with: | |
python-version: '3.x' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install build twine | |
- name: Import GPG | |
uses: crazy-max/ghaction-import-gpg@v6 | |
with: | |
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} | |
passphrase: ${{ secrets.GPG_PASSPHRASE }} | |
- name: Build and publish | |
env: | |
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} | |
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | |
run: | | |
python -m build | |
twine upload --skip-existing --sign dist/* | |
docker-hub: | |
runs-on: ubuntu-latest | |
needs: pypi | |
steps: | |
- name: Checkout project | |
uses: actions/checkout@v4 | |
- name: Fetching tags | |
run: git fetch --prune --unshallow --force --tags | |
- name: Prepare | |
id: prep | |
run: | | |
DOCKER_IMAGE=maestraldbx/maestral | |
LAST_GIT_TAG=$(git describe --tags --abbrev=0) | |
MAESTRAL_VERSION=${LAST_GIT_TAG:1} | |
VERSION=noop | |
GIT_BRANCH=${GITHUB_REF##*/} | |
if [ "${{ github.event_name }}" = "schedule" ]; then | |
VERSION=nightly | |
elif [ "${{ github.event_name }}" = "pull_request_target" ]; then | |
VERSION=pr-${{ github.event.number }} | |
elif [[ $GITHUB_REF == refs/tags/* ]]; then | |
VERSION=${GITHUB_REF#refs/tags/} | |
elif [[ $GITHUB_REF == refs/heads/* ]]; then | |
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g') | |
if [ "${{ github.event.repository.default_branch }}" = "$VERSION" ]; then | |
VERSION=edge | |
fi | |
fi | |
TAGS="${DOCKER_IMAGE}:${VERSION}" | |
if [[ $VERSION =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then | |
MAESTRAL_VERSION=${VERSION:1} | |
MINOR=${MAESTRAL_VERSION%.*} | |
MAJOR=${MINOR%.*} | |
TAGS="${DOCKER_IMAGE}:${MAESTRAL_VERSION},${DOCKER_IMAGE}:${MINOR},${DOCKER_IMAGE}:${MAJOR},${DOCKER_IMAGE}:latest" | |
fi | |
echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
echo "maestral_version=${MAESTRAL_VERSION}" >> $GITHUB_OUTPUT | |
echo "docker_image=${DOCKER_IMAGE}" >> $GITHUB_OUTPUT | |
echo "git_branch=${GIT_BRANCH}" >> $GITHUB_OUTPUT | |
echo "tags=${TAGS}" >> $GITHUB_OUTPUT | |
echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT | |
- name: Wait for PyPI release | |
run: | | |
echo "Waiting for PyPI release ${{ steps.prep.outputs.maestral_version }}" | |
while [[ $(curl -s "https://pypi.org/pypi/maestral/${{ steps.prep.outputs.maestral_version }}/json") == *"Not Found"* ]] | |
do | |
sleep 2 | |
done | |
# There is delay until packages actually can be downloaded for all platforms. | |
sleep 10 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
build-args: | | |
VERSION=${{ steps.prep.outputs.maestral_version }} | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache-new | |
context: . | |
file: ./Dockerfile | |
# See https://github.com/opencontainers/image-spec/blob/master/annotations.md | |
labels: | | |
org.opencontainers.image.created=${{ steps.prep.outputs.created }} | |
org.opencontainers.image.description=${{ github.event.repository.description }} | |
org.opencontainers.image.docker.cmd=docker run -d --rm --name maestral -v /home/dropbox:/dropbox maestral | |
org.opencontainers.image.documentation=https://maestral.readthedocs.io/en/latest | |
org.opencontainers.image.licenses=${{ github.event.repository.license.spdx_id }} | |
org.opencontainers.image.ref.name=${{ steps.prep.outputs.git_branch }} | |
org.opencontainers.image.revision=${{ github.sha }} | |
org.opencontainers.image.source=${{ github.event.repository.clone_url }} | |
org.opencontainers.image.title=Maestral | |
org.opencontainers.image.url=${{ github.event.repository.html_url }} | |
org.opencontainers.image.version=${{ steps.prep.outputs.version }} | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: ${{ steps.prep.outputs.tags }} | |
- name: Move cache | |
# Temp fix | |
# https://github.com/docker/build-push-action/issues/252 | |
# https://github.com/moby/buildkit/issues/1896 | |
if: ${{ always() }} | |
run: | | |
rm -rf /tmp/.buildx-cache | |
mv /tmp/.buildx-cache-new /tmp/.buildx-cache |