From 4171435bea78437be70cc739751d74534cb4b848 Mon Sep 17 00:00:00 2001 From: paketo-bot Date: Thu, 8 Jul 2021 15:48:11 +0000 Subject: [PATCH] Bump pipeline from 1.10.0 to 1.10.0 Bumps pipeline from 1.10.0 to 1.10.0. Signed-off-by: GitHub --- .github/CODEOWNERS | 1 + .github/dependabot.yml | 9 + .github/labels.yml | 27 +++ .github/release-drafter.yml | 32 ++++ .github/workflows/create-package.yml | 184 ++++++++++++++++++++ .github/workflows/minimal-labels.yml | 29 ++++ .github/workflows/synchronize-labels.yml | 17 ++ .github/workflows/tests.yml | 177 +++++++++++++++++++ .github/workflows/update-draft-release.yml | 191 +++++++++++++++++++++ 9 files changed, 667 insertions(+) create mode 100644 .github/CODEOWNERS create mode 100644 .github/dependabot.yml create mode 100644 .github/labels.yml create mode 100644 .github/release-drafter.yml create mode 100644 .github/workflows/create-package.yml create mode 100644 .github/workflows/minimal-labels.yml create mode 100644 .github/workflows/synchronize-labels.yml create mode 100644 .github/workflows/tests.yml create mode 100644 .github/workflows/update-draft-release.yml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..c3b2fc0 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @paketo-buildpacks/java-buildpacks \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..5302b7b --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,9 @@ +version: 2 +updates: + - package-ecosystem: gomod + directory: / + schedule: + interval: daily + labels: + - semver:patch + - type:dependency-upgrade diff --git a/.github/labels.yml b/.github/labels.yml new file mode 100644 index 0000000..270dd19 --- /dev/null +++ b/.github/labels.yml @@ -0,0 +1,27 @@ +- name: semver:major + description: A change requiring a major version bump + color: f9d0c4 +- name: semver:minor + description: A change requiring a minor version bump + color: f9d0c4 +- name: semver:patch + description: A change requiring a patch version bump + color: f9d0c4 +- name: type:bug + description: A general bug + color: e3d9fc +- name: type:dependency-upgrade + description: A dependency upgrade + color: e3d9fc +- name: type:documentation + description: A documentation update + color: e3d9fc +- name: type:enhancement + description: A general enhancement + color: e3d9fc +- name: type:question + description: A user question + color: e3d9fc +- name: type:task + description: A general task + color: e3d9fc diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..b5c1d5b --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,32 @@ +template: $CHANGES +name-template: $RESOLVED_VERSION +tag-template: v$RESOLVED_VERSION +categories: + - title: ⭐️ Enhancements + labels: + - type:enhancement + - title: "\U0001F41E Bug Fixes" + labels: + - type:bug + - title: "\U0001F4D4 Documentation" + labels: + - type:documentation + - title: ⛏ Dependency Upgrades + labels: + - type:dependency-upgrade + - title: "\U0001F6A7 Tasks" + labels: + - type:task +exclude-labels: + - type:question +version-resolver: + major: + labels: + - semver:major + minor: + labels: + - semver:minor + patch: + labels: + - semver:patch + default: patch diff --git a/.github/workflows/create-package.yml b/.github/workflows/create-package.yml new file mode 100644 index 0000000..fd8e7c6 --- /dev/null +++ b/.github/workflows/create-package.yml @@ -0,0 +1,184 @@ +name: Create Package +"on": + release: + types: + - published +jobs: + create-package: + name: Create Package + runs-on: + - ubuntu-latest + steps: + - if: ${{ github.event_name != 'pull_request' || ! github.event.pull_request.head.repo.fork }} + name: Docker login gcr.io + uses: docker/login-action@v1 + with: + password: ${{ secrets.JAVA_GCLOUD_SERVICE_ACCOUNT_KEY }} + registry: gcr.io + username: _json_key + - uses: actions/setup-go@v2 + with: + go-version: "1.16" + - name: Install create-package + run: | + #!/usr/bin/env bash + + set -euo pipefail + + GO111MODULE=on go get -u -ldflags="-s -w" github.com/paketo-buildpacks/libpak/cmd/create-package + - 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.5.1 + - 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.18.1 + - if: ${{ false }} + name: Enable pack Experimental + 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@v2 + - if: ${{ false }} + uses: actions/cache@v2 + with: + key: ${{ runner.os }}-go-${{ hashFiles('**/buildpack.toml', '**/package.toml') }} + path: |- + ${{ env.HOME }}/.pack + ${{ env.HOME }}/carton-cache + restore-keys: ${{ runner.os }}-go- + - id: version + name: Compute Version + run: | + #!/usr/bin/env bash + + set -euo pipefail + + if [[ ${GITHUB_REF} =~ refs/tags/v([0-9]+\.[0-9]+\.[0-9]+) ]]; then + VERSION=${BASH_REMATCH[1]} + elif [[ ${GITHUB_REF} =~ refs/heads/(.+) ]]; then + VERSION=${BASH_REMATCH[1]} + else + VERSION=$(git rev-parse --short HEAD) + fi + + echo "::set-output name=version::${VERSION}" + echo "Selected ${VERSION} from + * ref: ${GITHUB_REF} + * sha: ${GITHUB_SHA} + " + - name: Create Package + run: | + #!/usr/bin/env bash + + set -euo pipefail + + if [[ "${INCLUDE_DEPENDENCIES}" == "true" ]]; then + create-package \ + --cache-location "${HOME}"/carton-cache \ + --destination "${HOME}"/buildpack \ + --include-dependencies \ + --version "${VERSION}" + else + create-package \ + --destination "${HOME}"/buildpack \ + --version "${VERSION}" + fi + + [[ -e package.toml ]] && cp package.toml "${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 + VERSION: ${{ steps.version.outputs.version }} + - id: package + name: Package Buildpack + run: | + #!/usr/bin/env bash + + set -euo pipefail + + if [[ -n "${PUBLISH+x}" ]]; then + pack package-buildpack \ + "${PACKAGE}:${VERSION}" \ + --config "${HOME}"/package.toml \ + --publish + + crane tag "${PACKAGE}:${VERSION}" latest + echo "::set-output name=digest::$(crane digest "${PACKAGE}:${VERSION}")" + else + pack package-buildpack \ + "${PACKAGE}:${VERSION}" \ + --config "${HOME}"/package.toml \ + --format "${FORMAT}" + fi + env: + PACKAGE: gcr.io/paketo-buildpacks/watchexec + PUBLISH: "true" + VERSION: ${{ steps.version.outputs.version }} + - 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.JAVA_GITHUB_TOKEN }} + - if: ${{ true }} + uses: docker://ghcr.io/buildpacks/actions/registry/request-add-entry:4.0.1 + with: + address: gcr.io/paketo-buildpacks/watchexec@${{ steps.package.outputs.digest }} + id: paketo-buildpacks/watchexec + token: ${{ secrets.JAVA_GITHUB_TOKEN }} + version: ${{ steps.version.outputs.version }} diff --git a/.github/workflows/minimal-labels.yml b/.github/workflows/minimal-labels.yml new file mode 100644 index 0000000..1bb1fd6 --- /dev/null +++ b/.github/workflows/minimal-labels.yml @@ -0,0 +1,29 @@ +name: Minimal Labels +"on": + pull_request: + types: + - synchronize + - reopened + - labeled + - unlabeled +jobs: + semver: + name: Minimal Semver Labels + runs-on: + - ubuntu-latest + steps: + - uses: mheap/github-action-required-labels@v1 + with: + count: 1 + labels: semver:major, semver:minor, semver:patch + mode: exactly + type: + name: Minimal Type Labels + runs-on: + - ubuntu-latest + steps: + - uses: mheap/github-action-required-labels@v1 + with: + count: 1 + labels: type:bug, type:dependency-upgrade, type:documentation, type:enhancement, type:question, type:task + mode: exactly diff --git a/.github/workflows/synchronize-labels.yml b/.github/workflows/synchronize-labels.yml new file mode 100644 index 0000000..ce69fdf --- /dev/null +++ b/.github/workflows/synchronize-labels.yml @@ -0,0 +1,17 @@ +name: Synchronize Labels +"on": + push: + branches: + - main + paths: + - .github/labels.yml +jobs: + synchronize: + name: Synchronize Labels + runs-on: + - ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: micnncim/action-label-syncer@v1 + env: + GITHUB_TOKEN: ${{ secrets.JAVA_GITHUB_TOKEN }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..6cb3ab6 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,177 @@ +name: Tests +"on": + pull_request: {} + push: + branches: + - main +jobs: + create-package: + name: Create Package Test + runs-on: + - ubuntu-latest + steps: + - if: ${{ github.event_name != 'pull_request' || ! github.event.pull_request.head.repo.fork }} + name: Docker login gcr.io + uses: docker/login-action@v1 + with: + password: ${{ secrets.JAVA_GCLOUD_SERVICE_ACCOUNT_KEY }} + registry: gcr.io + username: _json_key + - name: Install create-package + run: | + #!/usr/bin/env bash + + set -euo pipefail + + GO111MODULE=on go get -u -ldflags="-s -w" github.com/paketo-buildpacks/libpak/cmd/create-package + - 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.18.1 + - if: ${{ false }} + name: Enable pack Experimental + 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/setup-go@v2 + with: + go-version: "1.16" + - uses: actions/checkout@v2 + - uses: actions/cache@v2 + with: + key: ${{ runner.os }}-go-${{ hashFiles('**/buildpack.toml', '**/package.toml') }} + path: |- + ${{ env.HOME }}/.pack + ${{ env.HOME }}/carton-cache + restore-keys: ${{ runner.os }}-go- + - id: version + name: Compute Version + run: | + #!/usr/bin/env bash + + set -euo pipefail + + if [[ ${GITHUB_REF} =~ refs/tags/v([0-9]+\.[0-9]+\.[0-9]+) ]]; then + VERSION=${BASH_REMATCH[1]} + elif [[ ${GITHUB_REF} =~ refs/heads/(.+) ]]; then + VERSION=${BASH_REMATCH[1]} + else + VERSION=$(git rev-parse --short HEAD) + fi + + echo "::set-output name=version::${VERSION}" + echo "Selected ${VERSION} from + * ref: ${GITHUB_REF} + * sha: ${GITHUB_SHA} + " + - name: Create Package + run: | + #!/usr/bin/env bash + + set -euo pipefail + + if [[ "${INCLUDE_DEPENDENCIES}" == "true" ]]; then + create-package \ + --cache-location "${HOME}"/carton-cache \ + --destination "${HOME}"/buildpack \ + --include-dependencies \ + --version "${VERSION}" + else + create-package \ + --destination "${HOME}"/buildpack \ + --version "${VERSION}" + fi + + [[ -e package.toml ]] && cp package.toml "${HOME}"/package.toml + printf '[buildpack]\nuri = "%s"\n\n[platform]\nos = "%s"\n' "${HOME}"/buildpack "${OS}" >> "${HOME}"/package.toml + env: + INCLUDE_DEPENDENCIES: "true" + OS: linux + VERSION: ${{ steps.version.outputs.version }} + - name: Package Buildpack + run: | + #!/usr/bin/env bash + + set -euo pipefail + + if [[ -n "${PUBLISH+x}" ]]; then + pack package-buildpack \ + "${PACKAGE}:${VERSION}" \ + --config "${HOME}"/package.toml \ + --publish + + crane tag "${PACKAGE}:${VERSION}" latest + echo "::set-output name=digest::$(crane digest "${PACKAGE}:${VERSION}")" + else + pack package-buildpack \ + "${PACKAGE}:${VERSION}" \ + --config "${HOME}"/package.toml \ + --format "${FORMAT}" + fi + env: + FORMAT: image + PACKAGE: test + VERSION: ${{ steps.version.outputs.version }} + unit: + name: Unit Test + runs-on: + - ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/cache@v2 + with: + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + path: ${{ env.HOME }}/go/pkg/mod + restore-keys: ${{ runner.os }}-go- + - uses: actions/setup-go@v2 + with: + go-version: "1.16" + - name: Install richgo + run: | + #!/usr/bin/env bash + + set -euo pipefail + + echo "Installing richgo ${RICHGO_VERSION}" + + mkdir -p "${HOME}"/bin + echo "${HOME}/bin" >> "${GITHUB_PATH}" + + curl \ + --location \ + --show-error \ + --silent \ + "https://github.com/kyoh86/richgo/releases/download/v${RICHGO_VERSION}/richgo_${RICHGO_VERSION}_linux_amd64.tar.gz" \ + | tar -C "${HOME}"/bin -xz richgo + env: + RICHGO_VERSION: 0.3.6 + - name: Run Tests + run: | + #!/usr/bin/env bash + + set -euo pipefail + + richgo test ./... + env: + RICHGO_FORCE_COLOR: "1" diff --git a/.github/workflows/update-draft-release.yml b/.github/workflows/update-draft-release.yml new file mode 100644 index 0000000..84cc027 --- /dev/null +++ b/.github/workflows/update-draft-release.yml @@ -0,0 +1,191 @@ +name: Update Draft Release +"on": + push: + branches: + - main +jobs: + update: + name: Update Draft Release + runs-on: + - ubuntu-latest + steps: + - id: release-drafter + uses: release-drafter/release-drafter@v5 + env: + GITHUB_TOKEN: ${{ secrets.JAVA_GITHUB_TOKEN }} + - name: Install yj + run: | + #!/usr/bin/env bash + + set -euo pipefail + + echo "Installing yj ${YJ_VERSION}" + + mkdir -p "${HOME}"/bin + echo "${HOME}/bin" >> "${GITHUB_PATH}" + + curl \ + --location \ + --show-error \ + --silent \ + --output "${HOME}"/bin/yj \ + "https://github.com/sclevine/yj/releases/download/v${YJ_VERSION}/yj-linux" + + chmod +x "${HOME}"/bin/yj + env: + YJ_VERSION: 5.0.0 + - uses: actions/checkout@v2 + - name: Update draft release with buildpack information + run: | + #!/usr/bin/env bash + + set -euo pipefail + + PAYLOAD="{}" + + if [[ -e buildpack.toml ]]; then + PAYLOAD=$(jq -n -r \ + --argjson PAYLOAD "${PAYLOAD}" \ + --argjson BUILDPACK "$(yj -tj < buildpack.toml)" \ + '$PAYLOAD | .primary = $BUILDPACK') + fi + + if [[ -e builder.toml ]]; then + PAYLOAD=$(jq -n -r \ + --argjson PAYLOAD "${PAYLOAD}" \ + --argjson BUILDER "$(yj -tj < builder.toml)" \ + '$PAYLOAD | .primary = $BUILDER') + + for BUILDPACK in $( + jq -n -r \ + --argjson PAYLOAD "${PAYLOAD}" \ + '$PAYLOAD.primary.buildpacks[].uri | capture("(?:.+://)?(?.+)") | .image' + ); do + crane export "${BUILDPACK}" - | tar xf - --absolute-names --strip-components 1 --wildcards "/cnb/buildpacks/*/*/buildpack.toml" + done + fi + + if [[ -e package.toml ]]; then + for PACKAGE in $(yj -t < package.toml | jq -r '.dependencies[].uri | capture("(?:.+://)?(?.+)") | .image'); do + crane export "${PACKAGE}" - | tar xf - --absolute-names --strip-components 1 --wildcards "/cnb/buildpacks/*/*/buildpack.toml" + done + fi + + if [[ -d buildpacks ]]; then + while IFS= read -r -d '' FILE; do + PAYLOAD=$(jq -n -r \ + --argjson PAYLOAD "${PAYLOAD}" \ + --argjson BUILDPACK "$(yj -tj < "${FILE}")" \ + '$PAYLOAD | .buildpacks += [ $BUILDPACK ]') + done < <(find buildpacks -name buildpack.toml -print0) + fi + + jq -n -r \ + --argjson PAYLOAD "${PAYLOAD}" \ + --arg RELEASE_NAME "${RELEASE_NAME}" \ + '( select($PAYLOAD.primary.buildpack.name) | "\($PAYLOAD.primary.buildpack.name) \($RELEASE_NAME)" ) // "\($RELEASE_NAME)"' \ + > "${HOME}"/name + + jq -n -r \ + --argjson PAYLOAD "${PAYLOAD}" \ + --arg RELEASE_BODY "${RELEASE_BODY}" \ + ' + def id(b): + select(b.buildpack.id) | "**ID**: `\(b.buildpack.id)`" + ; + + def included_buildpackages(b): [ + "#### Included Buildpackages:", + "Name | ID | Version", + ":--- | :- | :------", + ( b | sort_by(.buildpack.name | ascii_downcase) | map("\(.buildpack.name) | `\(.buildpack.id)` | `\(.buildpack.version)`") ), + "" + ]; + + def stacks(s): [ + "#### Supported Stacks:", + ( s | sort_by(.id | ascii_downcase) | map("- `\(.id)`") ), + "" + ]; + + def default_dependency_versions(d): [ + "#### Default Dependency Versions:", + "ID | Version", + ":- | :------", + ( d | to_entries | sort_by(.key | ascii_downcase) | map("`\(.key)` | `\(.value)`") ), + "" + ]; + + def dependencies(d): [ + "#### Dependencies:", + "Name | Version | SHA256", + ":--- | :------ | :-----", + ( d | sort_by(.name // .id | ascii_downcase) | map("\(.name // .id) | `\(.version)` | `\(.sha256)`")), + "" + ]; + + def order_groupings(o): [ + "
", + "Order Groupings", + "", + ( o | map([ + "ID | Version | Optional", + ":- | :------ | :-------", + ( .group | map([ "`\(.id)` | ", (select(.version) | "`\(.version)`"), ( select(.optional) | "| `\(.optional)`" ) ] | join(" ")) ), + "" + ])), + "
", + "" + ]; + + def primary_buildpack(p): [ + id(p.primary), + "**Digest**: ", + "", + ( select(p.buildpacks) | included_buildpackages(p.buildpacks) ), + ( select(p.primary.stacks) | stacks(p.primary.stacks) ), + ( select(p.primary.metadata."default-versions") | default_dependency_versions(p.primary.metadata."default-versions") ), + ( select(p.primary.metadata.dependencies) | dependencies(p.primary.metadata.dependencies) ), + ( select(p.primary.order) | order_groupings(p.primary.order) ), + ( select(p.buildpacks) | "---" ), + "" + ]; + + def nested_buildpack(b): [ + "
", + "\(b.buildpack.name) \(b.buildpack.version)", + "", + id(b), + "", + ( select(b.stacks) | stacks(b.stacks) ), + ( select(b.metadata."default-versions") | default_dependency_versions(b.metadata."default-versions") ), + ( select(b.metadata.dependencies) | dependencies(b.metadata.dependencies) ), + ( select(b.order) | order_groupings(b.order) ), + "---", + "", + "
", + "" + ]; + + $PAYLOAD | [ + primary_buildpack(.), + ( select(.buildpacks) | [ .buildpacks | sort_by(.buildpack.name | ascii_downcase) | map(nested_buildpack(.)) ] ), + "", + "---", + "", + $RELEASE_BODY + ] | flatten | join("\n") + ' > "${HOME}"/body + + gh api \ + --method PATCH \ + "/repos/:owner/:repo/releases/${RELEASE_ID}" \ + --field "tag_name=${RELEASE_TAG_NAME}" \ + --field "name=@${HOME}/name" \ + --field "body=@${HOME}/body" + env: + GITHUB_TOKEN: ${{ secrets.JAVA_GITHUB_TOKEN }} + RELEASE_BODY: ${{ steps.release-drafter.outputs.body }} + RELEASE_ID: ${{ steps.release-drafter.outputs.id }} + RELEASE_NAME: ${{ steps.release-drafter.outputs.name }} + RELEASE_TAG_NAME: ${{ steps.release-drafter.outputs.tag_name }}