Skip to content

Commit

Permalink
feat: add initial buildpack
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrox committed Dec 12, 2023
1 parent 64a4de5 commit 95937dc
Show file tree
Hide file tree
Showing 34 changed files with 6,653 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/.patch_files
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.github/.patch_files
.github/.syncignore
.github/CODEOWNERS
.github/dependabot.yml
.github/labels.yml
.github/workflows/approve-bot-pr.yml
.github/workflows/codeql-analysis.yml
.github/workflows/go-get-update.yml
.github/workflows/label-pr.yml
.github/workflows/lint-yaml.yml
.github/workflows/lint.yml
.github/workflows/synchronize-labels.yml
.github/workflows/test-pull-request.yml
.github/workflows/update-dependencies.yml
.github/workflows/update-dependencies-from-metadata.yml
.github/workflows/update-github-config.yml
.gitignore
LICENSE
NOTICE
README.md
go.mod
go.sum
scripts/.util/builders.sh
scripts/.util/git.sh
scripts/.util/print.sh
scripts/.util/tools.json
scripts/.util/tools.sh
scripts/integration.sh
scripts/unit.sh
1 change: 1 addition & 0 deletions .github/.syncignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CODEOWNERS
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
version: 2
updates:
- package-ecosystem: gomod
directory: "/"
schedule:
interval: daily
51 changes: 51 additions & 0 deletions .github/labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
- name: status/possible-priority
description: This issue is ready to work and should be considered as a potential priority
color: F9D0C4
- name: status/prioritized
description: This issue has been triaged and resolving it is a priority
color: BFD4F2
- name: status/blocked
description: This issue has been triaged and resolving it is blocked on some other issue
color: 848978
- name: bug
description: Something isn't working
color: d73a4a
- name: enhancement
description: A new feature or request
color: a2eeef
- name: documentation
description: This issue relates to writing documentation
color: D4C5F9
- name: help wanted
description: Extra attention is needed
color: 008672
- name: semver:major
description: A change requiring a major version bump
color: 6b230e
- name: semver:minor
description: A change requiring a minor version bump
color: cc6749
- name: semver:patch
description: A change requiring a patch version bump
color: f9d0c4
- name: good first issue
description: A good first issue to get started with
color: d3fc03
- name: "failure:release"
description: An issue filed automatically when a release workflow run fails
color: f00a0a
- name: "failure:push"
description: An issue filed automatically when a push buildpackage workflow run fails
color: f00a0a
- name: "failure:update-dependencies"
description: An issue filed automatically when updating buildpack.toml dependencies fails in a workflow
color: f00a0a
- name: "failure:go-get-update"
description: An issue filed automatically when a go get update workflow run fails
color: f00a0a
- name: "failure:update-github-config"
description: An issue filed automatically when a github config update workflow run fails
color: f00a0a
- name: "failure:approve-bot-pr"
description: An issue filed automatically when a PR auto-approve workflow run fails
color: f00a0a
125 changes: 125 additions & 0 deletions .github/workflows/create-draft-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
name: Create or Update Draft Release

on:
push:
branches:
- main
repository_dispatch:
types: [ version-bump ]
workflow_dispatch:
inputs:
version:
description: 'Version of the release to cut (e.g. 1.2.3)'
required: false

concurrency: release

jobs:
unit:
name: Unit Tests
runs-on: ubuntu-22.04
outputs:
builders: ${{ steps.builders.outputs.builders }}
steps:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.20.x
- name: Checkout
uses: actions/checkout@v3
- name: Run Unit Tests
run: ./scripts/unit.sh
- name: Get builders from integration.json
id: builders
run: |
source "${{ github.workspace }}/scripts/.util/builders.sh"
builders="$(util::builders::list "${{ github.workspace }}/integration.json")"
printf "Output: %s\n" "${builders}"
printf "builders=%s\n" "${builders}" >> "$GITHUB_OUTPUT"
integration:
name: Integration Tests
runs-on: ubuntu-22.04
needs: unit
strategy:
matrix:
builder: ${{ fromJSON(needs.unit.outputs.builders) }}
fail-fast: false # don't cancel all test jobs when one fails
steps:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.20.x
- name: Checkout
uses: actions/checkout@v3
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* || true
- name: Run Integration Tests
run: ./scripts/integration.sh --use-token --builder ${{ matrix.builder }}
env:
GIT_TOKEN: ${{ github.token }}

release:
name: Release
runs-on: ubuntu-22.04
needs: integration
steps:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.20.x
- name: Checkout
uses: actions/checkout@v3
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* || true
- name: Reset Draft Release
id: reset
uses: paketo-buildpacks/github-config/actions/release/reset-draft@main
with:
repo: ${{ github.repository }}
token: ${{ github.token }}
- name: Calculate Semver Tag
if: github.event.inputs.version == ''
id: semver
uses: paketo-buildpacks/github-config/actions/tag/calculate-semver@main
with:
repo: ${{ github.repository }}
token: ${{ github.token }}
ref-name: ${{ github.ref_name }}
- name: Set Release Tag
id: tag
run: |
tag="${{ github.event.inputs.version }}"
if [ -z "${tag}" ]; then
tag="${{ steps.semver.outputs.tag }}"
fi
echo "tag=${tag}" >> "$GITHUB_OUTPUT"
- name: Package
run: ./scripts/package.sh --version "${{ steps.tag.outputs.tag }}"
- name: Create Release Notes
id: create-release-notes
uses: paketo-buildpacks/github-config/actions/release/notes@main
with:
repo: ${{ github.repository }}
token: ${{ secrets.NINE_BOT_GITHUB_TOKEN }}
- name: Create Release
uses: paketo-buildpacks/github-config/actions/release/create@main
with:
repo: ${{ github.repository }}
token: ${{ secrets.NINE_BOT_GITHUB_TOKEN }}
tag_name: v${{ steps.tag.outputs.tag }}
target_commitish: ${{ github.sha }}
name: v${{ steps.tag.outputs.tag }}
body: ${{ steps.create-release-notes.outputs.release_body }}
draft: true
assets: |
[
{
"path": "build/buildpack.tgz",
"name": "${{ github.event.repository.name }}-${{ steps.tag.outputs.tag }}.tgz",
"content_type": "application/gzip"
},
{
"path": "build/buildpackage.cnb",
"name": "${{ github.event.repository.name }}-${{ steps.tag.outputs.tag }}.cnb",
"content_type": "application/gzip"
}
]
30 changes: 30 additions & 0 deletions .github/workflows/lint-yaml.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Lint Workflows

on:
pull_request:
paths:
- '.github/**.yml'
- '.github/**.yaml'

jobs:
lintYaml:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3

- name: Checkout github-config
uses: actions/checkout@v3
with:
repository: paketo-buildpacks/github-config
path: github-config

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8

- name: Install yamllint
run: pip install yamllint

- name: Lint YAML files
run: yamllint ./.github -c github-config/.github/.yamllint
28 changes: 28 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Lint

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
golangci:
name: lint
runs-on: ubuntu-22.04
steps:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.20.x

- name: Checkout
uses: actions/checkout@v3

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
args: --timeout 3m0s
52 changes: 52 additions & 0 deletions .github/workflows/push-buildpackage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Push Buildpackage

on:
release:
types:
- published

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
push:
name: Push
runs-on: ubuntu-22.04
steps:

- name: Parse Event
id: event
run: |
FULL_VERSION="$(jq -r '.release.tag_name' "${GITHUB_EVENT_PATH}" | sed s/^v//)"
MINOR_VERSION="$(echo "${FULL_VERSION}" | awk -F '.' '{print $1 "." $2 }')"
MAJOR_VERSION="$(echo "${FULL_VERSION}" | awk -F '.' '{print $1 }')"
echo "tag_full=${FULL_VERSION}" >> "$GITHUB_OUTPUT"
echo "tag_minor=${MINOR_VERSION}" >> "$GITHUB_OUTPUT"
echo "tag_major=${MAJOR_VERSION}" >> "$GITHUB_OUTPUT"
echo "download_url=$(jq -r '.release.assets[] | select(.name | endswith(".cnb")) | .url' "${GITHUB_EVENT_PATH}")" >> "$GITHUB_OUTPUT"
- name: Download
id: download
uses: paketo-buildpacks/github-config/actions/release/download-asset@main
with:
url: ${{ steps.event.outputs.download_url }}
output: "/github/workspace/buildpackage.cnb"
token: ${{ secrets.NINE_BOT_GITHUB_TOKEN }}

- name: Validate version
run: |
buidpackTomlVersion=$(sudo skopeo inspect "oci-archive:${GITHUB_WORKSPACE}/buildpackage.cnb" | jq -r '.Labels."io.buildpacks.buildpackage.metadata" | fromjson | .version')
githubReleaseVersion="${{ steps.event.outputs.tag_full }}"
if [[ "$buidpackTomlVersion" != "$githubReleaseVersion" ]]; then
echo "Version in buildpack.toml ($buidpackTomlVersion) and github release ($githubReleaseVersion) are not identical"
exit 1
fi
- name: Push to GHCR
run: |
sudo skopeo login --username ${{ github.actor }} --password "${{ secrets.GITHUB_TOKEN }}" "${{ env.REGISTRY }}"
sudo skopeo copy "oci-archive:${GITHUB_WORKSPACE}/buildpackage.cnb" "docker://${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.event.outputs.tag_full }}"
sudo skopeo copy "oci-archive:${GITHUB_WORKSPACE}/buildpackage.cnb" "docker://${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.event.outputs.tag_minor }}"
sudo skopeo copy "oci-archive:${GITHUB_WORKSPACE}/buildpackage.cnb" "docker://${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.event.outputs.tag_major }}"
sudo skopeo copy "oci-archive:${GITHUB_WORKSPACE}/buildpackage.cnb" "docker://${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest"
Loading

0 comments on commit 95937dc

Please sign in to comment.