|
20 | 20 |
|
21 | 21 | name: build
|
22 | 22 | on:
|
23 |
| - - push |
24 |
| - - pull_request |
| 23 | + push: |
| 24 | + branches: |
| 25 | + - master |
| 26 | + pull_request: |
| 27 | + release: |
| 28 | + types: |
| 29 | + - published |
25 | 30 |
|
26 | 31 | env:
|
27 | 32 | NODE_VERSION: 14.x
|
| 33 | + PYTHON_VERSION: 3.x |
28 | 34 |
|
29 | 35 | permissions:
|
30 | 36 | contents: read
|
31 | 37 |
|
32 | 38 | jobs:
|
33 |
| - build: |
34 |
| - name: Build project |
| 39 | + npm: |
35 | 40 | runs-on: ubuntu-latest
|
36 | 41 | steps:
|
37 | 42 |
|
|
61 | 66 | run: |
|
62 | 67 | npm run build
|
63 | 68 | git diff --name-only
|
| 69 | +
|
| 70 | + pypi: |
| 71 | + runs-on: ubuntu-latest |
| 72 | + steps: |
| 73 | + |
| 74 | + - name: Checkout repository |
| 75 | + uses: actions/checkout@v3 |
| 76 | + |
| 77 | + - name: Set up Python runtime |
| 78 | + uses: actions/setup-python@v4 |
| 79 | + with: |
| 80 | + python-version: ${{ env.PYTHON_VERSION }} |
| 81 | + |
| 82 | + - name: Set up Python dependencies |
| 83 | + run: pip install --upgrade build twine |
| 84 | + |
| 85 | + - name: Build Python package |
| 86 | + run: python -m build |
| 87 | + |
| 88 | + - name: Publish Python package |
| 89 | + if: github.event_name == 'release' |
| 90 | + env: |
| 91 | + PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }} |
| 92 | + PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} |
| 93 | + run: twine upload --disable-progress-bar -u ${PYPI_USERNAME} -p ${PYPI_PASSWORD} dist/* |
| 94 | + |
| 95 | + docker: |
| 96 | + runs-on: ubuntu-latest |
| 97 | + steps: |
| 98 | + |
| 99 | + - name: Checkout repository |
| 100 | + uses: actions/checkout@v3 |
| 101 | + |
| 102 | + - name: Set up Docker Buildx |
| 103 | + uses: docker/setup-buildx-action@v2 |
| 104 | + |
| 105 | + - name: Login to DockerHub |
| 106 | + if: github.event_name == 'release' |
| 107 | + uses: docker/login-action@v2 |
| 108 | + with: |
| 109 | + username: ${{ secrets.DOCKER_USERNAME }} |
| 110 | + password: ${{ secrets.DOCKER_PASSWORD }} |
| 111 | + |
| 112 | + - name: Login to GitHub Container Registry |
| 113 | + if: github.event_name == 'release' |
| 114 | + uses: docker/login-action@v2 |
| 115 | + with: |
| 116 | + registry: ghcr.io |
| 117 | + username: ${{ github.repository_owner }} |
| 118 | + password: ${{ secrets.GHCR_TOKEN }} |
| 119 | + |
| 120 | + - name: Generate Docker tags and labels |
| 121 | + id: meta |
| 122 | + uses: docker/metadata-action@v4 |
| 123 | + with: |
| 124 | + images: | |
| 125 | + ${{ github.event.repository.full_name }} |
| 126 | + ghcr.io/${{ github.event.repository.full_name }} |
| 127 | + tags: | |
| 128 | + type=ref,event=branch |
| 129 | + type=ref,event=tag |
| 130 | + type=ref,event=pr |
| 131 | + flavor: | |
| 132 | + latest=${{ github.event.release.prerelease == false }} |
| 133 | +
|
| 134 | + - name: Build Docker image |
| 135 | + uses: docker/build-push-action@v4 |
| 136 | + with: |
| 137 | + context: . |
| 138 | + load: true |
| 139 | + tags: ${{ steps.meta.outputs.tags }} |
| 140 | + labels: ${{ steps.meta.outputs.labels }} |
| 141 | + |
| 142 | + - name: Check Docker image |
| 143 | + working-directory: /tmp |
| 144 | + run: | |
| 145 | + docker run --rm -i -v ${PWD}:/docs ${{ github.event.repository.full_name }}:${{ steps.meta.outputs.version }} new . |
| 146 | + docker run --rm -i -v ${PWD}:/docs ${{ github.event.repository.full_name }}:${{ steps.meta.outputs.version }} build |
| 147 | +
|
| 148 | + - name: Publish Docker image |
| 149 | + uses: docker/build-push-action@v4 |
| 150 | + with: |
| 151 | + context: . |
| 152 | + push: ${{ github.event_name == 'release' }} |
| 153 | + tags: ${{ steps.meta.outputs.tags }} |
| 154 | + labels: ${{ steps.meta.outputs.labels }} |
0 commit comments