Skip to content

Commit

Permalink
Release task and instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
schneems committed Mar 23, 2022
1 parent 75efaff commit 2ab5792
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 0 deletions.
100 changes: 100 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: release

# Allow the action to be triggered manually in the "actions"
# tab of GitHub.
on:
workflow_dispatch

jobs:
release:
name: Package, Publish, and Register
runs-on:
- ubuntu-latest
steps:
# Needed to get the buildpack code
- name: Checkout
uses: actions/checkout@v3

# Install musl gcc needed to compile rust buildpack
# to linux musl target
- name: Install musl-tools
run: sudo apt-get install musl-tools --no-install-recommends

# Get the `pack` command for packaging the buildpack
- id: setup-pack
name: Install Pack
uses: buildpacks/github-actions/setup-pack@v4.6.0

# Used by `pack buildpack package --publish`. The buildpack
# will be published to this user and password
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
registry: docker.io
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_PASS }}

# Most of the time this will be a no-op, since GitHub releases new images every week
# which include the latest stable release of Rust, Rustup, Clippy and rustfmt.
- name: Update Rust toolchain
run: rustup update
- name: Rust Cache
uses: Swatinem/rust-cache@v1.3.0

# Needed to get `cargo libcnb package` command
- name: Install libcnb plugin
run: cargo install libcnb-cargo
# Configure Rust so it knows how to compile to the linux musl target
- name: Install Rust linux-musl target
run: rustup target add x86_64-unknown-linux-musl
# Compile the rust buildpack
- id: package-libcnb-rs
run: cargo libcnb package --release

# Pull out data from the buildpacks `buildpack.toml` to make
# it available to other commands. Also package and publish
# the buildpack to docker hub as well as generate a local
# file containing the buildpack.
- id: package
run: |
#!/usr/bin/env bash
set -euo pipefail
BP_ID="$(cat buildpack.toml | yj -t | jq -r .buildpack.id)"
VERSION="$(cat buildpack.toml | yj -t | jq -r .buildpack.version)"
ESCAPED_ID="$(echo "$BP_ID" | sed 's/\//_/g')"
PACKAGE="${REPO}"
# --publish pushes to the registry (logged in)
pack buildpack package --publish --path "target/buildpack/release/$ESCAPED_ID" "${PACKAGE}:${VERSION}"
pack buildpack package --format file --path "target/buildpack/release/$ESCAPED_ID" "${ESCAPED_ID}_${VERSION}.cnb"
DIGEST="$(crane digest ${PACKAGE}:${VERSION})"
echo "::set-output name=bp_id::$BP_ID"
echo "::set-output name=version::$VERSION"
echo "::set-output name=address::${PACKAGE}@${DIGEST}"
echo "::set-output name=package::${ESCAPED_ID}_${VERSION}.cnb"
env:
REPO: docker.io/heroku/procfile-cnb

# Open a PR to the buildpack registry index.
# For example: https://github.com/buildpacks/registry-index/issues/2776
- id: register
uses: docker://ghcr.io/buildpacks/actions/registry/request-add-entry:4.2.0
with:
token: ${{ secrets.PUBLIC_REPO_TOKEN }}
id: ${{ steps.package.outputs.bp_id }}
version: ${{ steps.package.outputs.version }}
address: ${{ steps.package.outputs.address }}

# Create a release and tag on the github repo
# For example: https://github.com/heroku/procfile-cnb/releases/tag/0.7.1
# Attaches the previously generate cloud native buildpack file (`*.cnb`)
# to the release
- id: release
name: Upload buildpackage to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ steps.package.outputs.package }}
tag: ${{ steps.package.outputs.version }}
overwrite: true
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,23 @@ This is a [Cloud Native Buildpack](https://buildpacks.io/) that replicates the b

It is written in Rust using the Cloud Native Buildpack framework [libcnb.rs](https://github.com/Malax/libcnb.rs).

## Deployment

### 1) Generate a release

- Visit the actions page https://github.com/heroku/procfile-cnb/actions,
- Click on "release" and then "Run workflow".

When the action is successful a release will be added to https://github.com/heroku/procfile-cnb/releases and docker hub https://hub.docker.com/r/heroku/procfile-cnb/tags.

### 2) Update pack images

- Clone https://github.com/heroku/pack-images
- Edit the `uri` in all builder-*.toml files to point at the latest docker hub release for `heroku/procfile` under `buildpacks`.
- Edit the `version` in all builder-*.toml files to the latest version of `heroku/procfile` for each `order.group`.
- Commit and make a PR to pack images
- Fix any CI errors and merge on success

## Development

### Prerequisites
Expand Down

0 comments on commit 2ab5792

Please sign in to comment.