Skip to content

fix default debug (#506) #872

fix default debug (#506)

fix default debug (#506) #872

Workflow file for this run

name: Build and Release rapida
on:
push:
branches:
- "main"
pull_request:
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
REGISTRY_IMAGE: ${{ github.repository }}
# --- REQUIRED FOR GHCR AUTHENTICATION ---
permissions:
contents: write
packages: write
jobs:
test:
name: Test
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: docker/build-push-action@v5
with:
context: .
target: prod
load: true
tags: rapida:test
# --- TURN ON GITHUB ACTIONS CACHING ---
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Run tests
run: |
docker run --rm --entrypoint /bin/bash \
-u root \
-e SETUPTOOLS_SCM_PRETEND_VERSION="0.0.0.dev0" \
-v ${{ github.workspace }}:/ci-workspace -w /ci-workspace \
rapida:test \
-c "uv pip install .[dev] && pytest tests"
create-tag:
name: Auto-Increment Version
# ONLY run this when code is merged/pushed directly to main
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
#needs: [test]
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
version: ${{ steps.tagger.outputs.new_tag }}
steps:
- uses: actions/checkout@v4
- name: Bump version and push tag
id: tagger
uses: mathieudutour/github-tag-action@v6.2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
default_bump: patch
build-multi-arch:
name: Build & Push
needs: [create-tag]
environment: azure container registry
runs-on: ${{ matrix.runner }}
strategy:
matrix:
platform: [linux/amd64, linux/arm64]
include:
- platform: linux/amd64
runner: ubuntu-latest
- platform: linux/arm64
runner: ubuntu-22.04-arm
steps:
- uses: actions/checkout@v4
- name: Prepare Variables
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
echo "IMAGE_NAME=$(echo '${{ env.REGISTRY_IMAGE }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/login-action@v3
with:
registry: ${{ secrets.ACR_ENDPOINT }}
username: ${{ secrets.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ env.IMAGE_NAME }}
${{ secrets.ACR_ENDPOINT }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=${{ needs.create-tag.outputs.version }}
type=raw,value=latest
- name: Build and push by digest
id: build
uses: docker/build-push-action@v5
with:
context: .
target: prod
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,"name=ghcr.io/${{ env.IMAGE_NAME }},${{ secrets.ACR_ENDPOINT }}/${{ env.IMAGE_NAME }}",push-by-digest=true,name-canonical=true,push=true
build-args: |
RAPIDA_VERSION=${{ needs.create-tag.outputs.version }}
- name: Export digest
run: |
mkdir -p ${{ runner.temp }}/digests
digest="${{ steps.build.outputs.digest }}"
touch "${{ runner.temp }}/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ env.PLATFORM_PAIR }}
path: ${{ runner.temp }}/digests/*
retention-days: 1
deploy-manifests:
name: Merge Manifests
needs: [create-tag, build-multi-arch]
environment: azure container registry
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
path: ${{ runner.temp }}/digests
pattern: digests-*
merge-multiple: true
- uses: docker/setup-buildx-action@v3
- name: Prepare Variables
run: |
echo "IMAGE_NAME=$(echo '${{ env.REGISTRY_IMAGE }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/login-action@v3
with:
registry: ${{ secrets.ACR_ENDPOINT }}
username: ${{ secrets.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ env.IMAGE_NAME }}
${{ secrets.ACR_ENDPOINT }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=${{ needs.create-tag.outputs.version }}
type=raw,value=latest
- name: Create manifest lists
working-directory: ${{ runner.temp }}/digests
run: |
# 1. Filter the metadata JSON to separate the tags by registry
GHCR_TAGS=$(jq -cr '.tags | map(select(test("ghcr.io"))) | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON")
ACR_TAGS=$(jq -cr '.tags | map(select(test("${{ secrets.ACR_ENDPOINT }}"))) | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON")
# 2. Build and push the GHCR manifest
echo "Creating manifest for GHCR..."
docker buildx imagetools create $GHCR_TAGS \
$(printf "ghcr.io/${{ env.IMAGE_NAME }}@sha256:%s " *)
# 3. Build and push the ACR manifest
echo "Creating manifest for ACR..."
docker buildx imagetools create $ACR_TAGS \
$(printf "${{ secrets.ACR_ENDPOINT }}/${{ env.IMAGE_NAME }}@sha256:%s " *)
create-release:
name: Create GitHub Release
# Wait for the Docker images to be fully published first!
needs: [ create-tag, deploy-manifests ]
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Generate Release Notes
uses: softprops/action-gh-release@v2
with:
# Use the exact version tag created earlier in the pipeline
tag_name: ${{ needs.create-tag.outputs.version }}
# This tells GitHub to auto-generate the markdown changelog
generate_release_notes: true