Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 20 additions & 55 deletions .github/workflows/pb-create-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,48 +16,30 @@ jobs:
password: ${{ secrets.INITIALIZ_BUILDPACKS_DOCKERHUB_PASSWORD }}
registry: docker.io
username: ${{ secrets.INITIALIZ_BUILDPACKS_DOCKERHUB_USERNAME }}
- uses: actions/setup-go@v5
- uses: actions/setup-go@v6
with:
go-version: "1.22"
go-version: "1.26"
- name: Install create-package
run: |
#!/usr/bin/env bash

set -euo pipefail

go install -ldflags="-s -w" github.com/paketo-buildpacks/libpak/cmd/create-package@latest
- uses: buildpacks/github-actions/setup-tools@v5.6.0
- uses: buildpacks/github-actions/setup-tools@v5.12.0
with:
crane-version: 0.19.1
crane-version: 0.20.3
yj-version: 5.1.0
- name: Install pack
run: |
#!/usr/bin/env bash
# this is coming from a copy of https://github.com/buildpacks/pack/actions/runs/8118576298 stored on box
# TODO to revisit when the official one is out
set -euo pipefail

echo "Installing pack experimental"

mkdir -p "${HOME}"/bin
echo "${HOME}/bin" >> "${GITHUB_PATH}"

curl -L "https://github.com/buildpacks/pack/releases/download/v0.36.0/pack-v0.36.0-linux.tgz" | tar xvz -C "${HOME}/bin"
chmod +x "${HOME}"/bin/pack
- uses: buildpacks/github-actions/setup-pack@v5.12.0
with:
pack-version: 0.40.2
- name: Enable pack Experimental
if: ${{ false }}
run: |
#!/usr/bin/env bash

set -euo pipefail

echo "Enabling pack experimental features"

mkdir -p "${HOME}"/.pack
echo "experimental = true" >> "${HOME}"/.pack/config.toml
- uses: actions/checkout@v4
pack config experimental true
- uses: actions/checkout@v6
- if: ${{ false }}
uses: actions/cache@v4
uses: actions/cache@v5
with:
key: ${{ runner.os }}-go-${{ hashFiles('**/buildpack.toml', '**/package.toml') }}
path: |-
Expand All @@ -68,28 +50,22 @@ jobs:
id: version
run: |
#!/usr/bin/env bash

set -euo pipefail

if [[ ${GITHUB_REF:-} != "refs/"* ]]; then
echo "GITHUB_REF set to [${GITHUB_REF:-}], but that is unexpected. It should start with 'refs/*'"
exit 255
fi

if [[ ${GITHUB_REF} =~ refs/tags/v([0-9]+\.[0-9]+\.[0-9]+) ]]; then
VERSION=${BASH_REMATCH[1]}

MAJOR_VERSION="$(echo "${VERSION}" | awk -F '.' '{print $1 }')"
MINOR_VERSION="$(echo "${VERSION}" | awk -F '.' '{print $1 "." $2 }')"

echo "version-major=${MAJOR_VERSION}" >> "$GITHUB_OUTPUT"
echo "version-minor=${MINOR_VERSION}" >> "$GITHUB_OUTPUT"
elif [[ ${GITHUB_REF} =~ refs/heads/(.+) ]]; then
VERSION=${BASH_REMATCH[1]}
else
VERSION=$(git rev-parse --short HEAD)
fi

echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
echo "Selected ${VERSION} from
* ref: ${GITHUB_REF}
Expand All @@ -98,16 +74,13 @@ jobs:
- name: Create Package
run: |
#!/usr/bin/env bash

set -euo pipefail

# With Go 1.20, we need to set this so that we produce statically compiled binaries
#
# Starting with Go 1.20, Go will produce binaries that are dynamically linked against libc
# which can cause compatibility issues. The compiler links against libc on the build system
# but that may be newer than on the stacks we support.
export CGO_ENABLED=0

if [[ "${INCLUDE_DEPENDENCIES}" == "true" ]]; then
create-package \
--source "${SOURCE_PATH:-.}" \
Expand All @@ -121,7 +94,6 @@ jobs:
--destination "${HOME}"/buildpack \
--version "${VERSION}"
fi

PACKAGE_FILE="${SOURCE_PATH:-.}/package.toml"
if [ -f "${PACKAGE_FILE}" ]; then
cp "${PACKAGE_FILE}" "${HOME}/buildpack/package.toml"
Expand All @@ -136,35 +108,28 @@ jobs:
id: package
run: |-
#!/usr/bin/env bash

set -euo pipefail

COMPILED_BUILDPACK="${HOME}/buildpack"

# create-package puts the buildpack here, we need to run from that directory
# for component buildpacks so that pack doesn't need a package.toml
cd "${COMPILED_BUILDPACK}"
CONFIG=""
if [ -f "${COMPILED_BUILDPACK}/package.toml" ]; then
CONFIG="--config ${COMPILED_BUILDPACK}/package.toml"
CONFIG="--config ${COMPILED_BUILDPACK}/package.toml --flatten"
fi

PACKAGE_LIST=($PACKAGES)
# Extract first repo (Docker Hub) as the main to package & register
PACKAGE=${PACKAGE_LIST[0]}

if [[ "${PUBLISH:-x}" == "true" ]]; then
pack -v buildpack package \
"${PACKAGE}:${VERSION}" ${CONFIG} \
--publish

if [[ -n ${VERSION_MINOR:-} && -n ${VERSION_MAJOR:-} ]]; then
crane tag "${PACKAGE}:${VERSION}" "${VERSION_MINOR}"
crane tag "${PACKAGE}:${VERSION}" "${VERSION_MAJOR}"
fi
crane tag "${PACKAGE}:${VERSION}" latest
echo "digest=$(crane digest "${PACKAGE}:${VERSION}")" >> "$GITHUB_OUTPUT"

# copy to other repositories specified
for P in "${PACKAGE_LIST[@]}"
do
Expand All @@ -177,11 +142,15 @@ jobs:
crane tag "${P}:${VERSION}" latest
fi
done

else
pack -v buildpack package \
"${PACKAGE}:${VERSION}" ${CONFIG} \
--format "${FORMAT}" $([ -n "$TTL_SH_PUBLISH" ] && [ "$TTL_SH_PUBLISH" = "true" ] && echo "--publish")
if [ -n "$TTL_SH_PUBLISH" ] && [ "$TTL_SH_PUBLISH" = "true" ]; then
TAG="${PACKAGE}-$(mktemp -u XXXXX | awk '{print tolower($0)}'):${VERSION}"
pack -v buildpack package "${TAG}" ${CONFIG} --format "${FORMAT}" --publish
else
TAG="${PACKAGE}:${VERSION}"
pack -v buildpack package "${TAG}" ${CONFIG} --format "${FORMAT}"
fi
echo "ttl-image-tag=${TAG:-}" >> "$GITHUB_OUTPUT"
fi
env:
PACKAGES: docker.io/initializbuildpacks/ca-certificates
Expand All @@ -192,16 +161,12 @@ jobs:
- name: Update release with digest
run: |
#!/usr/bin/env bash

set -euo pipefail

PAYLOAD=$(cat "${GITHUB_EVENT_PATH}")

RELEASE_ID=$(jq -n -r --argjson PAYLOAD "${PAYLOAD}" '$PAYLOAD.release.id')
RELEASE_TAG_NAME=$(jq -n -r --argjson PAYLOAD "${PAYLOAD}" '$PAYLOAD.release.tag_name')
RELEASE_NAME=$(jq -n -r --argjson PAYLOAD "${PAYLOAD}" '$PAYLOAD.release.name')
RELEASE_BODY=$(jq -n -r --argjson PAYLOAD "${PAYLOAD}" '$PAYLOAD.release.body')

gh api \
--method PATCH \
"/repos/:owner/:repo/releases/${RELEASE_ID}" \
Expand All @@ -212,7 +177,7 @@ jobs:
DIGEST: ${{ steps.package.outputs.digest }}
GITHUB_TOKEN: ${{ secrets.PAT }}
- if: ${{ true }}
uses: docker://ghcr.io/buildpacks/actions/registry/request-add-entry:5.6.0
uses: docker://ghcr.io/buildpacks/actions/registry/request-add-entry:5.12.0
with:
address: docker.io/initializbuildpacks/ca-certificates@${{ steps.package.outputs.digest }}
id: initializ-buildpacks/ca-certificates
Expand Down
Loading
Loading