Some checks failed
Build and Push Docker Image / check-version (push) Has been cancelled
Build and Push Docker Image / build (amd64, linux/amd64, linux-amd64) (push) Has been cancelled
Build and Push Docker Image / build (arm64, linux/arm64, linux-arm64) (push) Has been cancelled
Build and Push Docker Image / merge (push) Has been cancelled
Simplified runner configuration to use host execution instead of Docker-in-Docker for better performance. Configure runners with: - Raspberry Pi: linux-arm64:host - Laptop: linux-amd64:host 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
134 lines
4.6 KiB
YAML
134 lines
4.6 KiB
YAML
name: Build and Push Docker Image
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
workflow_dispatch:
|
|
schedule:
|
|
- cron: '0 * * * *' # Every hour
|
|
|
|
jobs:
|
|
check-version:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
should_build: ${{ steps.compare.outputs.should_build }}
|
|
latest_version: ${{ steps.get_version.outputs.version }}
|
|
steps:
|
|
- name: Get latest Nicotine+ version from PyPI
|
|
id: get_version
|
|
run: |
|
|
VERSION=$(curl -s https://pypi.org/pypi/nicotine-plus/json | jq -r '.info.version')
|
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
echo "Latest Nicotine+ version: $VERSION"
|
|
|
|
- name: Get current built version
|
|
id: current_version
|
|
run: |
|
|
CURRENT=$(curl -s https://git.nicola.sh/api/v1/repos/public/nicotine-less/releases/latest 2>/dev/null | jq -r '.tag_name // "none"')
|
|
echo "current=$CURRENT" >> $GITHUB_OUTPUT
|
|
echo "Current built version: $CURRENT"
|
|
|
|
- name: Compare versions
|
|
id: compare
|
|
run: |
|
|
if [ "${{ steps.get_version.outputs.version }}" != "${{ steps.current_version.outputs.current }}" ]; then
|
|
echo "should_build=true" >> $GITHUB_OUTPUT
|
|
echo "New version detected, will build"
|
|
else
|
|
echo "should_build=false" >> $GITHUB_OUTPUT
|
|
echo "Already up to date"
|
|
fi
|
|
|
|
build:
|
|
needs: check-version
|
|
if: needs.check-version.outputs.should_build == 'true' || github.event_name == 'push' || github.event_name == 'workflow_dispatch'
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- platform: linux/amd64
|
|
runner: linux-amd64
|
|
arch: amd64
|
|
- platform: linux/arm64
|
|
runner: linux-arm64
|
|
arch: arm64
|
|
runs-on: ${{ matrix.runner }}
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to Gitea Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: git.nicola.sh
|
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
|
|
|
- name: Build and push by digest
|
|
id: build
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
platforms: ${{ matrix.platform }}
|
|
outputs: type=image,name=git.nicola.sh/public/nicotine-less,push-by-digest=true,name-canonical=true,push=true
|
|
cache-from: type=registry,ref=git.nicola.sh/public/nicotine-less:buildcache-${{ matrix.platform }}
|
|
cache-to: type=registry,ref=git.nicola.sh/public/nicotine-less:buildcache-${{ matrix.platform }},mode=max
|
|
|
|
- name: Export digest
|
|
run: |
|
|
mkdir -p /tmp/digests
|
|
digest="${{ steps.build.outputs.digest }}"
|
|
touch "/tmp/digests/${digest#sha256:}"
|
|
|
|
- name: Upload digest
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: digests-${{ matrix.platform }}
|
|
path: /tmp/digests/*
|
|
if-no-files-found: error
|
|
retention-days: 1
|
|
|
|
merge:
|
|
needs: build
|
|
runs-on: linux-amd64
|
|
steps:
|
|
- name: Download digests
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
path: /tmp/digests
|
|
pattern: digests-*
|
|
merge-multiple: true
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to Gitea Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: git.nicola.sh
|
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
|
|
|
- name: Create manifest list and push
|
|
working-directory: /tmp/digests
|
|
run: |
|
|
docker buildx imagetools create \
|
|
-t git.nicola.sh/public/nicotine-less:latest \
|
|
-t git.nicola.sh/public/nicotine-less:${{ needs.check-version.outputs.latest_version }} \
|
|
$(printf 'git.nicola.sh/public/nicotine-less@sha256:%s ' *)
|
|
|
|
- name: Create release
|
|
if: needs.check-version.outputs.should_build == 'true'
|
|
run: |
|
|
curl -X POST "https://git.nicola.sh/api/v1/repos/public/nicotine-less/releases" \
|
|
-H "Authorization: token ${{ secrets.TOKEN }}" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{
|
|
\"tag_name\": \"${{ needs.check-version.outputs.latest_version }}\",
|
|
\"name\": \"Nicotine+ ${{ needs.check-version.outputs.latest_version }}\",
|
|
\"body\": \"Automated build with Nicotine+ version ${{ needs.check-version.outputs.latest_version }}\"
|
|
}"
|