-
Notifications
You must be signed in to change notification settings - Fork 7
115 lines (96 loc) · 4.03 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: Release Buildpack
on:
workflow_dispatch:
permissions:
contents: write
jobs:
release:
name: Release heroku/ruby
runs-on: ubuntu-20.04 # ubuntu-latest currently resolves to 18.04 which does not have aws-cli 2.x yet
steps:
- id: checkout
name: "Checkout code"
uses: actions/checkout@v3
- id: setup-pack
name: "Setup pack"
uses: buildpacks/github-actions/[email protected]
- name: Install yj
uses: buildpacks/github-actions/[email protected]
- id: install-musl-tools
run: sudo apt-get install musl-tools
- id: install-rust-toolchain
name: "Install Rust toolchain"
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: "x86_64-unknown-linux-musl"
- id: install-libcnb-cargo
name: "Install libcnb-cargo"
uses: actions-rs/[email protected]
with:
crate: libcnb-cargo
version: latest
- id: compile
name: "Compile buildpack"
run: cargo libcnb package --release
working-directory: ./buildpacks/ruby
- id: metadata
name: "Read buildpack metadata"
run: |
export BUILDPACK_PATH="target/buildpack/release/heroku_ruby"
echo "buildpack_path=$BUILDPACK_PATH" >> $GITHUB_ENV
echo "buildpack_id=$(yj -t < $BUILDPACK_PATH/buildpack.toml | jq -r .buildpack.id)" >> $GITHUB_ENV
echo "buildpack_version=$(yj -t < $BUILDPACK_PATH/buildpack.toml | jq -r .buildpack.version)" >> $GITHUB_ENV
echo "buildpack_repo=$(yj -t < $BUILDPACK_PATH/buildpack.toml | jq -r .metadata.release.image.repository)" >> $GITHUB_ENV
echo "buildpack_file=heroku_ruby.cnb" >> $GITHUB_ENV
- id: package-buildpack
name: "Package buildpack"
run: pack buildpack package --path "${{ env.buildpack_path }}" --format file "${{ env.buildpack_file}}"
- id: dockerhub-login
name: "Login to Docker Hub"
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- id: guard-double-publish
name: "Check version is unique on Docker Hub"
run: |
if docker manifest inspect "${{ env.buildpack_repo }}:${{ env.buildpack_version }}" > /dev/null; then
echo "Duplicate version found on dockerhub ${{ env.buildpack_repo }}:${{ env.buildpack_version }}"
exit 1
fi
- id: publish-image
name: "Publish buildpack to image registry"
run: pack buildpack package --path "${{ env.buildpack_path }}" --publish "${{ env.buildpack_repo }}:${{ env.buildpack_version }}"
- id: image-digest
name: "Calculate buildpack image digest"
run: |
echo "buildpack_digest=$(crane digest ${{ env.buildpack_repo }}:${{ env.buildpack_version }})" >> $GITHUB_ENV
- id: add-registry-entry
name: "Request Buildpack Registry Entry"
uses: docker://ghcr.io/buildpacks/actions/registry/request-add-entry:5.0.1
with:
token: ${{ secrets.CNB_REGISTRY_RELEASE_BOT_GITHUB_TOKEN }}
id: ${{ env.buildpack_id }}
version: ${{ env.buildpack_version }}
address: ${{ env.buildpack_repo }}@${{ env.buildpack_digest }}
- id: create_release
name: Create Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.buildpack_id }}_${{ env.buildpack_version }}
release_name: ${{ env.buildpack_id }} ${{ env.buildpack_version }}
body: |
See the [CHANGELOG](./CHANGELOG.md) for details.
draft: false
prerelease: false
- id: upload_package
name: Upload buildpackage to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ env.buildpack_file }}
tag: ${{ env.buildpack_id }}_${{ env.buildpack_version }}
overwrite: true