Skip to content

Commit 0d520c5

Browse files
New release flow (#52)
1 parent ab16890 commit 0d520c5

File tree

5 files changed

+123
-41
lines changed

5 files changed

+123
-41
lines changed

README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,21 @@
44
This packages provides a CLI for interacting with Codefresh <br />
55
You can also requires this module to be used in node.js and the browser
66

7-
# Install via npm
7+
# Installation Instructions
8+
## Install from official releases
9+
<a href="https://github.com/codefresh-io/codefresh/releases" target="_blank">Official Releases</a>
10+
11+
## Install via npm
812
`npm install -g codefresh`
913

10-
# Install via yarn
14+
## Install via yarn
1115
`yarn global add codefresh`
1216

17+
# Installing bash completions
18+
Run `/usr/local/bin/codefresh completion >> ~/.bashrc`. <br />
19+
If you are on OSX run `/usr/local/bin/codefresh completion >> ~/.bash_profile`
20+
1321
# Creating authentication context
1422
In order to start working with the cli you will need to update the authentication configuration. <br />
1523
You can find your access token through our swagger documentation `https://g.codefresh.io/api/` <br />
1624
Once you have the token create a new context: `codefresh auth create-context first-context --token {TOKEN}`
17-
18-
# Installing bash completions
19-
Run `/usr/local/bin/codefresh completion >> ~/.bashrc`. <br />
20-
If you are on OSX run `/usr/local/bin/codefresh completion >> ~/.bash_profile`

codefresh-release.yml

Lines changed: 94 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,101 @@
1+
# this pipeline should only be executed on master branch
12
version: '1.0'
23

34
steps:
45

5-
build_executables:
6+
fail_if_not_master:
7+
title: "Validate running on master branch"
8+
image: codefresh/cli-build
9+
commands:
10+
- 'echo This pipeline should be run only on master'
11+
- 'exit 1'
12+
when:
13+
branch:
14+
ignore: [ master ]
15+
16+
extract_version:
17+
title: "Exporting package.json version"
18+
image: codefresh/cli-build
19+
commands:
20+
- 'export PACKAGE_VERSION=$(jq -r ".version" package.json)'
21+
- "echo Current version: $PACKAGE_VERSION"
22+
- "cf_export PACKAGE_VERSION"
23+
24+
compile_executables:
625
title: "Compiling executables"
7-
image: node:9.2.0
26+
image: codefresh/cli-build
827
commands:
28+
- "rm -rf dist"
929
- "yarn install"
10-
- "yarn compile"
11-
- "apt-get update"
12-
- "apt-get install -y zip jq"
13-
- "zip codefresh-linux ./dist/codefresh-linux"
14-
- "zip codefresh-macos ./dist/codefresh-macos"
15-
- "zip codefresh-win ./dist/codefresh-win.exe"
16-
- "curl https://api.github.com/repos/codefresh-io/codefresh/releases/tags/${{CF_BRANCH}} | jq -r '.id' > release-id.txt"
17-
- 'curl -X POST -H "Content-Type:application/octet-stream" -H "Authorization: token ${{TOKEN}}" --data-binary @codefresh-macos.zip https://uploads.github.com/repos/codefresh-io/codefresh/releases/$(cat release-id.txt)/assets?name=codefresh-macos.zip'
18-
- 'curl -X POST -H "Content-Type:application/octet-stream" -H "Authorization: token ${{TOKEN}}" --data-binary @codefresh-linux.zip https://uploads.github.com/repos/codefresh-io/codefresh/releases/$(cat release-id.txt)/assets?name=codefresh-linux.zip'
19-
- 'curl -X POST -H "Content-Type:application/octet-stream" -H "Authorization: token ${{TOKEN}}" --data-binary @codefresh-win.zip https://uploads.github.com/repos/codefresh-io/codefresh/releases/$(cat release-id.txt)/assets?name=codefresh-win.zip'
20-
21-
22-
## add to npm
30+
- "yarn pkg"
31+
32+
create_release:
33+
title: "Create github release"
34+
image: codefresh/cli-build
35+
fail_fast: false
36+
commands:
37+
- '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/codefresh/releases'
38+
39+
get_release:
40+
title: "Get github release"
41+
image: codefresh/cli-build
42+
commands:
43+
- "curl --fail https://api.github.com/repos/codefresh-io/codefresh/releases/tags/v${{PACKAGE_VERSION}}"
44+
- "export GITHUB_RELEASE_ID=$(curl --fail https://api.github.com/repos/codefresh-io/codefresh/releases/tags/v${{PACKAGE_VERSION}} | jq -r '.id')"
45+
- "echo Github release id: $GITHUB_RELEASE_ID"
46+
- "cf_export GITHUB_RELEASE_ID"
47+
48+
upload_executables:
49+
title: "Upload executables to github release"
50+
image: codefresh/cli-build
51+
commands:
52+
# upload linux-x64 asset
53+
- "rm -rf codefresh-v${{PACKAGE_VERSION}}-linux-x64.tar"
54+
- "tar -cf codefresh-v${{PACKAGE_VERSION}}-linux-x64.tar README.md LICENSE -C ./dist ./codefresh-linux-x64 "
55+
- "gzip codefresh-v${{PACKAGE_VERSION}}-linux-x64.tar"
56+
- '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/codefresh/releases/${{GITHUB_RELEASE_ID}}/assets?name=codefresh-v${{PACKAGE_VERSION}}-linux-x64.tar.gz'
57+
# upload linux-x86 asset
58+
- "rm -rf codefresh-v${{PACKAGE_VERSION}}-linux-x86.tar"
59+
- "tar -cf codefresh-v${{PACKAGE_VERSION}}-linux-x86.tar README.md LICENSE -C ./dist ./codefresh-linux-x86 "
60+
- "gzip codefresh-v${{PACKAGE_VERSION}}-linux-x86.tar"
61+
- 'curl --fail -X POST -H "Content-Type:application/octet-stream" -H "Authorization: token ${{GITHUB_TOKEN}}" --data-binary @codefresh-v${{PACKAGE_VERSION}}-linux-x86.tar.gz https://uploads.github.com/repos/codefresh-io/codefresh/releases/${{GITHUB_RELEASE_ID}}/assets?name=codefresh-v${{PACKAGE_VERSION}}-linux-x86.tar.gz'
62+
# upload macos-x64 asset
63+
- "rm -rf codefresh-v${{PACKAGE_VERSION}}-macos-x64.tar"
64+
- "tar -cf codefresh-v${{PACKAGE_VERSION}}-macos-x64.tar README.md LICENSE -C ./dist ./codefresh-macos-x64 "
65+
- "gzip codefresh-v${{PACKAGE_VERSION}}-macos-x64.tar"
66+
- '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/codefresh/releases/${{GITHUB_RELEASE_ID}}/assets?name=codefresh-v${{PACKAGE_VERSION}}-macos-x64.tar.gz'
67+
# upload macos-x86 asset
68+
- "rm -rf codefresh-v${{PACKAGE_VERSION}}-macos-x86.tar"
69+
- "tar -cf codefresh-v${{PACKAGE_VERSION}}-macos-x86.tar README.md LICENSE -C ./dist ./codefresh-macos-x86 "
70+
- "gzip codefresh-v${{PACKAGE_VERSION}}-macos-x86.tar"
71+
- 'curl --fail -X POST -H "Content-Type:application/octet-stream" -H "Authorization: token ${{GITHUB_TOKEN}}" --data-binary @codefresh-v${{PACKAGE_VERSION}}-macos-x86.tar.gz https://uploads.github.com/repos/codefresh-io/codefresh/releases/${{GITHUB_RELEASE_ID}}/assets?name=codefresh-v${{PACKAGE_VERSION}}-macos-x86.tar.gz'
72+
# upload win-x64 asset
73+
- "rm -rf codefresh-v${{PACKAGE_VERSION}}-win-x64.zip"
74+
- "zip codefresh-v${{PACKAGE_VERSION}}-win-x64.zip README.md LICENSE -j ./dist/codefresh-win-x64.exe "
75+
- '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/codefresh/releases/${{GITHUB_RELEASE_ID}}/assets?name=codefresh-v${{PACKAGE_VERSION}}-win-x64.zip'
76+
# upload win-x86 asset
77+
- "rm -rf codefresh-v${{PACKAGE_VERSION}}-win-x86.zip"
78+
- "zip codefresh-v${{PACKAGE_VERSION}}-win-x86.zip README.md LICENSE -j ./dist/codefresh-win-x86.exe "
79+
- 'curl --fail -X POST -H "Content-Type:application/octet-stream" -H "Authorization: token ${{GITHUB_TOKEN}}" --data-binary @codefresh-v${{PACKAGE_VERSION}}-win-x86.zip https://uploads.github.com/repos/codefresh-io/codefresh/releases/${{GITHUB_RELEASE_ID}}/assets?name=codefresh-v${{PACKAGE_VERSION}}-win-x86.zip'
80+
81+
push_to_registry_version:
82+
title: "Update dockerhub image version tag"
83+
type: push
84+
candidate: r.cfcr.io/codefresh-inc/codefresh/cli:${{CF_SHORT_REVISION}}
85+
image_name: codefresh/cli
86+
tag: ${{PACKAGE_VERSION}}
87+
registry: dockerhub
88+
89+
push_to_registry_latest:
90+
title: "Update dockerhub image latest tag"
91+
type: push
92+
candidate: r.cfcr.io/codefresh-inc/codefresh/cli:${{CF_SHORT_REVISION}}
93+
image_name: codefresh/cli
94+
tag: latest
95+
registry: dockerhub
96+
97+
deploy_to_npm:
98+
title: "Publishing To Npm"
99+
image: codefresh/npm-publish:master
100+
commands:
101+
- NPM_TOKEN=${{NPM_TOKEN}} npm run ci-publish

codefresh.yml

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,15 @@ steps:
2626
image-name: codefresh/cli
2727
tag: ${{CF_BRANCH}}
2828

29-
push_to_registry:
30-
title: "Pushing image to registry"
29+
push_to_registry_revision:
30+
title: "Pushing image tagged with revision to registry"
3131
type: push
3232
candidate: ${{build_step}}
33-
tag: ${{CF_BRANCH}}
33+
tag: ${{CF_SHORT_REVISION}}
34+
registry: "CFCR"
3435

35-
push_to_registry_latest:
36-
title: "Update dockerhub image latest tag"
36+
push_to_registry_branch:
37+
title: "Pushing image tagged with branch to registry"
3738
type: push
3839
candidate: ${{build_step}}
39-
tag: latest
40-
when:
41-
branch:
42-
only: [ master ]
43-
44-
deploy_to_npm:
45-
title: Publishing To Npm
46-
image: codefresh/npm-publish:master
47-
commands:
48-
- NPM_TOKEN=${{NPM_TOKEN}} npm run ci-publish
49-
when:
50-
branch:
51-
only: [ master ]
40+
tag: ${{CF_BRANCH}}

examples/new-pipeline.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v1
2+
kind: pipeline
3+
name: cool-pipeline
4+
spec:
5+
steps:
6+
eslint:
7+
title: 'Running linting logic'
8+
image: codefresh/node-tester-image:8.8.0
9+
commands:
10+
- yarn eslint

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
22
"name": "codefresh",
3-
"version": "0.3.0",
3+
"version": "0.4.2",
44
"description": "Codefresh command line utility",
55
"main": "index.js",
66
"preferGlobal": true,
77
"scripts": {
88
"test": "jest unit.spec.js --coverage",
99
"eslint": "eslint lib/logic/**",
1010
"ci-publish": "ci-publish",
11-
"compile": "pkg . --out-path ./dist"
11+
"pkg": "pkg . -t node9-macos-x64,node9-macos-x86,node9-linux-x64,node9-linux-x86,node9-win-x64,node9-win-x86 --out-path ./dist"
1212
},
1313
"bin": {
1414
"codefresh": "./lib/interface/cli/index.js"

0 commit comments

Comments
 (0)