|
62 | 62 | flags: unittests |
63 | 63 | name: ${{ matrix.python-version }} |
64 | 64 | fail_ci_if_error: false |
| 65 | + |
| 66 | + publish: |
| 67 | + needs: [tests] |
| 68 | + runs-on: ubuntu-latest |
| 69 | + if: contains(github.ref, 'tags') && github.event_name == 'push' |
| 70 | + steps: |
| 71 | + - uses: actions/checkout@v2 |
| 72 | + - name: Set up Python |
| 73 | + uses: actions/setup-python@v1 |
| 74 | + with: |
| 75 | + python-version: ${{ env.LATEST_PY_VERSION }} |
| 76 | + |
| 77 | + - name: Install dependencies |
| 78 | + run: | |
| 79 | + python -m pip install --upgrade pip |
| 80 | + python -m pip install flit |
| 81 | + python -m pip install . |
| 82 | +
|
| 83 | + - name: Set tag version |
| 84 | + id: tag |
| 85 | + # https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions |
| 86 | + run: echo ::set-output name=tag::${GITHUB_REF#refs/*/} |
| 87 | + |
| 88 | + - name: Set module version |
| 89 | + id: module |
| 90 | + # https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions |
| 91 | + run: echo ::set-output name=version::$(python -c 'from importlib.metadata import version; print(version("tifeatures"))') |
| 92 | + |
| 93 | + - name: Build and publish |
| 94 | + if: steps.tag.outputs.tag == steps.module.outputs.version |
| 95 | + env: |
| 96 | + FLIT_USERNAME: ${{ secrets.PYPI_USERNAME }} |
| 97 | + FLIT_PASSWORD: ${{ secrets.PYPI_PASSWORD }} |
| 98 | + run: flit publish |
| 99 | + |
| 100 | + publish-docker: |
| 101 | + needs: [tests] |
| 102 | + if: github.ref == 'refs/heads/master' || startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release' |
| 103 | + runs-on: ubuntu-latest |
| 104 | + steps: |
| 105 | + - name: Checkout |
| 106 | + uses: actions/checkout@v2 |
| 107 | + |
| 108 | + - name: Set up QEMU |
| 109 | + uses: docker/setup-qemu-action@v1 |
| 110 | + |
| 111 | + - name: Set up Docker Buildx |
| 112 | + uses: docker/setup-buildx-action@v1 |
| 113 | + |
| 114 | + - name: Login to Github |
| 115 | + uses: docker/login-action@v1 |
| 116 | + with: |
| 117 | + registry: ghcr.io |
| 118 | + username: ${{ github.actor }} |
| 119 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 120 | + |
| 121 | + - name: Set tag version |
| 122 | + id: tag |
| 123 | + # https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions |
| 124 | + run: echo ::set-output name=tag::${GITHUB_REF#refs/*/} |
| 125 | + |
| 126 | + # Push `latest` when commiting to master |
| 127 | + - name: Build and push |
| 128 | + if: github.ref == 'refs/heads/master' |
| 129 | + uses: docker/build-push-action@v2 |
| 130 | + with: |
| 131 | + platforms: linux/amd64,linux/arm64 |
| 132 | + context: . |
| 133 | + file: dockerfiles/Dockerfile |
| 134 | + push: true |
| 135 | + tags: | |
| 136 | + ghcr.io/${{ github.repository }}:latest |
| 137 | +
|
| 138 | + # Push `{VERSION}` when pushing a new tag |
| 139 | + - name: Build and push |
| 140 | + if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release' |
| 141 | + uses: docker/build-push-action@v2 |
| 142 | + with: |
| 143 | + platforms: linux/amd64,linux/arm64 |
| 144 | + context: . |
| 145 | + file: dockerfiles/Dockerfile |
| 146 | + push: true |
| 147 | + tags: | |
| 148 | + ghcr.io/${{ github.repository }}:${{ steps.tag.outputs.tag }} |
0 commit comments