From dee892611652dbfae42ecddd932f909acf43a883 Mon Sep 17 00:00:00 2001 From: ook37 Date: Wed, 21 Feb 2024 19:27:59 -0500 Subject: [PATCH] i think fix vertag --- .github/workflows/publish-docker.yml | 20 +++++++++++++++----- README.md | 10 +++------- pacstall-docker-builder | 21 +++++++++------------ 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml index 19d9dd5..f9a2814 100644 --- a/.github/workflows/publish-docker.yml +++ b/.github/workflows/publish-docker.yml @@ -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 @@ -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 @@ -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 @@ -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 ' *) diff --git a/README.md b/README.md index 38534eb..1113eac 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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. @@ -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 diff --git a/pacstall-docker-builder b/pacstall-docker-builder index 8156146..dd60929 100755 --- a/pacstall-docker-builder +++ b/pacstall-docker-builder @@ -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}) @@ -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 @@ -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} @@ -296,7 +292,7 @@ else fi if [[ -z ${imgver} ]]; then - imgver="${dateiniso}" + imgver="master" fi if [[ -z ${input_distro} ]]; then @@ -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 @@ -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 @@ -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}