|
| 1 | +name: Release Buildpack |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +permissions: |
| 7 | + contents: write |
| 8 | + |
| 9 | +env: |
| 10 | + BUILDPACK_DOCKER_REPO: docker.io/heroku/buildpack-python |
| 11 | + CARGO_TERM_COLOR: always |
| 12 | + |
| 13 | +jobs: |
| 14 | + # Releases the buildpack to Docker Hub and registers it with the CNB Buildpack Registry. |
| 15 | + # This release process intentionally does not create a .cnb file release for now, since |
| 16 | + # there are currently no use-cases that need it for Python. |
| 17 | + release: |
| 18 | + name: Release heroku/python |
| 19 | + runs-on: ubuntu-latest |
| 20 | + steps: |
| 21 | + # Setup |
| 22 | + - name: Checkout |
| 23 | + uses: actions/checkout@v3 |
| 24 | + - name: Install musl-tools |
| 25 | + run: sudo apt-get install musl-tools --no-install-recommends |
| 26 | + - name: Update Rust toolchain |
| 27 | + run: rustup update |
| 28 | + - name: Install Rust linux-musl target |
| 29 | + run: rustup target add x86_64-unknown-linux-musl |
| 30 | + - name: Rust Cache |
| 31 | + uses: Swatinem/rust-cache@v2.2.1 |
| 32 | + - name: Install libcnb-cargo |
| 33 | + run: cargo install libcnb-cargo |
| 34 | + - name: Install Pack CLI |
| 35 | + uses: buildpacks/github-actions/setup-pack@v5.0.1 |
| 36 | + - name: Install yj and crane |
| 37 | + uses: buildpacks/github-actions/setup-tools@v5.0.1 |
| 38 | + - name: Login to Docker Hub |
| 39 | + uses: docker/login-action@v2 |
| 40 | + with: |
| 41 | + registry: docker.io |
| 42 | + username: ${{ secrets.DOCKER_HUB_USER }} |
| 43 | + password: ${{ secrets.DOCKER_HUB_TOKEN }} |
| 44 | + |
| 45 | + # Build |
| 46 | + - name: Compile the buildpack |
| 47 | + run: cargo libcnb package --release |
| 48 | + |
| 49 | + # Publish |
| 50 | + - name: Read buildpack metadata |
| 51 | + run: | |
| 52 | + echo "buildpack_id=$(yj -t < buildpack.toml | jq -r .buildpack.id)" >> $GITHUB_ENV |
| 53 | + echo "buildpack_version=$(yj -t < buildpack.toml | jq -r .buildpack.version)" >> $GITHUB_ENV |
| 54 | + - name: Check version is unique on Docker Hub |
| 55 | + run: | |
| 56 | + if docker manifest inspect "${{ env.BUILDPACK_DOCKER_REPO }}:${{ env.buildpack_version }}" > /dev/null; then |
| 57 | + echo "Duplicate version found on Docker Hub ${{ env.BUILDPACK_DOCKER_REPO }}:${{ env.buildpack_version }}" |
| 58 | + exit 1 |
| 59 | + fi |
| 60 | + - name: Publish the buildpack to Docker Hub |
| 61 | + run: pack buildpack package --path target/buildpack/release/heroku_python --publish "${{ env.BUILDPACK_DOCKER_REPO }}:${{ env.buildpack_version }}" |
| 62 | + - name: Calculate the buildpack image digest |
| 63 | + run: echo "buildpack_digest=$(crane digest ${{ env.BUILDPACK_DOCKER_REPO }}:${{ env.buildpack_version }})" >> $GITHUB_ENV |
| 64 | + - name: Register the new version with the CNB Buildpack Registry |
| 65 | + uses: docker://ghcr.io/buildpacks/actions/registry/request-add-entry:5.0.1 |
| 66 | + with: |
| 67 | + token: ${{ secrets.CNB_REGISTRY_RELEASE_BOT_GITHUB_TOKEN }} |
| 68 | + id: ${{ env.buildpack_id }} |
| 69 | + version: ${{ env.buildpack_version }} |
| 70 | + address: ${{ env.BUILDPACK_DOCKER_REPO }}@${{ env.buildpack_digest }} |
| 71 | + - name: Create GitHub release |
| 72 | + uses: actions/create-release@v1 |
| 73 | + env: |
| 74 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 75 | + with: |
| 76 | + tag_name: v${{ env.buildpack_version }} |
| 77 | + release_name: v${{ env.buildpack_version }} |
| 78 | + body: | |
| 79 | + See the [CHANGELOG](./CHANGELOG.md) for details. |
| 80 | + draft: false |
0 commit comments