Skip to content

Commit

Permalink
Bump pipeline & add jobs to publish buildpack
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Mikusa <[email protected]>
  • Loading branch information
Daniel Mikusa committed Nov 17, 2021
1 parent 86ca297 commit ba3b164
Show file tree
Hide file tree
Showing 7 changed files with 324 additions and 13 deletions.
1 change: 0 additions & 1 deletion .github/labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,3 @@
- name: type:task
description: A general task
color: e3d9fc

16 changes: 13 additions & 3 deletions .github/pipeline-descriptor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
github:
username: ${{ secrets.GITHUB_USERNAME }}
token: ${{ secrets.GITHUB_TOKEN }}
username: ${{ secrets.JAVA_GITHUB_USERNAME }}
token: ${{ secrets.JAVA_GITHUB_TOKEN }}

codeowners:
- path: "*"
owner: "@paketo-buildpacks/java-buildpacks"
owner: "@paketo-buildpacks/java-buildpacks"

package:
repository: gcr.io/paketo-buildpacks/open-liberty
register: true
registry_token: ${{ secrets.JAVA_GITHUB_TOKEN }}

docker_credentials:
- registry: gcr.io
username: _json_key
password: ${{ secrets.JAVA_GCLOUD_SERVICE_ACCOUNT_KEY }}
184 changes: 184 additions & 0 deletions .github/workflows/create-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
name: Create Package
"on":
release:
types:
- published
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@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.6.0
- 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.21.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@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-
- name: Compute Version
id: 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 }}
- name: Package Buildpack
id: package
run: |
#!/usr/bin/env bash
set -euo pipefail
if [[ -n "${PUBLISH+x}" ]]; then
pack buildpack package \
"${PACKAGE}:${VERSION}" \
--config "${HOME}"/package.toml \
--publish
crane tag "${PACKAGE}:${VERSION}" latest
echo "::set-output name=digest::$(crane digest "${PACKAGE}:${VERSION}")"
else
pack buildpack package \
"${PACKAGE}:${VERSION}" \
--config "${HOME}"/package.toml \
--format "${FORMAT}"
fi
env:
PACKAGE: gcr.io/paketo-buildpacks/open-liberty
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 PLACEHOLDER -->/\`${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/open-liberty@${{ steps.package.outputs.digest }}
id: paketo-buildpacks/open-liberty
token: ${{ secrets.JAVA_GITHUB_TOKEN }}
version: ${{ steps.version.outputs.version }}
2 changes: 1 addition & 1 deletion .github/workflows/synchronize-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ jobs:
- uses: actions/checkout@v2
- uses: micnncim/action-label-syncer@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.JAVA_GITHUB_TOKEN }}
122 changes: 121 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,127 @@ name: Tests
branches:
- main
jobs:
create-package:
name: Create Package Test
runs-on:
- ubuntu-latest
steps:
- 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 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.21.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@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-
- name: Compute Version
id: 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 buildpack package \
"${PACKAGE}:${VERSION}" \
--config "${HOME}"/package.toml \
--publish
crane tag "${PACKAGE}:${VERSION}" latest
echo "::set-output name=digest::$(crane digest "${PACKAGE}:${VERSION}")"
else
pack buildpack package \
"${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:
Expand Down Expand Up @@ -47,4 +168,3 @@ jobs:
richgo test ./...
env:
RICHGO_FORCE_COLOR: "1"

5 changes: 2 additions & 3 deletions .github/workflows/update-draft-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- id: release-drafter
uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.JAVA_GITHUB_TOKEN }}
- name: Install yj
run: |
#!/usr/bin/env bash
Expand Down Expand Up @@ -184,9 +184,8 @@ jobs:
--field "name=@${HOME}/name" \
--field "body=@${HOME}/body"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
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 }}

7 changes: 3 additions & 4 deletions .github/workflows/update-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ jobs:
echo "::set-output name=release-notes::${RELEASE_NOTES//$'\n'/%0A}"
env:
DESCRIPTOR: .github/pipeline-descriptor.yml
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.JAVA_GITHUB_TOKEN }}
- uses: peter-evans/create-pull-request@v3
with:
author: ${{ secrets.GITHUB_USERNAME }} <${{ secrets.GITHUB_USERNAME }}@users.noreply.github.com>
author: ${{ secrets.JAVA_GITHUB_USERNAME }} <${{ secrets.JAVA_GITHUB_USERNAME }}@users.noreply.github.com>
body: |-
Bumps pipeline from `${{ steps.pipeline.outputs.old-version }}` to `${{ steps.pipeline.outputs.new-version }}`.
Expand All @@ -81,5 +81,4 @@ jobs:
labels: semver:patch, type:task
signoff: true
title: Bump pipeline from ${{ steps.pipeline.outputs.old-version }} to ${{ steps.pipeline.outputs.new-version }}
token: ${{ secrets.GITHUB_TOKEN }}

token: ${{ secrets.JAVA_GITHUB_TOKEN }}

0 comments on commit ba3b164

Please sign in to comment.