Skip to content

Commit

Permalink
i think fix vertag
Browse files Browse the repository at this point in the history
  • Loading branch information
ook37 committed Feb 22, 2024
1 parent 25dd54f commit dee8926
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 24 deletions.
20 changes: 15 additions & 5 deletions .github/workflows/publish-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ jobs:
run: |
vertag=${{ env.INPUT_VERTAG }}
if [[ -z ${vertag} ]]; then
vertag="$(date +%Y%m%d)"
vertag="master"
fi
platform=${{ matrix.platform }}
arch=${platform#*/}
distro=${{ matrix.OS }}
distro_tag="${distro/:/-}"
./pacstall-docker-builder -f -a ${arch} -d ${distro} -v ${vertag}
echo "BUILT_DOCKFILE=Dockerfile-Pacstall-${vertag}-${arch}-${distro_tag}" >> $GITHUB_ENV
echo "BUILT_DOCKFILE=Dockerfile-Pacstall-${vertag}-${arch}-${distro_tag}-$(date +%Y%m%d)" >> $GITHUB_ENV
echo "DOCK_LABEL=${vertag}" >> $GITHUB_ENV
echo "PLATFORM_PAIR=${distro_tag}-${arch}" >> $GITHUB_ENV
echo "REGISTRY_IMAGE=${{ env.REGISTRY }}/${{ github.repository_owner }}/${distro_tag}" >> $GITHUB_ENV
Expand Down Expand Up @@ -103,11 +103,20 @@ jobs:
run: |
vertag=${{ env.INPUT_VERTAG }}
if [[ -z ${vertag} ]]; then
vertag="$(date +%Y%m%d)"
vertag="master"
fi
distro=${{ matrix.OS }}
distro_tag="${distro/:/-}"
echo "DOCK_LABEL=${vertag}" >> $GITHUB_ENV
if [[ ${vertag} == "develop" ]]; then
echo "FLAVOR_LATEST='false'" >> $GITHUB_ENV
echo "DATE_DOCK_LABEL=${vertag}-$(date +%Y%m%d)" >> $GITHUB_ENV
elif [[ ${vertag} == "master" ]]; then
echo "FLAVOR_LATEST='true'" >> $GITHUB_ENV
echo "DATE_DOCK_LABEL=${vertag}-$(date +%Y%m%d)" >> $GITHUB_ENV
else
echo "FLAVOR_LATEST='true'" >> $GITHUB_ENV
fi
echo "DISTRO_TAG=${distro_tag}" >> $GITHUB_ENV
echo "REGISTRY_IMAGE=${{ env.REGISTRY }}/${{ github.repository_owner }}/${distro_tag}" >> $GITHUB_ENV
Expand All @@ -130,7 +139,8 @@ jobs:
images: ${{ env.REGISTRY_IMAGE }}
tags: |
type=raw,value=${{ env.DOCK_LABEL }}
flavor: latest=true
type=raw,value=${{ env.DATE_DOCK_LABEL }}
flavor: latest=${{ env.FLAVOR_LATEST }}

- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3
Expand All @@ -143,7 +153,7 @@ jobs:
working-directory: /tmp/digests
run: |
docker buildx imagetools create \
--annotation "index:org.opencontainers.image.description=Contains amd64/x86_64 + arm64/aarch64 Pacstall ${{ env.DOCK_LABEL }} images for ${{ matrix.OS }}." \
--annotation "index:org.opencontainers.image.description=Contains amd64/x86_64 + arm64/aarch64 Pacstall ${{ env.DOCK_LABEL }} images for ${{ matrix.OS }}, from $(date +%Y%m%d)." \
$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
Expand Down
10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ Usage: pacstall-docker-builder [OPTIONS]
Options:
-V/-v, --version Image version tag
(default: current date in YYYYMMDD format)
-V/-v, --version Pacstall version and Docker image tag
(default: master)
-A/-a, --arch Target architecture
(options: auto, all/off, arm64/aarch64, amd64/x86_64)
Expand Down Expand Up @@ -44,7 +44,7 @@ Examples:
pacstall-docker-builder -f
Creates the file Dockerfile-Pacstall-YYYYMMDD for building the image
Creates the file Dockerfile-Pacstall-master-YYYYMMDD for building the image
pacstall/pacstall:YYYYMMDD, with instructions outputted to terminal
on how to build and run it.
Expand All @@ -56,10 +56,6 @@ Examples:
Builds and starts amd64/pacstall/pacstall:4.3.2 from scratch.
Note: the version tag may not correlate with the actual version
of Pacstall when building. This option is meant for easily publishing
images for specific milestones.
pacstall-docker-builder -p -t -v latest
Expand Down
21 changes: 9 additions & 12 deletions pacstall-docker-builder
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ ${BYellow}Usage:${NC} ${0##*/} ${PURPLE}[OPTIONS]${NC}
${BYellow}Options:${NC}
${BGreen}-V/-v, --version${NC} Image version tag
(default: ${CYAN}current date in YYYYMMDD format${NC})
${BGreen}-V/-v, --version${NC} Pacstall version and Docker image tag
(default: ${CYAN}master${NC})
${BGreen}-A/-a, --arch${NC} Target architecture
(options: ${CYAN}auto${NC}, ${CYAN}all${NC}/${CYAN}off${NC}, ${CYAN}arm64${NC}/${CYAN}aarch64${NC}, ${CYAN}amd64${NC}/${CYAN}x86_64${NC})
Expand Down Expand Up @@ -73,8 +73,8 @@ ${BYellow}Examples:${NC}
${BPurple}${0##*/} -f${NC}
Creates the file ${BGreen}Dockerfile-Pacstall-${dateiniso}${NC} for building the image
${BGreen}pacstall/pacstall:${dateiniso}${NC}, with instructions outputted to terminal
Creates the file ${BGreen}Dockerfile-Pacstall-master-${dateiniso}${NC} for building the image
${BGreen}pacstall/pacstall:master${NC}, with instructions outputted to terminal
on how to build and run it.
${BYellow}Note:${NC} if no options are passed, this is the default function, but
Expand All @@ -85,10 +85,6 @@ ${BYellow}Examples:${NC}
Builds and starts ${BGreen}amd64/pacstall/pacstall:4.3.2${NC} from scratch.
${BYellow}Note:${NC} the version tag may not correlate with the actual version
of Pacstall when building. This option is meant for easily publishing
images for specific milestones.
${BPurple}${0##*/} -p -t -v latest${NC}
Expand Down Expand Up @@ -296,7 +292,7 @@ else
fi

if [[ -z ${imgver} ]]; then
imgver="${dateiniso}"
imgver="master"
fi

if [[ -z ${input_distro} ]]; then
Expand All @@ -311,7 +307,7 @@ fi
function cat_built_dock {
cat > ${built_dock} << EOF
FROM ${base_darch}${base_distro}
LABEL org.opencontainers.image.description "Contains Pacstall ${imgver}"
LABEL org.opencontainers.image.description "Contains pacstall:${imgver} from ${dateiniso}"
SHELL ["/bin/bash", "-l", "-c"]
ARG DEBIAN_FRONTEND=noninteractive
Expand All @@ -332,6 +328,7 @@ RUN adduser --disabled-password --gecos '' pacstall && adduser pacstall sudo
RUN echo N | sudo bash -c "\$(curl -fsSL https://pacstall.dev/q/install\?dnt || wget -q https://pacstall.dev/q/install\?dnt -O -)" && rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
RUN chown -R pacstall:pacstall /var/log/pacstall && chown -R pacstall:pacstall /tmp/pacstall
RUN runuser -l pacstall -c "HOME=/home/pacstall SUDO_USER=pacstall pacstall -U pacstall:${imgver}"
# https://askubuntu.com/a/1026978
RUN rm /etc/apt/apt.conf.d/docker-clean
Expand All @@ -357,9 +354,9 @@ fi

if ((pull_upstream == 0)); then
if [[ -z ${input_distro} ]]; then
built_dock="${dock_dir}/Dockerfile-Pacstall-${imgver}${darcher}"
built_dock="${dock_dir}/Dockerfile-Pacstall-${imgver}${darcher}-${dateiniso}"
else
built_dock="${dock_dir}/Dockerfile-Pacstall-${imgver}${darcher}-${base_distro/:/-}"
built_dock="${dock_dir}/Dockerfile-Pacstall-${imgver}${darcher}-${base_distro/:/-}-${dateiniso}"
fi
if [[ -f ${built_dock} ]]; then
rm -f ${built_dock}
Expand Down

0 comments on commit dee8926

Please sign in to comment.