-
Notifications
You must be signed in to change notification settings - Fork 294
227 lines (200 loc) · 7.88 KB
/
build.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
name: build
on:
push:
branches:
- master
- 'release/**'
pull_request:
branches:
- master
- 'release/**'
jobs:
test:
strategy:
fail-fast: false
matrix:
config: [macos, linux, windows-lcow, windows-wcow]
include:
- config: macos
os: macos
runner: macos-latest
no_docker: "true"
pack_bin: pack
- config: linux
os: linux
runner: ubuntu-latest
no_docker: "false"
pack_bin: pack
- config: windows-lcow
os: windows
runner: [self-hosted, windows]
no_docker: "false"
pack_bin: pack.exe
- config: windows-wcow
os: windows
runner: windows-latest
no_docker: "false"
pack_bin: pack.exe
runs-on: ${{ matrix.runner }}
env:
PACK_BIN: ${{ matrix.pack_bin }}
NO_DOCKER: ${{ matrix.no_docker }}
steps:
- uses: actions/checkout@v2
- name: Derive pack version from branch name
run: |
[[ $GITHUB_REF =~ ^refs\/heads\/release/(.*)$ ]] && version=${BASH_REMATCH[1]} || version=0.0.0
echo "::set-env name=PACK_VERSION::$version"
shell: bash
- name: Set up go
uses: actions/setup-go@v2-beta
with:
go-version: '1.13'
- name: Set up go env
run: |
echo "::set-env name=GOPATH::$(go env GOPATH)"
echo "::add-path::$(go env GOPATH)/bin"
- name: Verify
# disabled for windows due to format verification failing
if: matrix.os != 'windows'
run: make verify
- name: Test
env:
TEST_COVERAGE: 1
run: make test
- name: Upload Coverage
uses: codecov/codecov-action@v1
with:
file: ./out/tests/coverage-unit.txt
flags: unit,os_${{ matrix.os }}
fail_ci_if_error: true
- name: Build
run: make build
env:
PACK_BUILD: ${{ github.run_number }}
- uses: actions/upload-artifact@v1
if: matrix.config != 'windows-wcow'
with:
name: pack-${{ matrix.os }}
path: out/${{ env.PACK_BIN }}
release:
if: ${{ startsWith(github.ref, 'refs/heads/release/') }}
needs: test
runs-on: ubuntu-latest
steps:
- name: Derive pack version from branch name
run: |
[[ $GITHUB_REF =~ ^refs\/heads\/release/(.*)$ ]] && version=${BASH_REMATCH[1]}
echo "::set-env name=PACK_VERSION::$version"
shell: bash
- name: Download artifacts - macos
uses: actions/download-artifact@v1
with:
name: pack-macos
- name: Download artifacts - linux
uses: actions/download-artifact@v1
with:
name: pack-linux
- name: Download artifacts - windows
uses: actions/download-artifact@v1
with:
name: pack-windows-lcow
path: pack-windows
- name: Package artifacts - macos
run: |
chmod +x pack-macos/pack
tar -C pack-macos -vzcf pack-macos.tgz pack
- name: Package artifacts - linux
run: |
chmod +x pack-linux/pack
tar -C pack-linux -vzcf pack-linux.tgz pack
- name: Package artifacts - windows
run: zip -j pack-windows.zip pack-windows/pack.exe
- name: Extract lifecycle version
id: lifecycle_version
run: |
LIFECYCLE_VERSION=$(./pack-linux/pack report | grep 'Default Lifecycle Version:' | grep -o '[^ ]*$')
echo "::set-output name=version::$LIFECYCLE_VERSION"
- name: Extract pack help
id: pack_help
# Replacements have to do with multiline output.
# See https://github.saobby.my.eu.orgmunity/t5/GitHub-Actions/set-output-Truncates-Multiline-Strings/m-p/38372/highlight/true#M3322
run: |
PACK_HELP=$(./pack-linux/pack --help)
PACK_HELP="${PACK_HELP//'%'/'%25'}"
PACK_HELP="${PACK_HELP//$'\n'/'%0A'}"
PACK_HELP="${PACK_HELP//$'\r'/'%0D'}"
echo "::set-output name=help::$PACK_HELP"
- name: Create Release
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ env.PACK_VERSION }}
release_name: pack v${{ env.PACK_VERSION }}
draft: true
prerelease: false
body: |
# pack v${{ env.PACK_VERSION }}
> This is a **beta** release of the Cloud Native Buildpack local CLI. This platform implementation should be relatively stable and reliable, but breaking changes in the underlying [specification](https://github.com/buildpack/spec) may be implemented without notice. Note that pack is intended for local image builds, and thus requires a Docker daemon. The [lifecycle](https://github.com/buildpack/lifecycle) should be used directly when building on cloud platforms.
## Prerequisites
- The [Docker daemon](https://www.docker.com/get-started) must be installed on your workstation or accessible over the network.
## Install
#### macOS
If you're on macOS, you can use Homebrew:
```bash
$ brew install buildpacks/tap/pack
```
#### Linux
On Linux you can use the one of the following methods of installation.
##### Arch Linux
- [pack-cli](https://aur.archlinux.org/packages/pack-cli/)
- [pack-cli-bin](https://aur.archlinux.org/packages/pack-cli-bin/)
##### Command
```bash
(export GH=buildpacks/pack; export LATEST=$(curl -s https://api.github.com/repos/$GH/releases/latest | grep -o -E "https://.+?-linux.tgz"); echo "$LATEST"; curl -sSL "$LATEST" | sudo tar -C /usr/local/bin/ --no-same-owner -xzv $(basename $GH))
```
#### Others
Otherwise:
1. Download the `.tgz` or `.zip` file for your platform
2. Extract the `pack` binary
3. (Optional) Add the directory containing `pack` to `PATH`, or copy `pack` to a directory like `/usr/local/bin`
## Run
Run the command `pack`.
You should see the following output
```text
${{ steps.pack_help.outputs.help }}
```
## Info
Builders created with this release of the pack CLI continue to contain [lifecycle v${{ steps.lifecycle_version.outputs.version }}](https://github.com/buildpack/lifecycle/releases/tag/v${{ steps.lifecycle_version.outputs.version }}) by default.
## Features
## Fixes
## Breaking Changes
- name: Upload Release Asset - macos
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./pack-macos.tgz
asset_name: pack-v${{ env.PACK_VERSION }}-macos.tgz
asset_content_type: application/gzip
- name: Upload Release Asset - linux
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./pack-linux.tgz
asset_name: pack-v${{ env.PACK_VERSION }}-linux.tgz
asset_content_type: application/gzip
- name: Upload Release Asset - windows
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./pack-windows.zip
asset_name: pack-v${{ env.PACK_VERSION }}-windows.zip
asset_content_type: application/zip