|
| 1 | +name: Release Docker Image |
| 2 | + |
| 3 | +concurrency: |
| 4 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 5 | + cancel-in-progress: true |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: read |
| 9 | + |
| 10 | +on: |
| 11 | + push: |
| 12 | + tags: |
| 13 | + - '\d+\.\d+\.\d+' |
| 14 | + |
| 15 | +jobs: |
| 16 | + build-and-push: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + permissions: |
| 19 | + contents: read |
| 20 | + packages: write |
| 21 | + steps: |
| 22 | + - name: Checkout |
| 23 | + uses: actions/checkout@v4 |
| 24 | + |
| 25 | + - name: Extract Docker image metadata |
| 26 | + id: meta |
| 27 | + uses: docker/metadata-action@v5 |
| 28 | + with: |
| 29 | + images: | |
| 30 | + ${{ vars.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }} |
| 31 | + ghcr.io/${{ vars.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }} |
| 32 | + tags: | |
| 33 | + type=ref,event=branch |
| 34 | + type=ref,event=pr |
| 35 | + type=semver,pattern={{version}} |
| 36 | + type=semver,pattern={{major}}.{{minor}} |
| 37 | +
|
| 38 | + - name: Set frontend and backend versions |
| 39 | + run: | |
| 40 | + VERSION=${{ steps.meta.outputs.version }} |
| 41 | + sed -i "s/^version = \".*-git\"/version = \"${VERSION}\"/" ./backend/Cargo.toml |
| 42 | + jq ".version = \"${VERSION}\"" ./frontend/package.json > ./frontend/package.tmp.json |
| 43 | + mv ./frontend/package.tmp.json ./frontend/package.json |
| 44 | +
|
| 45 | + - name: Log in to Docker Hub |
| 46 | + if: github.event_name != 'pull_request' |
| 47 | + uses: docker/login-action@v3 |
| 48 | + with: |
| 49 | + username: ${{ vars.DOCKERHUB_USERNAME }} |
| 50 | + password: ${{ secrets.DOCKERHUB_PASSWORD }} |
| 51 | + |
| 52 | + - name: Login to GitHub Container Registry |
| 53 | + if: github.event_name != 'pull_request' |
| 54 | + uses: docker/login-action@v3 |
| 55 | + with: |
| 56 | + registry: ghcr.io |
| 57 | + username: ${{ github.repository_owner }} |
| 58 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 59 | + |
| 60 | + - name: Set up QEMU |
| 61 | + uses: docker/setup-qemu-action@v3 |
| 62 | + |
| 63 | + - name: Set up Docker Buildx |
| 64 | + uses: docker/setup-buildx-action@v3 |
| 65 | + |
| 66 | + - name: Build and push Docker image |
| 67 | + uses: docker/build-push-action@v6 |
| 68 | + with: |
| 69 | + platforms: linux/amd64,linux/arm64 |
| 70 | + context: . |
| 71 | + push: ${{ github.event_name != 'pull_request' }} |
| 72 | + tags: ${{ steps.meta.outputs.tags }} |
| 73 | + labels: ${{ steps.meta.outputs.labels }} |
| 74 | + annotations: ${{ steps.meta.outputs.annotations }} |
| 75 | + provenance: true |
| 76 | + sbom: true |
0 commit comments