diff --git a/.github/workflows/multi-arch-create-package.yml b/.github/workflows/multi-arch-create-package.yml deleted file mode 100644 index 50b48dc..0000000 --- a/.github/workflows/multi-arch-create-package.yml +++ /dev/null @@ -1,396 +0,0 @@ -name: Create arm64, amd64 and multi arch Packages -"on": - push: - branches: - - anthonydahanne-arm64-tests -jobs: - create-arm64-package: - name: Create arm64 Package - runs-on: - - buildjet-4vcpu-ubuntu-2204-arm - steps: - - name: Docker login gcr.io - if: ${{ (github.event_name != 'pull_request' || ! github.event.pull_request.head.repo.fork) && (github.actor != 'dependabot[bot]') }} - uses: docker/login-action@v2 - with: - password: ${{ secrets.GCR_PUSH_BOT_JSON_KEY }} - registry: gcr.io - username: _json_key - - uses: actions/setup-go@v5 - with: - go-version: "1.20" - - 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 - - name: Install pack - run: | - #!/usr/bin/env bash - - set -euo pipefail - - echo "Installing pack ${PACK_VERSION}" - - mkdir -p "${HOME}"/bin - echo "${HOME}/bin" >> "${GITHUB_PATH}" - - curl \ - --location \ - --show-error \ - --silent \ - "https://github.com/buildpacks/pack/releases/download/v${PACK_VERSION}/pack-v${PACK_VERSION}-linux-arm64.tgz" \ - | tar -C "${HOME}"/bin -xz pack - env: - PACK_VERSION: 0.32.1 - - 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 - - if: ${{ false }} - uses: actions/cache@v4 - with: - key: ${{ runner.os }}-go-${{ hashFiles('**/buildpack.toml', '**/package.toml') }} - path: |- - ${{ env.HOME }}/.pack - ${{ env.HOME }}/carton-cache - restore-keys: ${{ runner.os }}-go- - - name: Compute Version - id: version - run: | - #!/usr/bin/env bash - - set -euo pipefail - - if [ -z "${GITHUB_REF+set}" ]; then - echo "GITHUB_REF set to [${GITHUB_REF-}], but should never be empty or unset" - 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} - * sha: ${GITHUB_SHA} - " - - 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:-.} \ - --cache-location "${HOME}"/carton-cache \ - --destination "${HOME}"/buildpack \ - --include-dependencies \ - --version "${VERSION}" - else - create-package \ - --source ${SOURCE_PATH:-.} \ - --destination "${HOME}"/buildpack \ - --version "${VERSION}" - fi - - PACKAGE_FILE=${SOURCE_PATH:-.}/package.toml - [[ -e ${PACKAGE_FILE} ]] && cp ${PACKAGE_FILE} "${HOME}"/package.toml - printf '[buildpack]\nuri = "%s"\n\n[platform]\nos = "%s"\n' "${HOME}"/buildpack "${OS}" >> "${HOME}"/package.toml - env: - INCLUDE_DEPENDENCIES: "false" - OS: linux - SOURCE_PATH: "" - VERSION: 0.0.1-anthony - - name: Package Buildpack - id: package - run: |- - #!/usr/bin/env bash - - set -euo pipefail - - if [[ "${PUBLISH:-x}" == "true" ]]; then - pack buildpack package \ - "${PACKAGE}:$VERSION-$ARCH_SUFFIX" \ - --config "${HOME}"/package.toml \ - --publish - - else - pack buildpack package \ - "${PACKAGE}:$VERSION-$ARCH_SUFFIX" \ - --config "${HOME}"/package.toml - fi - env: - PACKAGE: gcr.io/paketo-buildpacks/syft - PUBLISH: "true" - VERSION: 0.0.1-anthony - ARCH_SUFFIX: arm64 - - - create-package: - name: Create Package - runs-on: - - ubuntu-latest - outputs: - version-major: ${{ steps.version.outputs.version-major }} - version-minor: ${{ steps.version.outputs.version-minor }} - version: ${{ steps.version.outputs.version }} - steps: - - name: Docker login gcr.io - if: ${{ (github.event_name != 'pull_request' || ! github.event.pull_request.head.repo.fork) && (github.actor != 'dependabot[bot]') }} - uses: docker/login-action@v2 - with: - password: ${{ secrets.GCR_PUSH_BOT_JSON_KEY }} - registry: gcr.io - username: _json_key - - uses: actions/setup-go@v5 - with: - go-version: "1.20" - - 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 - - name: Install pack - run: | - #!/usr/bin/env bash - - set -euo pipefail - - echo "Installing pack ${PACK_VERSION}" - - mkdir -p "${HOME}"/bin - echo "${HOME}/bin" >> "${GITHUB_PATH}" - - curl \ - --location \ - --show-error \ - --silent \ - "https://github.com/buildpacks/pack/releases/download/v${PACK_VERSION}/pack-v${PACK_VERSION}-linux.tgz" \ - | tar -C "${HOME}"/bin -xz pack - env: - PACK_VERSION: 0.32.1 - - 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 - - if: ${{ false }} - uses: actions/cache@v4 - with: - key: ${{ runner.os }}-go-${{ hashFiles('**/buildpack.toml', '**/package.toml') }} - path: |- - ${{ env.HOME }}/.pack - ${{ env.HOME }}/carton-cache - restore-keys: ${{ runner.os }}-go- - - name: Compute Version - id: version - run: | - #!/usr/bin/env bash - - set -euo pipefail - - if [ -z "${GITHUB_REF+set}" ]; then - echo "GITHUB_REF set to [${GITHUB_REF-}], but should never be empty or unset" - 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} - * sha: ${GITHUB_SHA} - " - - 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:-.} \ - --cache-location "${HOME}"/carton-cache \ - --destination "${HOME}"/buildpack \ - --include-dependencies \ - --version "${VERSION}" - else - create-package \ - --source ${SOURCE_PATH:-.} \ - --destination "${HOME}"/buildpack \ - --version "${VERSION}" - fi - - PACKAGE_FILE=${SOURCE_PATH:-.}/package.toml - [[ -e ${PACKAGE_FILE} ]] && cp ${PACKAGE_FILE} "${HOME}"/package.toml - printf '[buildpack]\nuri = "%s"\n\n[platform]\nos = "%s"\n' "${HOME}"/buildpack "${OS}" >> "${HOME}"/package.toml - env: - INCLUDE_DEPENDENCIES: "false" - OS: linux - SOURCE_PATH: "" - VERSION: 0.0.1-anthony - - name: Package Buildpack - id: package - run: |- - #!/usr/bin/env bash - - set -euo pipefail - - if [[ "${PUBLISH:-x}" == "true" ]]; then - pack buildpack package \ - "${PACKAGE}:$VERSION-$ARCH_SUFFIX" \ - --config "${HOME}"/package.toml \ - --publish - else - pack buildpack package \ - "${PACKAGE}:$VERSION-$ARCH_SUFFIX" \ - --config "${HOME}"/package.toml - fi - env: - PACKAGE: gcr.io/paketo-buildpacks/syft - PUBLISH: "true" - VERSION: 0.0.1-anthony - ARCH_SUFFIX: amd64 - - create-multiarch-package: - name: Create Multi-Arch Package - needs: [create-package, create-arm64-package] - runs-on: - - ubuntu-latest - steps: - - name: Docker login gcr.io - if: ${{ (github.event_name != 'pull_request' || ! github.event.pull_request.head.repo.fork) && (github.actor != 'dependabot[bot]') }} - uses: docker/login-action@v2 - with: - password: ${{ secrets.GCR_PUSH_BOT_JSON_KEY }} - registry: gcr.io - username: _json_key - - name: Docker login docker.io - if: ${{ (github.event_name != 'pull_request' || ! github.event.pull_request.head.repo.fork) && (github.actor != 'dependabot[bot]') }} - uses: docker/login-action@v2 - with: - password: ${{ secrets.PAKETO_BUILDPACKS_DOCKERHUB_PASSWORD }} - registry: docker.io - username: ${{ secrets.PAKETO_BUILDPACKS_DOCKERHUB_USERNAME }} - - name: Install crane - run: | - #!/usr/bin/env bash - - set -euo pipefail - - echo "Installing crane ${CRANE_VERSION}" - - mkdir -p "${HOME}"/bin - echo "${HOME}/bin" >> "${GITHUB_PATH}" - - curl \ - --show-error \ - --silent \ - --location \ - "https://github.com/google/go-containerregistry/releases/download/v${CRANE_VERSION}/go-containerregistry_Linux_x86_64.tar.gz" \ - | tar -C "${HOME}/bin" -xz crane - env: - CRANE_VERSION: 0.18.0 - - name: Merge and push manifests - if: ${{ env.PUBLISH == 'true' }} - run: | - #!/usr/bin/env bash - set -x - set -euo pipefail - - PACKAGE_LIST=($PACKAGES) - # Extract first repo (GCR) as the main to duplicate - PACKAGE=${PACKAGE_LIST[0]} - - docker pull ${PACKAGE}:${VERSION}-amd64 && docker pull ${PACKAGE}:${VERSION}-arm64 - docker manifest create ${PACKAGE}:${VERSION} --amend ${PACKAGE}:${VERSION}-amd64 --amend ${PACKAGE}:${VERSION}-arm64 - docker manifest annotate gcr.io/paketo-buildpacks/syft:0.0.1-anthony gcr.io/paketo-buildpacks/syft:0.0.1-anthony-amd64 --arch amd64 - docker manifest annotate gcr.io/paketo-buildpacks/syft:0.0.1-anthony gcr.io/paketo-buildpacks/syft:0.0.1-anthony-arm64 --arch arm64 - docker manifest push ${PACKAGE}:${VERSION} - docker pull ${PACKAGE}:${VERSION} - - 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 - if [ "$P" != "$PACKAGE" ]; then - crane copy "${PACKAGE}:${VERSION}" "${P}:${VERSION}" - if [[ -n ${VERSION_MINOR:-} && -n ${VERSION_MAJOR:-} ]]; then - crane tag "${P}:${VERSION}" "${VERSION_MINOR}" - crane tag "${P}:${VERSION}" "${VERSION_MAJOR}" - fi - # crane tag "${P}:${VERSION}" latest - fi - done - - - env: - PACKAGES: gcr.io/paketo-buildpacks/syft docker.io/paketobuildpacks/syft - PUBLISH: "true" - VERSION: 0.0.1-anthony - VERSION_MAJOR: ${{ needs.steps.version.outputs.version-major }} - VERSION_MINOR: ${{ steps.version.outputs.version-minor }} \ No newline at end of file diff --git a/.github/workflows/pb-create-package.yml b/.github/workflows/pb-create-package.yml index e69de29..9173161 100644 --- a/.github/workflows/pb-create-package.yml +++ b/.github/workflows/pb-create-package.yml @@ -0,0 +1,220 @@ +name: Create Package +"on": + push: + branches: + - anthonydahanne-arm64-tests +jobs: + create-package: + name: Create Package + runs-on: + - ubuntu-latest + steps: + - name: Docker login gcr.io + if: ${{ (github.event_name != 'pull_request' || ! github.event.pull_request.head.repo.fork) && (github.actor != 'dependabot[bot]') }} + uses: docker/login-action@v3 + with: + password: ${{ secrets.GCR_PUSH_BOT_JSON_KEY }} + registry: gcr.io + username: _json_key + - name: Docker login docker.io + if: ${{ (github.event_name != 'pull_request' || ! github.event.pull_request.head.repo.fork) && (github.actor != 'dependabot[bot]') }} + uses: docker/login-action@v3 + with: + password: ${{ secrets.PAKETO_BUILDPACKS_DOCKERHUB_PASSWORD }} + registry: docker.io + username: ${{ secrets.PAKETO_BUILDPACKS_DOCKERHUB_USERNAME }} + - uses: actions/setup-go@v5 + with: + go-version: "1.20" + - 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.5.3 + with: + crane-version: 0.19.0 + yj-version: 5.1.0 + # 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 + - name: Install pack + run: | + #!/usr/bin/env bash + + set -euo pipefail + + echo "Installing pack experimental" + + mkdir -p "${HOME}"/bin + echo "${HOME}/bin" >> "${GITHUB_PATH}" + + curl -L "https://ent.box.com/shared/static/97fyc5bhprj6nkwfoioo3l4cxktnooif" -o ${HOME}/bin/pack + chmod ${HOME}/bin/pack + + - 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 + - if: ${{ false }} + uses: actions/cache@v4 + with: + key: ${{ runner.os }}-go-${{ hashFiles('**/buildpack.toml', '**/package.toml') }} + path: |- + ${{ env.HOME }}/.pack + ${{ env.HOME }}/carton-cache + restore-keys: ${{ runner.os }}-go- + - name: Compute Version + 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} + * sha: ${GITHUB_SHA} + " + - 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:-.} \ + --cache-location "${HOME}"/carton-cache \ + --destination "${HOME}"/buildpack \ + --include-dependencies \ + --version "${VERSION}" + else + create-package \ + --source ${SOURCE_PATH:-.} \ + --destination "${HOME}"/buildpack \ + --version "${VERSION}" + fi + + PACKAGE_FILE=${SOURCE_PATH:-.}/package.toml + [[ -e ${PACKAGE_FILE} ]] && cp ${PACKAGE_FILE} "${HOME}"/package.toml + printf '[buildpack]\nuri = "%s"\n\n[platform]\nos = "%s"\n' "${HOME}"/buildpack "${OS}" >> "${HOME}"/package.toml + env: + INCLUDE_DEPENDENCIES: "false" + OS: linux + SOURCE_PATH: "" + VERSION: ${{ steps.version.outputs.version }} + - name: Package Buildpack + id: package + run: |- + #!/usr/bin/env bash + + set -euo pipefail + + + PACKAGE_LIST=($PACKAGES) + # Extract first repo (Docker Hub) as the main to package & register + PACKAGE=${PACKAGE_LIST[0]} + + if [[ "${PUBLISH:-x}" == "true" ]]; then + pack buildpack package \ + "${PACKAGE}:${VERSION}" \ + --config "${HOME}"/package.toml \ + --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 + if [ "$P" != "$PACKAGE" ]; then + crane copy "${PACKAGE}:${VERSION}" "${P}:${VERSION}" + if [[ -n ${VERSION_MINOR:-} && -n ${VERSION_MAJOR:-} ]]; then + crane tag "${P}:${VERSION}" "${VERSION_MINOR}" + crane tag "${P}:${VERSION}" "${VERSION_MAJOR}" + fi + crane tag "${P}:${VERSION}" latest + fi + done + + else + pack buildpack package \ + "${PACKAGE}:${VERSION}" \ + --config "${HOME}"/package.toml \ + --format "${FORMAT}" + fi + env: + PACKAGES: docker.io/paketobuildpacks/syft gcr.io/paketo-buildpacks/syft + PUBLISH: "true" + VERSION: dualarch-experiment + VERSION_MAJOR: dualarch + VERSION_MINOR: dualarch-exp +# - 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}" \ +# --field "tag_name=${RELEASE_TAG_NAME}" \ +# --field "name=${RELEASE_NAME}" \ +# --field "body=${RELEASE_BODY///\`${DIGEST}\`}" +# env: +# DIGEST: ${{ steps.package.outputs.digest }} +# GITHUB_TOKEN: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }} +# - if: ${{ true }} +# uses: docker://ghcr.io/buildpacks/actions/registry/request-add-entry:4.0.1 +# with: +# address: docker.io/paketobuildpacks/syft@${{ steps.package.outputs.digest }} +# id: paketo-buildpacks/syft +# token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }} +# version: ${{ steps.version.outputs.version }}