-
Notifications
You must be signed in to change notification settings - Fork 112
157 lines (146 loc) · 6.49 KB
/
draft-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
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
name: draft-release
on:
workflow_dispatch:
jobs:
draft-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install jq
run: |
mkdir -p deps/bin
curl -s -L -o deps/bin/jq https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64
chmod +x deps/bin/jq
echo "${PWD}/deps/bin" >> $GITHUB_PATH
- name: Derive lifecycle version from branch name
run: |
[[ $GITHUB_REF =~ ^refs\/heads\/release/(.*)$ ]] && version=${BASH_REMATCH[1]}
if [[ -z "${version}" ]]; then
echo "lifecycle version not detected."
exit 1
fi
echo "LIFECYCLE_VERSION=$version" >> $GITHUB_ENV
- name: Determine download urls for linux-x86-64, linux-arm64 and windows
id: artifact-urls
uses: actions/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
return github.actions
.listRepoWorkflows({
owner: "${{ github.repository_owner }}",
repo: "lifecycle",
})
.then(workflows_result => {
let workflows = workflows_result.data.workflows
.filter(a => a.name === "build" && a.state === "active")
.map(a => a.id);
if (workflows.length === 0) {
throw "no active workflows found with name build"
}
return workflows[0]
})
.then(workflow_id => {
return github.actions.listWorkflowRunsForRepo({
owner: "${{ github.repository_owner }}",
repo: "lifecycle",
workflow_id: workflow_id,
branch: "release/${{ env.LIFECYCLE_VERSION }}",
event: "push"
})
})
.then(workflow_runs_result => {
let workflow_runs = workflow_runs_result.data.workflow_runs
.filter(run => run.conclusion === "success")
.filter(run => run.head_sha === "${{ github.sha }}");
if (workflow_runs.length === 0) {
throw "no successful workflow runs found for commit"
}
return workflow_runs[0].id
})
.then(workflow_runid => {
return github.actions.listWorkflowRunArtifacts({
owner: "${{ github.repository_owner }}",
repo: "lifecycle",
run_id: workflow_runid
})
})
.then(artifacts_result => {
let tuples = artifacts_result.data.artifacts
.map(artifact => [artifact.name, artifact.archive_download_url]);
let urlList = new Array();
tuples.forEach(function(tuple) {
if (tuple[0].includes("lifecycle-")) {
urlList.push(tuple[1]);
}
})
if (urlList.length === 0) {
throw "no artifacts found"
}
if (urlList.length != 10) {
throw "there should be exactly ten artifacts"
}
return urlList.join(",")
})
- name: Download artifacts
run: |
mkdir artifacts
echo "ARTIFACTS_PATH=$PWD/artifacts" >> $GITHUB_ENV
urls=$(echo '${{ steps.artifact-urls.outputs.result }}' | jq -r . )
for url in $(echo $urls | tr "," "\n"); do
curl -sL -w 'RESP_CODE:%{response_code}\n' \
--header 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
-o tmp-artifact.zip $url
unzip -d artifacts tmp-artifact.zip
rm tmp-artifact.zip
done
- name: Combine checksums
run: |
cd ${{ env.ARTIFACTS_PATH }}
cat *.sha256 | sort > lifecycle-v${{ env.LIFECYCLE_VERSION }}-checksums.txt
rm *.sha256
- name: Set pre-release kind
if: "contains(env.LIFECYCLE_VERSION, 'rc') || contains(env.LIFECYCLE_VERSION, 'pre')" # e.g., 0.99.0-rc.1
run: |
echo "RELEASE_KIND=pre-release" >> $GITHUB_ENV
- name: Set release kind
if: "!contains(env.LIFECYCLE_VERSION, 'rc') && !contains(env.LIFECYCLE_VERSION, 'pre')"
run: |
echo "RELEASE_KIND=release" >> $GITHUB_ENV
- name: Set release body text
run: |
cat << EOF > body.txt
# lifecycle v${{ env.LIFECYCLE_VERSION }}
Welcome to v${{ env.LIFECYCLE_VERSION }}, a **beta** ${{ env.RELEASE_KIND }} of the Cloud Native Buildpacks Lifecycle.
## Prerequisites
The lifecycle runs as a normal user in a series of unprivileged containers. To export images and cache image layers, it requires access to a Docker daemon **or** Docker registry.
## Install
Extract the .tgz file and copy the lifecycle binaries into a [build stack base image](https://github.com/buildpack/spec/blob/master/platform.md#stacks). The build image can then be orchestrated by a platform implementation such as the [pack CLI](https://github.com/buildpack/pack) or [tekton](https://github.com/tektoncd/catalog/blob/master/task/buildpacks/0.1/README.md).
## Lifecycle Image
An OCI image containing the lifecycle binaries is available at buildpacksio/lifecycle:${{ env.LIFECYCLE_VERSION }}.
EOF
- name: Create Pre Release
if: "contains(env.LIFECYCLE_VERSION, 'rc') || contains(env.LIFECYCLE_VERSION, 'pre')" # e.g., 0.99.0-rc.1
run: |
cd ${{ env.ARTIFACTS_PATH }}
gh release create v${{ env.LIFECYCLE_VERSION }} \
$(ls | sort | paste -sd " " -) \
--draft \
--notes-file ../body.txt \
--prerelease \
--target $GITHUB_REF \
--title "lifecycle v${{ env.LIFECYCLE_VERSION }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
if: "!contains(env.LIFECYCLE_VERSION, 'rc') && !contains(env.LIFECYCLE_VERSION, 'pre')"
run: |
cd ${{ env.ARTIFACTS_PATH }}
gh release create v${{ env.LIFECYCLE_VERSION }} \
$(ls | sort | paste -sd " " -) \
--draft \
--notes-file ../body.txt \
--target $GITHUB_REF \
--title "lifecycle v${{ env.LIFECYCLE_VERSION }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}