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
126 lines (113 loc) · 5.92 KB
/
codefresh-release.yml
File metadata and controls
126 lines (113 loc) · 5.92 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
# this pipeline should only be executed on master branch
version: '1.0'
steps:
fail_if_not_master:
title: "Validate running on master branch"
image: codefresh/cli-build
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/cli-build
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_to_registry_version:
title: "Update dockerhub image version tag"
type: push
candidate: r.cfcr.io/codefresh-inc/codefresh/cli:${{CF_SHORT_REVISION}}
image_name: codefresh/cli
tag: ${{PACKAGE_VERSION}}
registry: dockerhub
push_to_registry_latest:
title: "Update dockerhub image latest tag"
type: push
candidate: r.cfcr.io/codefresh-inc/codefresh/cli:${{CF_SHORT_REVISION}}
image_name: codefresh/cli
tag: latest
registry: dockerhub
deploy_to_npm:
title: "Publishing To Npm"
image: codefresh/npm-publish:master
commands:
- NPM_TOKEN=${{NPM_TOKEN}} npm run ci-publish
compile_executables:
title: "Compiling executables"
image: codefresh/cli-build
commands:
- "rm -rf dist"
- "yarn install"
- "yarn pkg"
create_release:
title: "Create github release"
image: codefresh/cli-build
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/cli-build
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/cli-build
commands:
# delete all previous .zip/.gz created files
- "rm -rf *.gz"
- "rm -rf *.zip"
# 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'
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/cli-build
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