Docker Release #65
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Docker Release | |
| on: | |
| workflow_dispatch: | |
| release: | |
| types: [created, published] | |
| jobs: | |
| determine-tags: | |
| runs-on: ubuntu-24.04 | |
| outputs: | |
| tags: ${{ steps.meta.outputs.tags }} | |
| steps: | |
| - name: Determine Docker tags | |
| id: meta | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| if [[ -z "${{ github.event.release.tag_name }}" ]]; then | |
| echo "Manual run detected. Fetching latest release..." | |
| RELEASE_JSON=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \ | |
| https://api.github.com/repos/${{ github.repository }}/releases | jq 'sort_by(.created_at) | reverse | .[0]') | |
| TAG_NAME=$(echo "$RELEASE_JSON" | jq -r '.tag_name') | |
| COMMIT_REF=$(echo "$RELEASE_JSON" | jq -r '.target_commitish') | |
| IS_PRERELEASE=$(echo "$RELEASE_JSON" | jq -r '.prerelease') | |
| else | |
| TAG_NAME="${{ github.event.release.tag_name }}" | |
| COMMIT_REF="${{ github.event.release.target_commitish }}" | |
| IS_PRERELEASE="${{ github.event.release.prerelease }}" | |
| fi | |
| echo "Tag: $TAG_NAME" | |
| echo "Branch: $COMMIT_REF" | |
| echo "Is prerelease: $IS_PRERELEASE" | |
| TAGS="vitodeploy/vito:$TAG_NAME" | |
| if [[ "$COMMIT_REF" == 1.x* ]]; then | |
| TAGS="$TAGS,vitodeploy/vito:1.x" | |
| elif [[ "$COMMIT_REF" == 2.x* ]]; then | |
| TAGS="$TAGS,vitodeploy/vito:2.x" | |
| elif [[ "$COMMIT_REF" == 3.x* ]]; then | |
| TAGS="$TAGS,vitodeploy/vito:3.x" | |
| if [[ "$IS_PRERELEASE" == "false" ]]; then | |
| TAGS="$TAGS,vitodeploy/vito:latest" | |
| fi | |
| fi | |
| echo "tags=$TAGS" >> "$GITHUB_OUTPUT" | |
| build-amd64: | |
| runs-on: ubuntu-24.04 | |
| needs: determine-tags | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: docker/setup-buildx-action@v3 | |
| - uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Build and push amd64 images | |
| run: | | |
| IFS=',' read -ra TAG_ARRAY <<< "${{ needs.determine-tags.outputs.tags }}" | |
| TAGS="" | |
| for TAG in "${TAG_ARRAY[@]}"; do | |
| TAGS="$TAGS --tag ${TAG}" | |
| done | |
| docker buildx build . \ | |
| -f docker/Dockerfile \ | |
| --platform linux/amd64 \ | |
| --push \ | |
| $TAGS | |
| build-arm64: | |
| runs-on: ubuntu-24.04-arm | |
| needs: determine-tags | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: docker/setup-buildx-action@v3 | |
| - uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Build and push arm64 images | |
| run: | | |
| IFS=',' read -ra TAG_ARRAY <<< "${{ needs.determine-tags.outputs.tags }}" | |
| TAGS="" | |
| for TAG in "${TAG_ARRAY[@]}"; do | |
| TAGS="$TAGS --tag ${TAG}-arm64" | |
| done | |
| docker buildx build . \ | |
| -f docker/Dockerfile \ | |
| --platform linux/arm64 \ | |
| --push \ | |
| $TAGS | |