before_deploy doesn’t run unless something is going to be deployed

This commit is contained in:
James R. Barlow
2017-03-03 00:21:51 -08:00
parent 4a1fec8328
commit 8444a8f211
6 changed files with 92 additions and 3 deletions

View File

@@ -41,6 +41,9 @@ script:
- pytest
- mv dont_import_this_ocrmypdf ocrmypdf
after_success:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then bash .travis/osx_before_deploy.sh ; fi
# See https://www.appneta.com/blog/pypi-deployment-with-travis-ci/ for
# steps to set up testpypi deploy for untagged builds if desired

66
.travis/autobrew.py Normal file
View File

@@ -0,0 +1,66 @@
from string import Template
from subprocess import run, PIPE
import re
recipe_template = Template("""
class Ocrmypdf < Formula
include Language::Python::Virtualenv
desc "Adds an OCR text layer to scanned PDF files"
homepage "https://github.com/jbarlow83/OCRmyPDF"
${ocrmypdf_url}
${ocrmypdf_sha256}
depends_on :python3
depends_on "tesseract"
depends_on "ghostscript"
depends_on "unpaper"
depends_on "qpdf"
${poet_resources}
def install
ENV.append ["SETUPTOOLS_SCM_PRETEND_VERSION"], "v${ocrmypdf_version}"
ENV.each do |key, value|
puts "#{key}:#{value}"
end
virtualenv_install_with_resources
end
test do
# `test do` will create, run in and delete a temporary directory.
#
# This test will fail and we won't accept that! It's enough to just replace
# "false" with the main program this formula installs, but it'd be nice if you
# were more thorough. Run the test with `brew test OCRmyPDF`. Options passed
# to `brew install` such as `--HEAD` also need to be provided to `brew test`.
#
# The installed folder is not in the path, so use the entire path to any
# executables being tested: `system "#{bin}/program", "do", "something"`.
system "#{bin}/ocrmypdf", "--version"
end
end
""")
def main():
p = run(['poet', '--single', 'ocrmypdf'],
encoding='utf-8', stdout=PIPE, check=True)
ocrmypdf_lines = p.stdout.splitlines()
ocrmypdf_url = ocrmypdf_lines[1].strip()
ocrmypdf_sha256 = ocrmypdf_lines[2].strip()
ocrmypdf_version = re.search(
r'ocrmypdf-(.+)\.tar.*', ocrmypdf_url).group(1)
print(f"Autobrewing {ocrmypdf_version}")
p = run(['poet', '--resources', 'ocrmypdf'],
encoding='utf-8', stdout=PIPE, check=True)
poet_resources = p.stdout
with open('ocrmypdf.rb', 'w') as out:
out.write(recipe_template.substitute(**locals()))
if __name__ == '__main__':
main()

View File

@@ -1,4 +1,6 @@
#!/bin/bash
set -euo pipefail
set -x
sudo add-apt-repository ppa:vshn/ghostscript -y
sudo add-apt-repository ppa:heyarje/libav-11 -y
@@ -19,4 +21,4 @@ sudo apt-get install -y \
pip install --upgrade pip
mkdir -p packages
[ -f packages/unpaper_6.1-1.deb ] || wget -q https://dl.dropboxusercontent.com/u/28971240/unpaper_6.1-1.deb -O packages/unpaper_6.1-1.deb
sudo dpkg -i packages/unpaper_6.1-1.deb
sudo dpkg -i packages/unpaper_6.1-1.deb

View File

@@ -0,0 +1,8 @@
#!/bin/bash
set -euo pipefail
set -x
pip3 install homebrew-pypi-poet
python3 .travis/autobrew.py
brew audit ocrmypdf.rb
cat ocrmypdf.rb

View File

@@ -1,8 +1,10 @@
#!/bin/bash
set -euo pipefail
set -x
brew update
brew install libpng openjpeg jbig2dec libtiff # image libraries
brew install openjpeg jbig2dec libtiff # image libraries
brew install qpdf
brew install ghostscript
brew install python3
@@ -11,4 +13,4 @@ brew install unpaper # optional
brew install tesseract
pip3 install --upgrade pip
pip3 install wheel
pip3 install wheel

8
.travis/osx_brew.sh Normal file
View File

@@ -0,0 +1,8 @@
#!/bin/bash
set -euo pipefail
set -x
pip3 install homebrew-pypi-poet
python3 .travis/autobrew.py
brew audit ocrmypdf.rb
cat ocrmypdf.rb