Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependency Update Pipelines #4

Merged
merged 1 commit into from
Oct 6, 2020
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
File renamed without changes.
111 changes: 61 additions & 50 deletions .github/workflows/create-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,87 +9,98 @@ jobs:
runs-on:
- ubuntu-latest
steps:
- 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/checkout@v2
- id: version
name: Compute Version
- 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-
- uses: actions/setup-go@v2
with:
go-version: "1.15"
- name: Install crane
run: |
#!/usr/bin/env bash

set -euo pipefail

PATTERN="refs/tags/v([0-9]+\.[0-9]+\.[0-9]+)"
if [[ ${GITHUB_REF} =~ ${PATTERN} ]]; then
VERSION=${BASH_REMATCH[1]}
else
VERSION=$(git rev-parse --short HEAD)
fi

echo "::set-output name=version::${VERSION}"
printf "Selected %s from
* ref: %s
* sha: %s
" "${VERSION}" "${GITHUB_REF}" "${GITHUB_SHA}"
- uses: actions/setup-go@v2
with:
go-version: "1.15"
- name: Install Create Package
GO111MODULE=on go get -u -ldflags="-s -w" github.com/google/go-containerregistry/cmd/crane
- 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: Create Package
- name: Install pack
run: |
#!/usr/bin/env bash

set -euo pipefail

if [[ -n "${INCLUDE_DEPENDENCIES+x}" ]]; then
create-package \
--cache-location "${HOME}"/carton-cache \
--destination "${HOME}"/buildpack \
--include-dependencies \
--version "${VERSION}"
else
create-package \
--destination "${HOME}"/buildpack \
--version "${VERSION}"
fi
mkdir -p "${HOME}"/bin
echo "${HOME}/bin" >> "${GITHUB_PATH}"

[[ -e package.toml ]] && cp package.toml "${HOME}"/package.toml
printf '[buildpack]\nuri = "%s"' "${HOME}"/buildpack >> "${HOME}"/package.toml
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/ -xzv pack
env:
VERSION: ${{ steps.version.outputs.version }}
- name: Install Crane
PACK_VERSION: 0.14.1
- id: version
name: Compute Version
run: |
#!/usr/bin/env bash

set -euo pipefail

GO111MODULE=on go get -u -ldflags="-s -w" github.com/google/go-containerregistry/cmd/crane
- name: Install pack
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

mkdir -p "${HOME}"/bin
echo "::add-path::${HOME}/bin"
if [[ -n "${INCLUDE_DEPENDENCIES+x}" ]]; then
create-package \
--cache-location "${HOME}"/carton-cache \
--destination "${HOME}"/buildpack \
--include-dependencies \
--version "${VERSION}"
else
create-package \
--destination "${HOME}"/buildpack \
--version "${VERSION}"
fi

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/ -xzv pack
[[ -e package.toml ]] && cp package.toml "${HOME}"/package.toml
printf '[buildpack]\nuri = "%s"' "${HOME}"/buildpack >> "${HOME}"/package.toml
env:
PACK_VERSION: 0.13.1
- uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
with:
service_account_key: ${{ secrets.JAVA_GCLOUD_SERVICE_ACCOUNT_KEY }}
- name: Configure gcloud docker credentials
run: gcloud auth configure-docker
INCLUDE_DEPENDENCIES: "false"
VERSION: ${{ steps.version.outputs.version }}
- id: package
name: Package Buildpack
run: |
Expand Down
107 changes: 58 additions & 49 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,72 @@ name: Tests
branches:
- main
jobs:
package:
name: Package Test
create-package:
name: Create Package Test
runs-on:
- ubuntu-latest
steps:
- 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/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-
- uses: actions/setup-go@v2
with:
go-version: "1.15"
- 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

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/ -xzv pack
env:
PACK_VERSION: 0.14.1
- id: version
name: Compute Version
run: |
#!/usr/bin/env bash

set -euo pipefail

PATTERN="refs/tags/v([0-9]+\.[0-9]+\.[0-9]+)"
if [[ ${GITHUB_REF} =~ ${PATTERN} ]]; then
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}"
printf "Selected %s from
* ref: %s
* sha: %s
" "${VERSION}" "${GITHUB_REF}" "${GITHUB_SHA}"
- uses: actions/setup-go@v2
with:
go-version: "1.15"
- uses: actions/cache@v2
with:
key: ${{ runner.os }}-go-${{ hashFiles('**/buildpack.toml') }}
path: ${{ env.HOME }}/carton-cache
restore-keys: ${{ runner.os }}-go-
- 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
echo "Selected ${VERSION} from
* ref: ${GITHUB_REF}
* sha: ${GITHUB_SHA}
"
- name: Create Package
run: |
#!/usr/bin/env bash
Expand All @@ -53,38 +79,21 @@ jobs:

if [[ -n "${INCLUDE_DEPENDENCIES+x}" ]]; then
create-package \
--cache-location "${HOME}"/carton-cache \
--destination "${HOME}"/buildpack \
--include-dependencies \
--version "${VERSION}"
--cache-location "${HOME}"/carton-cache \
--destination "${HOME}"/buildpack \
--include-dependencies \
--version "${VERSION}"
else
create-package \
--destination "${HOME}"/buildpack \
--version "${VERSION}"
--destination "${HOME}"/buildpack \
--version "${VERSION}"
fi

[[ -e package.toml ]] && cp package.toml "${HOME}"/package.toml
printf '[buildpack]\nuri = "%s"' "${HOME}"/buildpack >> "${HOME}"/package.toml
env:
INCLUDE_DEPENDENCIES: "true"
VERSION: ${{ steps.version.outputs.version }}
- name: Install pack
run: |
#!/usr/bin/env bash

set -euo pipefail

mkdir -p "${HOME}"/bin
echo "::add-path::${HOME}/bin"

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/ -xzv pack
env:
PACK_VERSION: 0.13.1
- name: Package Buildpack
run: |
#!/usr/bin/env bash
Expand Down Expand Up @@ -112,14 +121,14 @@ jobs:
- ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: "1.15"
- 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.15"
- name: Install richgo
run: |
#!/usr/bin/env bash
Expand Down
36 changes: 22 additions & 14 deletions .github/workflows/update-draft-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ jobs:
uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- 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/checkout@v2
- name: Install yj
run: |
Expand All @@ -21,14 +27,14 @@ jobs:
set -euo pipefail

mkdir -p "${HOME}"/bin
echo "::add-path::${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"
--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:
Expand All @@ -41,14 +47,16 @@ jobs:

PAYLOAD=$(yj -tj < buildpack.toml | jq '{ primary: . }')

for PACKAGE in $(yj -t < package.toml | jq -r '.dependencies[].image'); do
PAYLOAD=$(jq -n -r \
--argjson PAYLOAD "${PAYLOAD}" \
--argjson BUILDPACK "$(crane export "${PACKAGE}" - \
| tar xOf - --absolute-names --wildcards "/cnb/buildpacks/*/*/buildpack.toml" \
| yj -tj)" \
'$PAYLOAD | .buildpacks += [ $BUILDPACK ]')
done
if [[ -e package.toml ]]; then
for PACKAGE in $(yj -t < package.toml | jq -r '.dependencies[].image'); do
PAYLOAD=$(jq -n -r \
--argjson PAYLOAD "${PAYLOAD}" \
--argjson BUILDPACK "$(crane export "${PACKAGE}" - \
| tar xOf - --absolute-names --wildcards "/cnb/buildpacks/*/*/buildpack.toml" \
| yj -tj)" \
'$PAYLOAD | .buildpacks += [ $BUILDPACK ]')
done
fi

jq -n -r \
--argjson PAYLOAD "${PAYLOAD}" \
Expand Down
Loading