release.yml 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. name: Release
  2. on:
  3. push:
  4. tags:
  5. - v*
  6. jobs:
  7. release:
  8. name: Release Artifacts
  9. runs-on: ubuntu-18.04
  10. steps:
  11. - name: Checkout
  12. uses: actions/checkout@v2
  13. - name: Build collection
  14. run: make archives
  15. - name: Create release
  16. id: create_release
  17. uses: actions/create-release@v1
  18. env:
  19. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  20. with:
  21. tag_name: ${{ github.ref }}
  22. release_name: pandoc-scholar ${{ github.ref }}
  23. draft: false
  24. prerelease: false
  25. - name: Add zip archive to release
  26. uses: actions/upload-release-asset@v1
  27. env:
  28. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  29. with:
  30. upload_url: ${{ steps.create_release.outputs.upload_url }}
  31. asset_path: ./dist/pandoc-scholar.zip
  32. asset_name: pandoc-scholar.zip
  33. asset_content_type: application/zip
  34. - name: Add tar archive to release
  35. uses: actions/upload-release-asset@v1
  36. env:
  37. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  38. with:
  39. upload_url: ${{ steps.create_release.outputs.upload_url }}
  40. asset_path: ./dist/pandoc-scholar.tar.gz
  41. asset_name: pandoc-scholar.tar.gz
  42. asset_content_type: application/x-gtar
  43. docker:
  44. name: Docker release
  45. runs-on: ubuntu-18.04
  46. strategy:
  47. fail-fast: false
  48. matrix:
  49. distro:
  50. - ubuntu
  51. - alpine
  52. steps:
  53. - name: Checkout
  54. uses: actions/checkout@v2
  55. - name: Create Docker image
  56. run: |
  57. docker build \
  58. --tag pandocscholar/${{ matrix.distro }}:latest \
  59. --file docker/${{ matrix.distro }}.Dockerfile \
  60. .
  61. - name: Run Docker on example
  62. run: |
  63. docker run --rm \
  64. --user "$(id -u):$(id -g)" \
  65. --volume "$(pwd)/example:/data" \
  66. pandocscholar/${{ matrix.distro }}:latest
  67. - name: Login to Docker Hub
  68. run: >-
  69. echo "${{ secrets.DOCKER_HUB_TOKEN }}" |
  70. docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
  71. - name: Push image as latest
  72. run: docker push pandocscholar/${{ matrix.distro }}:latest
  73. - name: Push image as version
  74. run: |
  75. version=$(printf "${{ github.ref }}" | sed 's#.*v\(.*\)$#\1#')
  76. if [ -n "${version}" ]; then
  77. docker tag \
  78. pandocscholar/${{ matrix.distro }}:latest \
  79. pandocscholar/${{ matrix.distro }}:${version}
  80. docker push pandocscholar/${{ matrix.distro }}:${version}
  81. else
  82. printf "Could not determine version" >&2
  83. exit 1
  84. fi