Skip to content

Alpine Artifacts

Alpine Artifacts #9

Workflow file for this run

name: Alpine Artifacts
on:
schedule:
- cron: '0 0 1 * *'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
version: ['v3.21', 'v3.22', 'edge']
latest_version: ['v3.22']
steps:
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- name: Checkout code for alpine
uses: actions/checkout@v5
with:
repository: alpinelinux/docker-alpine
ref: ${{ matrix.version }}
- name: Get Version
id: get_version
run: |
if [ ! -f "loongarch64/Dockerfile" ]; then
mkdir -p loongarch64
cp riscv64/Dockerfile loongarch64/
sed -i 's@riscv64@loongarch64@g' loongarch64/Dockerfile
cd loongarch64
wget https://dl-cdn.alpinelinux.org/alpine/${{ matrix.version }}/releases/loongarch64/alpine-minirootfs-$(cat ../VERSION)-loongarch64.tar.gz
cd ..
fi
case ${{ matrix.version }} in
edge)
full_version=$(grep -oP '(?<=alpine-minirootfs-)[0-9]+' loongarch64/Dockerfile)
minor_version=${full_version%??}
major_version=edge
full_image_tag=alpine:edge
;;
*)
full_version=$(grep -oP '(?<=alpine-minirootfs-)[0-9]+\.[0-9]+\.[0-9]+' loongarch64/Dockerfile)
minor_version=$(echo $full_version | grep -oP '^[0-9]+\.[0-9]+')
major_version=$(echo $full_version | grep -oP '^[0-9]+')
full_image_tag=alpine:${full_version}
;;
esac
echo "full_version=$full_version" >> $GITHUB_OUTPUT
echo "minor_version=$minor_version" >> $GITHUB_OUTPUT
echo "major_version=$major_version" >> $GITHUB_OUTPUT
echo "full_image_tag=$full_image_tag" >> $GITHUB_OUTPUT
if [ -z "${full_version}" ] || [ "${full_version}" == "null" ]; then
echo "Version is different"
exit 1
fi
echo "Current Version: $full_version"
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push Images
uses: docker/build-push-action@v6
with:
context: ./loongarch64
platforms: linux/loong64
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/alpine:${{ steps.get_version.outputs.full_version }}-loong64
ghcr.io/${{ github.repository_owner }}/alpine:${{ steps.get_version.outputs.minor_version }}-loong64
outputs: type=image,oci-mediatypes=true,compression=zstd,compression-level=3,force-compression=true
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Prepare configuration
run: |
wget -qO- https://github.com/google/go-containerregistry/releases/latest/download/go-containerregistry_Linux_x86_64.tar.gz | sudo tar -xzf - -C /usr/local/bin/ crane
sudo chmod +x /usr/local/bin/crane
sudo chown root:root /usr/local/bin/crane
- name: Merge Images
run: |
crane index append -t ghcr.io/${{ github.repository_owner }}/${{ steps.get_version.outputs.full_image_tag }} -m ghcr.io/${{ github.repository_owner }}/alpine:${{ steps.get_version.outputs.full_version }}-loong64 -m alpine:${{ steps.get_version.outputs.full_version }}
crane cp ghcr.io/${{ github.repository_owner }}/${{ steps.get_version.outputs.full_image_tag }} ghcr.io/${{ github.repository_owner }}/alpine:${{ steps.get_version.outputs.full_version }}
crane cp ghcr.io/${{ github.repository_owner }}/${{ steps.get_version.outputs.full_image_tag }} ghcr.io/${{ github.repository_owner }}/alpine:${{ steps.get_version.outputs.minor_version }}
if [ "${{ matrix.version }}" = "${{ matrix.latest_version }}" ]; then
crane cp ghcr.io/${{ github.repository_owner }}/${{ steps.get_version.outputs.full_image_tag }} ghcr.io/${{ github.repository_owner }}/alpine:latest
crane cp ghcr.io/${{ github.repository_owner }}/${{ steps.get_version.outputs.full_image_tag }} ghcr.io/${{ github.repository_owner }}/alpine:${{ steps.get_version.outputs.major_version }}
fi