Skip to content

build(deps): bump requests from 2.32.4 to 2.33.0 (#77) #97

build(deps): bump requests from 2.32.4 to 2.33.0 (#77)

build(deps): bump requests from 2.32.4 to 2.33.0 (#77) #97

Workflow file for this run

name: Build
on:
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
env:
IMAGE_NAME: aoirint/sd_scripts
GHCR_IMAGE_NAME: ghcr.io/aoirint/sd_scripts
jobs:
version:
runs-on: ubuntu-slim
permissions:
contents: read
outputs:
release_mode: ${{ steps.version.outputs.release_mode }}
tag: ${{ steps.version.outputs.tag }}
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Read release version
id: version
run: |-
version="$(tr -d '[:space:]' < VERSION)"
if [[ ! "${version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then
echo "VERSION must be stable SemVer like 0.1.0 or prerelease SemVer like 0.1.0-rc.1" >&2
exit 1
fi
tag="v${version}"
tag_exists=false
if git ls-remote --exit-code --tags origin "refs/tags/${tag}" > /dev/null 2>&1; then
tag_exists=true
fi
if [[ "${tag_exists}" == "true" ]]; then
release_mode=edge
elif [[ "${version}" == "0.0.0" ]]; then
release_mode=edge
elif [[ "${version}" == *-* ]]; then
release_mode=prerelease
else
release_mode=latest
fi
{
echo "tag_exists=${tag_exists}"
echo "version=${version}"
echo "tag=${tag}"
echo "release_mode=${release_mode}"
} >> "$GITHUB_OUTPUT"
release:
needs:
- version
if: ${{ needs.version.outputs.release_mode != 'edge' }}
runs-on: ubuntu-slim
permissions:
contents: write
steps:
- name: Publish release
# Create immutable releases so an already-published version cannot be
# silently replaced by a later workflow run for the same tag.
uses: ncipollo/release-action@339a81892b84b4eeb0f6e744e4574d79d0d9b8dd # v1.21.0
with:
tag: ${{ needs.version.outputs.tag }}
commit: ${{ github.sha }}
immutableCreate: true
prerelease: ${{ needs.version.outputs.release_mode == 'prerelease' }}
makeLatest: ${{ needs.version.outputs.release_mode == 'latest' }}
generateReleaseNotes: true
build-docker:
needs:
- version
- release
# Keep the original release flow: create the GitHub release first, then
# publish Docker tags for that commit. Edge builds intentionally skip the
# release job, so the Docker publish path must accept either success or
# skipped here.
if: ${{ always() && needs.version.result == 'success' && (needs.release.result == 'success' || needs.release.result == 'skipped') }}
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Free disk space
run: |-
# https://github.com/actions/runner-images/issues/2840#issuecomment-2272410832
sudo rm -rf \
"$AGENT_TOOLSDIRECTORY" \
/opt/google/chrome \
/opt/microsoft/msedge \
/opt/microsoft/powershell \
/opt/pipx \
/usr/lib/mono \
/usr/local/julia* \
/usr/local/lib/android \
/usr/local/lib/node_modules \
/usr/local/share/chromium \
/usr/local/share/powershell \
/usr/share/dotnet \
/usr/share/swift
df -h /
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup Docker Buildx
id: buildx
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
- name: Docker metadata
id: meta
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
with:
images: |
${{ env.IMAGE_NAME }}
${{ env.GHCR_IMAGE_NAME }}
flavor: |
latest=false
tags: |
type=raw,value=edge,enable=${{ needs.version.outputs.release_mode != 'latest' }}
type=raw,value=${{ needs.version.outputs.tag }},enable=${{ needs.version.outputs.release_mode == 'latest' }}
type=raw,value=latest,enable=${{ needs.version.outputs.release_mode == 'latest' }}
- name: Derive build cache refs
id: cache
run: |-
if [[ "${{ needs.version.outputs.release_mode }}" == "latest" ]]; then
{
echo "cache_from<<EOF"
echo "type=registry,ref=${{ env.GHCR_IMAGE_NAME }}:edge-buildcache"
echo "type=registry,ref=${{ env.GHCR_IMAGE_NAME }}:buildcache"
echo "EOF"
echo "cache_to=type=registry,ref=${{ env.GHCR_IMAGE_NAME }}:buildcache,mode=max"
} >> "$GITHUB_OUTPUT"
else
{
echo "cache_from=type=registry,ref=${{ env.GHCR_IMAGE_NAME }}:edge-buildcache"
echo "cache_to=type=registry,ref=${{ env.GHCR_IMAGE_NAME }}:edge-buildcache,mode=max"
} >> "$GITHUB_OUTPUT"
fi
- name: Login to ghcr.io
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Docker Hub
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and Deploy Docker image
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
with:
builder: ${{ steps.buildx.outputs.name }}
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: ${{ steps.cache.outputs.cache_from }}
cache-to: ${{ steps.cache.outputs.cache_to }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}
test-docker:
needs:
- version
- build-docker
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
steps:
- name: Free disk space
run: |-
# https://github.com/actions/runner-images/issues/2840#issuecomment-2272410832
sudo rm -rf \
"$AGENT_TOOLSDIRECTORY" \
/opt/google/chrome \
/opt/microsoft/msedge \
/opt/microsoft/powershell \
/opt/pipx \
/usr/lib/mono \
/usr/local/julia* \
/usr/local/lib/android \
/usr/local/lib/node_modules \
/usr/local/share/chromium \
/usr/local/share/powershell \
/usr/share/dotnet \
/usr/share/swift
df -h /
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Login to ghcr.io
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull built Docker image
id: image
run: |-
# Test the image tag that build-docker just pushed, not a second local
# build. Latest releases are immutable version tags; edge builds reuse
# the moving edge tag because VERSION either already exists or is 0.0.0.
if [[ "${{ needs.version.outputs.release_mode }}" == "latest" ]]; then
image="${{ env.GHCR_IMAGE_NAME }}:${{ needs.version.outputs.tag }}"
else
image="${{ env.GHCR_IMAGE_NAME }}:edge"
fi
docker pull "${image}"
echo "image=${image}" >> "$GITHUB_OUTPUT"
- name: Run upstream sd-scripts pytest release tests
run: |-
scripts/run-sd-scripts-release-tests.sh --image "${{ steps.image.outputs.image }}"