File: publish.yml

package info (click to toggle)
pdf2docx 0.5.10-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 16,876 kB
  • sloc: python: 6,843; makefile: 82; sh: 9
file content (127 lines) | stat: -rw-r--r-- 3,506 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# Create release and publish to Pypi when pushing tags

name: publish

# Trigger the workflow on push tags, matching vM.n.p, i.e. v3.2.10
on:  
  push:
    tags:
      - 'v[0-9]+.[0-9]+.[0-9]+'

# Jobs to do:
# - build package
# - create release with asset
# - publish to Pypi
jobs:

  # -----------------------------------------------------------
  # create python env and setup package
  # -----------------------------------------------------------
  build:

    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      - name: Check out code
        uses: actions/checkout@v2

      - name: Set up Python 3.x
        uses: actions/setup-python@v1
        with:
          python-version: '3.10'

      - name: Display Python version
        run: python -c "import sys; print(sys.version)"

      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install setuptools wheel pytest

      # build package for tags, e.g. 3.2.1 extracted from 'refs/tags/v3.2.1'
      - name: Build package
        run: |
          echo ${GITHUB_REF#refs/tags/v} > version.txt
          python setup.py sdist --formats=gztar,zip
          python setup.py bdist_wheel

      # test wheel file locally
      - name: Test package
        run: |
          pip install ./dist/*.whl
          cd test
          pytest -v test.py::TestConversion

      # upload the artifacts for further jobs
      # - app-tag.tar.gz
      # - app-tag.zip
      # - app-tag-info.whl
      - name: Archive package
        uses: actions/upload-artifact@v4
        with:
            name: dist
            path: ./dist
  
  # -----------------------------------------------------------
  # create release and upload asset
  # -----------------------------------------------------------
  release:
    runs-on: ubuntu-latest

    # Run this job after build completes successfully
    needs: build

    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      # download artifacts from job: build
      - name: Download artifacts from build
        uses: actions/download-artifact@v4
        with:
          name: dist
          path: dist

      # create release and upload assets
      - name: Create release with assets
        uses: softprops/action-gh-release@v1
        with:
          files: |
            ./dist/*.tar.gz
            ./dist/*.zip
            ./dist/*.whl
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


  # -----------------------------------------------------------
  # publish to Pypi
  # -----------------------------------------------------------
  publish:
    runs-on: ubuntu-latest

    # Run this job after both build and release completes successfully
    needs: [build, release]

    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Download artifacts from release
        uses: actions/download-artifact@v4
        with:
          name: dist
          path: dist

      # Error when two sdist files created in build job are uploaded to Pipi:
      # HTTPError: 400 Bad Request from https://upload.pypi.org/legacy/
      # Only one sdist may be uploaded per release.
      - name: Remove duplicated sdist
        run: rm ./dist/*.zip

      - name: Publish to PyPI
        uses: pypa/gh-action-pypi-publish@master
        with:
          password: ${{ secrets.PYPI_PASSWORD }}