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

Use the shared GitHub Actions workflows for buildpack releases #58

Merged
merged 12 commits into from
Aug 2, 2023
23 changes: 23 additions & 0 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Prepare Buildpack Releases
edmorley marked this conversation as resolved.
Show resolved Hide resolved

on:
workflow_dispatch:
inputs:
bump:
description: "Bump"
required: true
default: 'patch'
edmorley marked this conversation as resolved.
Show resolved Hide resolved
type: choice
options:
- major
- minor
- patch

jobs:
prepare-release:
uses: heroku/languages-github-actions/.github/workflows/_buildpacks-prepare-release.yml@main
with:
bump: ${{ inputs.bump }}
app_id: ${{ vars.LINGUIST_GH_APP_ID }}
secrets:
app_private_key: ${{ secrets.LINGUIST_GH_PRIVATE_KEY }}
84 changes: 10 additions & 74 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,80 +1,16 @@
name: Release Buildpack
name: Release Buildpacks
edmorley marked this conversation as resolved.
Show resolved Hide resolved

on:
workflow_dispatch:

permissions:
contents: write

env:
BUILDPACK_DOCKER_REPO: docker.io/heroku/buildpack-python
CARGO_TERM_COLOR: always
edmorley marked this conversation as resolved.
Show resolved Hide resolved

jobs:
# Releases the buildpack to Docker Hub and registers it with the CNB Buildpack Registry.
# This release process intentionally does not create a .cnb file release for now, since
# there are currently no use-cases that need it for Python.
release:
name: Release heroku/python
runs-on: pub-hk-ubuntu-22.04-large
steps:
# Setup
- name: Checkout
uses: actions/checkout@v3
- name: Install musl-tools
run: sudo apt-get install musl-tools --no-install-recommends
- name: Update Rust toolchain
run: rustup update
- name: Install Rust linux-musl target
run: rustup target add x86_64-unknown-linux-musl
- name: Rust Cache
uses: Swatinem/rust-cache@v2.5.1
- name: Install libcnb-cargo
run: cargo install libcnb-cargo
- name: Install Pack CLI
uses: buildpacks/github-actions/setup-pack@v5.3.0
- name: Install yj and crane
uses: buildpacks/github-actions/setup-tools@v5.3.0
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
registry: docker.io
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}

# Build
- name: Compile the buildpack
run: cargo libcnb package --release

# Publish
- name: Read buildpack metadata
run: |
echo "buildpack_id=$(yj -t < buildpack.toml | jq -r .buildpack.id)" >> $GITHUB_ENV
echo "buildpack_version=$(yj -t < buildpack.toml | jq -r .buildpack.version)" >> $GITHUB_ENV
- name: Check version is unique on Docker Hub
run: |
if docker manifest inspect "${{ env.BUILDPACK_DOCKER_REPO }}:${{ env.buildpack_version }}" > /dev/null; then
echo "Duplicate version found on Docker Hub ${{ env.BUILDPACK_DOCKER_REPO }}:${{ env.buildpack_version }}"
exit 1
fi
- name: Publish the buildpack to Docker Hub
run: pack buildpack package --path target/buildpack/release/heroku_python --publish "${{ env.BUILDPACK_DOCKER_REPO }}:${{ env.buildpack_version }}"
- name: Calculate the buildpack image digest
run: echo "buildpack_digest=$(crane digest ${{ env.BUILDPACK_DOCKER_REPO }}:${{ env.buildpack_version }})" >> $GITHUB_ENV
- name: Register the new version with the CNB Buildpack Registry
uses: docker://ghcr.io/buildpacks/actions/registry/request-add-entry:5.2.0
with:
token: ${{ secrets.CNB_REGISTRY_RELEASE_BOT_GITHUB_TOKEN }}
id: ${{ env.buildpack_id }}
version: ${{ env.buildpack_version }}
address: ${{ env.BUILDPACK_DOCKER_REPO }}@${{ env.buildpack_digest }}
- name: Create GitHub release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ env.buildpack_version }}
release_name: v${{ env.buildpack_version }}
body: |
See the [CHANGELOG](./CHANGELOG.md) for details.
draft: false
name: Release
uses: heroku/languages-github-actions/.github/workflows/_buildpacks-release.yml@main
with:
app_id: ${{ vars.LINGUIST_GH_APP_ID }}
secrets:
app_private_key: ${{ secrets.LINGUIST_GH_PRIVATE_KEY }}
cnb_registry_token: ${{ secrets.CNB_REGISTRY_RELEASE_BOT_GITHUB_TOKEN }}
docker_hub_user: ${{ secrets.DOCKER_HUB_USER }}
docker_hub_token: ${{ secrets.DOCKER_HUB_TOKEN }}
5 changes: 5 additions & 0 deletions buildpack.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ id = "heroku-20"

[[stacks]]
id = "heroku-22"

[metadata]
[metadata.release]
[metadata.release.image]
repository = "docker.io/heroku/buildpack-python"
edmorley marked this conversation as resolved.
Show resolved Hide resolved