Skip to content

Commit

Permalink
Update Docker workflow to enhance build and release process
Browse files Browse the repository at this point in the history
  • Loading branch information
arrowplum committed Nov 26, 2024
1 parent 11d72b0 commit cb5cc01
Showing 1 changed file with 53 additions and 14 deletions.
67 changes: 53 additions & 14 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ jobs:
DOCKER_BUILDKIT: '1'

- name: Build and Push Docker Image
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
if: github.event_name == 'workflow_dispatch' || github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))
run: |
jf docker buildx bake \
--set asvec.tags=${{ env.REPO }}/asvec:${{ env.VERSION }} \
Expand All @@ -118,14 +118,12 @@ jobs:
DOCKER_BUILDKIT: '1'

- name: Build and Push Docker Image with 'latest' Tag (Release)
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
if: github.event_name == 'workflow_dispatch' && github.event.inputs.is_release || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
run: |
jf docker buildx bake \
--set asvec.tags=${{ env.REPO }}/asvec:${{ env.VERSION }} \
--set asvec.tags=${{ env.REPO }}/asvec:latest \
--file docker/asvec.docker/bake.hcl \
--push \
--metadata-file=build-metadata
--push
env:
DOCKER_BUILDKIT: '1'

Expand All @@ -135,48 +133,89 @@ jobs:
- name: Extract Image Name and Digest
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')))
run: |
jq -r '.[] | {digest: .["containerimage.digest"], names: .["image.name"] | split(",")} | "\(.names[0])@\(.digest)"' build-metadata > meta-info
jq -r '.[] | {digest: .["containerimage.digest"], names: .["image.name"] | split(",")} | "(.digest)"' build-metadata > sha
echo ${{ env.REPO }}/asvec:${{ env.VERSION }}@$(cat sha) > meta-info
echo ${{ env.REPO }}/asvec:${{ env.VERSION }}@$(cat sha) > meta-info-latest
- name: Create Docker Build Info
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')))
run: |
jf rt build-docker-create \
--build-name "${{ env.JFROG_CLI_BUILD_NAME }}" \
--build-name "${{ env.JFROG_CLI_BUILD_NAME }}-container" \
--build-number "${{ env.VERSION }}" \
--image-file ./meta-info \
--project ecosystem \
ecosystem-container-dev-local
- name: Publish Build Info
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')))
run: |
jf rt build-publish \
--detailed-summary \
--project ecosystem \
"${{ env.JFROG_CLI_BUILD_NAME }}" "${{ env.VERSION }}"
- name: Create Release Bundle
"${{ env.JFROG_CLI_BUILD_NAME }}-container" "${{ env.VERSION }}"
- name: Create Docker Build Info
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')))
run: |
jf rt build-docker-create \
--build-name "${{ env.JFROG_CLI_BUILD_NAME }}-container" \
--build-number "${{ env.VERSION }}" \
--image-file ./meta-info \
--project ecosystem \
ecosystem-container-dev-local
- name: Publish Build Info
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')))
run: |
jf rt build-publish \
--detailed-summary \
--project ecosystem \
"${{ env.JFROG_CLI_BUILD_NAME }}-container" "${{ env.VERSION }}"
- name: Create Docker Build Info and update Latest
if: github.event_name == 'workflow_dispatch' && github.event.inputs.is_release || (github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/')))
run: |
jf rt build-docker-create \
--build-name "${{ env.JFROG_CLI_BUILD_NAME }}-container-latest" \
--build-number "${{ env.VERSION }}" \
--image-file ./meta-info \
--project ecosystem \
ecosystem-container-dev-local
- name: Publish Build Info and update latest
if: github.event_name == 'workflow_dispatch' && github.event.inputs.is_release|| (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
run: |
jf rt build-publish \
--detailed-summary \
--project ecosystem \
"${{ env.JFROG_CLI_BUILD_NAME }}-container-latest" "${{ env.VERSION }}"
- name: Create Release Bundle
if: github.event_name == 'workflow_dispatch' && github.event.inputs.is_release|| (github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/')))
run: |
echo '{
"name": "${{ env.JFROG_CLI_BUILD_NAME }}," \
"name": "${{ env.JFROG_CLI_BUILD_NAME }}",\
"version": "${{ env.VERSION }}",\
"description": "Release bundle for ${GITHUB_REPOSITORY} version ${GITHUB_SHA}",\
"release_notes": "$sanitized_release_notes",
"files": [
{
"project": "ecosystem",
"build": "${{ env.JFROG_CLI_BUILD_NAME }}"
"build": "${{ env.JFROG_CLI_BUILD_NAME }}-container"
},
{
"project": "ecosystem",
"pattern": "ecosystem-container-dev-local/asvec/latest/*"
}
"build": "${{ env.JFROG_CLI_BUILD_NAME }}-container-latest"
},
]
}' > release-bundle-spec.json
cat release-bundle-spec.json
jf rt release-bundle-create \
jf release-bundle-create \
"${{ env.JFROG_CLI_BUILD_NAME }}" "${{ env.VERSION }}",\
--project ecosystem \
--spec release-bundle-spec.json

0 comments on commit cb5cc01

Please sign in to comment.