forked from codefresh-io/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodefresh-release.yml
More file actions
173 lines (159 loc) · 7.63 KB
/
codefresh-release.yml
File metadata and controls
173 lines (159 loc) · 7.63 KB
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
# this pipeline should only be executed on master branch
version: '1.0'
steps:
main_clone:
title: 'Cloning main repository...'
type: git-clone
repo: codefresh-io/cli
revision: ${{CF_BRANCH}}
git: cf_github
fail_if_not_master:
title: "Validate running on master branch"
image: codefresh/build-cli
commands:
- 'echo This pipeline should be run only on master'
- 'exit 1'
when:
branch:
ignore: [ master ]
extract_version:
title: "Exporting package.json version"
image: codefresh/build-cli
commands:
- 'export PACKAGE_VERSION=$(jq -r ".version" package.json)'
- "echo Current version: $PACKAGE_VERSION"
- "cf_export PACKAGE_VERSION"
# in case the candidate image will not be found the release flow will crash and this means that the build pipelines has failed
push_step:
type: push
title: "Push release image"
image_name: codefresh/cli
tags:
- ${{PACKAGE_VERSION}}
- latest
scale:
push_to_dockerhub:
registry: dockerhub
title: "push to dockerhub"
candidate: codefresh/cli:${{CF_SHORT_REVISION}}
push_to_gcr:
title: "push to gcr"
candidate: gcr.io/codefresh-inc/codefresh/cli:${{CF_SHORT_REVISION}}
push_to_quay:
registry: cf-quay
title: "push to quay.io"
candidate: quay.io/codefresh/cli:${{CF_SHORT_REVISION}}
create_manifest_list:
type: "codefresh-inc/multiarch-manifester"
arguments:
image_name: codefresh/cli
arch_tag_postfixes:
arm64: "${{ARM_TAG_POSTFIX}}"
registries:
- name: 'quay.io'
username: '${{QUAY_USERNAME}}'
password: '${{QUAY_PASSWORD}}'
- name: 'docker.io'
username: '${{DOCKERHUB_USERNAME}}'
password: '${{DOCKERHUB_PASSWORD}}'
- name: 'gcr.io'
path_prefix: codefresh-inc
username: '${{GCR_CODEFRESH_INC_USERNAME}}'
password: '${{GCR_CODEFRESH_INC_PASSWORD}}'
scale:
master_branch_tags:
arguments:
tags:
- ${{PACKAGE_VERSION}}
- latest
generate_comletion:
title: "Generating commands completion tree"
image: codefresh/build-cli
commands:
- "yarn install"
- "yarn generate-completion"
deploy_to_npm:
title: "Publishing To Npm"
type: npm-publish
arguments:
NPM_TOKEN: '${{NPM_TOKEN}}'
DIR: ./cli
compile_executables:
title: "Compiling executables"
image: codefresh/build-cli
commands:
- "rm -rf dist"
- "yarn pkg"
create_release:
title: "Create github release"
image: codefresh/build-cli
fail_fast: false
commands:
- 'curl --fail -X POST -d ''{"tag_name":"v${{PACKAGE_VERSION}}","target_commitish":"${{CF_REVISION}}","name":"Codefresh V${{PACKAGE_VERSION}}"}'' -H "Content-Type: application/json" -H "Authorization: token ${{GITHUB_TOKEN}}" https://api.github.com/repos/codefresh-io/cli/releases'
get_release:
title: "Get github release"
image: codefresh/build-cli
commands:
- "curl --fail https://api.github.com/repos/codefresh-io/cli/releases/tags/v${{PACKAGE_VERSION}}"
- "export GITHUB_RELEASE_ID=$(curl --fail https://api.github.com/repos/codefresh-io/cli/releases/tags/v${{PACKAGE_VERSION}} | jq -r '.id')"
- "echo Github release id: $GITHUB_RELEASE_ID"
- "cf_export GITHUB_RELEASE_ID"
upload_executables:
title: "Upload executables to github release"
image: codefresh/build-cli
commands:
# delete all previous .zip/.gz created files and copy readme and license to ./dist
- "rm -rf *.gz"
- "rm -rf *.zip"
- "cp README.md LICENSE ./dist --force"
# upload linux-x64 asset
- "mv ./dist/codefresh-linux ./dist/codefresh"
- "tar -cf codefresh-v${{PACKAGE_VERSION}}-linux-x64.tar README.md LICENSE -C ./dist ./codefresh "
- "gzip codefresh-v${{PACKAGE_VERSION}}-linux-x64.tar"
- 'curl --fail -X POST -H "Content-Type:application/octet-stream" -H "Authorization: token ${{GITHUB_TOKEN}}" --data-binary @codefresh-v${{PACKAGE_VERSION}}-linux-x64.tar.gz https://uploads.github.com/repos/codefresh-io/cli/releases/${{GITHUB_RELEASE_ID}}/assets?name=codefresh-v${{PACKAGE_VERSION}}-linux-x64.tar.gz'
# upload macos-x64 asset
- "mv ./dist/codefresh-macos ./dist/codefresh"
- "tar -cf codefresh-v${{PACKAGE_VERSION}}-macos-x64.tar README.md LICENSE -C ./dist ./codefresh "
- "gzip codefresh-v${{PACKAGE_VERSION}}-macos-x64.tar"
- 'curl --fail -X POST -H "Content-Type:application/octet-stream" -H "Authorization: token ${{GITHUB_TOKEN}}" --data-binary @codefresh-v${{PACKAGE_VERSION}}-macos-x64.tar.gz https://uploads.github.com/repos/codefresh-io/cli/releases/${{GITHUB_RELEASE_ID}}/assets?name=codefresh-v${{PACKAGE_VERSION}}-macos-x64.tar.gz'
# upload win-x64 asset
- "mv ./dist/codefresh-win.exe ./dist/codefresh.exe"
- "zip codefresh-v${{PACKAGE_VERSION}}-win-x64.zip README.md LICENSE -j ./dist/codefresh.exe "
- 'curl --fail -X POST -H "Content-Type:application/octet-stream" -H "Authorization: token ${{GITHUB_TOKEN}}" --data-binary @codefresh-v${{PACKAGE_VERSION}}-win-x64.zip https://uploads.github.com/repos/codefresh-io/cli/releases/${{GITHUB_RELEASE_ID}}/assets?name=codefresh-v${{PACKAGE_VERSION}}-win-x64.zip'
# upload alpine-x64 asset
- "mv ./dist/codefresh-alpine ./dist/codefresh"
- "tar -cf codefresh-v${{PACKAGE_VERSION}}-alpine-x64.tar README.md LICENSE -C ./dist ./codefresh "
- "gzip codefresh-v${{PACKAGE_VERSION}}-alpine-x64.tar"
- 'curl --fail -X POST -H "Content-Type:application/octet-stream" -H "Authorization: token ${{GITHUB_TOKEN}}" --data-binary @codefresh-v${{PACKAGE_VERSION}}-alpine-x64.tar.gz https://uploads.github.com/repos/codefresh-io/cli/releases/${{GITHUB_RELEASE_ID}}/assets?name=codefresh-v${{PACKAGE_VERSION}}-alpine-x64.tar.gz'
update_documentation:
title: "Update documentation http://cli.codefresh.io"
image: docker:18.01
commands:
- "apk update && apk add git nodejs"
- "npm install"
- "echo cleaning previous public dir and recreating worktree"
- "rm -rf public && git worktree prune && git worktree add -B gh-pages public origin/gh-pages"
- "echo Building public docs"
- "npm run build-public-docs"
- "echo Push new docs to gh-pages detached branch"
- 'git config --global user.email "[email protected]" && git config --global user.name "Automated CI"'
- 'cd public && git add --all && git commit -m "Publish new documentation for version ${{PACKAGE_VERSION}}" && git push https://${{GITHUB_TOKEN}}@github.com/codefresh-io/cli.git'
environment:
- HUGO_VERSION=0.32.0
update_brew_formula:
title: "Updating homebrew formula"
image: codefresh/build-cli
commands:
- VERSION=v${{PACKAGE_VERSION}}
- curl -L https://github.com/codefresh-io/cli/releases/download/$VERSION/codefresh-$VERSION-macos-x64.tar.gz > $VERSION.tar.gz
- echo "compute SHA256 ..."
- SHA256="$(shasum -a 256 ./$VERSION.tar.gz | awk '{print $1}')"
- echo "generate file from template ..."
- sed -e "s/{{ VERSION }}/$VERSION/g" -e "s/{{ SHA256 }}/$SHA256/g" ./brew/template.rb > codefresh.rb
- echo "Updating file in GitHub"
- |
curl -v -i -X PUT -H 'Authorization: token '${{GITHUB_TOKEN}}'' -d "{ \
\"message\": \"update formula version $VERSION\", \
\"content\": \"$(openssl base64 -A -in codefresh.rb)\", \
\"sha\": $(curl -X GET https://api.github.com/repos/codefresh-io/homebrew-cli/contents/Formula/codefresh.rb | jq .sha) \
}" https://api.github.com/repos/codefresh-io/homebrew-cli/contents/Formula/codefresh.rb