|
4 | 4 | push: |
5 | 5 | branches: [ master ] |
6 | 6 | release: |
7 | | - types: [published] |
| 7 | + types: [ published ] |
| 8 | + workflow_dispatch: {} |
8 | 9 |
|
9 | 10 | jobs: |
10 | 11 | build-and-push: |
11 | 12 | runs-on: ubuntu-latest |
12 | 13 | permissions: |
13 | 14 | contents: read |
14 | 15 | packages: write |
| 16 | + env: |
| 17 | + IMAGE_NAME: unet-lungs-segmentation |
| 18 | + |
15 | 19 | steps: |
16 | 20 | - name: Checkout |
17 | 21 | uses: actions/checkout@v4 |
18 | 22 |
|
19 | | - - name: Extract version |
| 23 | + - name: Compute owner + version |
20 | 24 | id: vars |
| 25 | + shell: bash |
21 | 26 | run: | |
22 | | - VERSION=$(grep -Po '^(version\s*=\s*).*' setup.cfg | sed -E 's/version\s*=\s*//') |
23 | | - echo "version=${VERSION}" >> $GITHUB_OUTPUT |
| 27 | + OWNER_LC="${GITHUB_REPOSITORY_OWNER,,}" |
| 28 | + VERSION="$(grep -Po '^[[:space:]]*version[[:space:]]*=[[:space:]]*\K.*' setup.cfg || true)" |
| 29 | + if [ -z "$VERSION" ]; then VERSION="${GITHUB_SHA::7}"; fi |
| 30 | + echo "owner=${OWNER_LC}" >> "$GITHUB_OUTPUT" |
| 31 | + echo "version=${VERSION}" >> "$GITHUB_OUTPUT" |
24 | 32 |
|
25 | 33 | - name: Set up QEMU |
26 | 34 | uses: docker/setup-qemu-action@v3 |
27 | 35 |
|
28 | 36 | - name: Set up Docker Buildx |
29 | 37 | uses: docker/setup-buildx-action@v3 |
30 | 38 |
|
31 | | - - name: Login to GitHub Container Registry |
| 39 | + - name: Log in to GHCR |
32 | 40 | uses: docker/login-action@v3 |
33 | 41 | with: |
34 | 42 | registry: ghcr.io |
35 | 43 | username: ${{ github.actor }} |
36 | 44 | password: ${{ secrets.GITHUB_TOKEN }} |
37 | 45 |
|
38 | | - - name: Build and push image (GHCR) |
| 46 | + - name: Build and push |
39 | 47 | uses: docker/build-push-action@v5 |
40 | 48 | with: |
41 | 49 | context: . |
42 | 50 | push: true |
43 | 51 | tags: | |
44 | | - ghcr.io/${{ github.repository_owner }}/unet-lungs-segmentation:latest |
45 | | - ghcr.io/${{ github.repository_owner }}/unet-lungs-segmentation:${{ steps.vars.outputs.version }} |
46 | | - ghcr.io/${{ github.repository_owner }}/unet-lungs-segmentation:${{ github.sha }} |
| 52 | + ghcr.io/${{ steps.vars.outputs.owner }}/${{ env.IMAGE_NAME }}:latest |
| 53 | + ghcr.io/${{ steps.vars.outputs.owner }}/${{ env.IMAGE_NAME }}:${{ steps.vars.outputs.version }} |
| 54 | + ghcr.io/${{ steps.vars.outputs.owner }}/${{ env.IMAGE_NAME }}:${{ github.sha }} |
| 55 | + labels: | |
| 56 | + org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }} |
0 commit comments