Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,21 @@
This packages provides a CLI for interacting with Codefresh <br />
You can also requires this module to be used in node.js and the browser

# Install via npm
# Installation Instructions
## Install from official releases
<a href="https://github.com/codefresh-io/codefresh/releases" target="_blank">Official Releases</a>

## Install via npm
`npm install -g codefresh`

# Install via yarn
## Install via yarn
`yarn global add codefresh`

# Installing bash completions
Run `/usr/local/bin/codefresh completion >> ~/.bashrc`. <br />
If you are on OSX run `/usr/local/bin/codefresh completion >> ~/.bash_profile`

# Creating authentication context
In order to start working with the cli you will need to update the authentication configuration. <br />
You can find your access token through our swagger documentation `https://g.codefresh.io/api/` <br />
Once you have the token create a new context: `codefresh auth create-context first-context --token {TOKEN}`

# Installing bash completions
Run `/usr/local/bin/codefresh completion >> ~/.bashrc`. <br />
If you are on OSX run `/usr/local/bin/codefresh completion >> ~/.bash_profile`
109 changes: 94 additions & 15 deletions codefresh-release.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,101 @@
# this pipeline should only be executed on master branch
version: '1.0'

steps:

build_executables:
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"

compile_executables:
title: "Compiling executables"
image: node:9.2.0
image: codefresh/cli-build
commands:
- "rm -rf dist"
- "yarn install"
- "yarn compile"
- "apt-get update"
- "apt-get install -y zip jq"
- "zip codefresh-linux ./dist/codefresh-linux"
- "zip codefresh-macos ./dist/codefresh-macos"
- "zip codefresh-win ./dist/codefresh-win.exe"
- "curl https://api.github.com/repos/codefresh-io/codefresh/releases/tags/${{CF_BRANCH}} | jq -r '.id' > release-id.txt"
- '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'
- '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'
- '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'


## add to npm
- "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/codefresh/releases'

get_release:
title: "Get github release"
image: codefresh/cli-build
commands:
- "curl --fail https://api.github.com/repos/codefresh-io/codefresh/releases/tags/v${{PACKAGE_VERSION}}"
- "export GITHUB_RELEASE_ID=$(curl --fail https://api.github.com/repos/codefresh-io/codefresh/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:
# upload linux-x64 asset
- "rm -rf codefresh-v${{PACKAGE_VERSION}}-linux-x64.tar"
- "tar -cf codefresh-v${{PACKAGE_VERSION}}-linux-x64.tar README.md LICENSE -C ./dist ./codefresh-linux-x64 "
- "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/codefresh/releases/${{GITHUB_RELEASE_ID}}/assets?name=codefresh-v${{PACKAGE_VERSION}}-linux-x64.tar.gz'
# upload linux-x86 asset
- "rm -rf codefresh-v${{PACKAGE_VERSION}}-linux-x86.tar"
- "tar -cf codefresh-v${{PACKAGE_VERSION}}-linux-x86.tar README.md LICENSE -C ./dist ./codefresh-linux-x86 "
- "gzip codefresh-v${{PACKAGE_VERSION}}-linux-x86.tar"
- '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'
# upload macos-x64 asset
- "rm -rf codefresh-v${{PACKAGE_VERSION}}-macos-x64.tar"
- "tar -cf codefresh-v${{PACKAGE_VERSION}}-macos-x64.tar README.md LICENSE -C ./dist ./codefresh-macos-x64 "
- "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/codefresh/releases/${{GITHUB_RELEASE_ID}}/assets?name=codefresh-v${{PACKAGE_VERSION}}-macos-x64.tar.gz'
# upload macos-x86 asset
- "rm -rf codefresh-v${{PACKAGE_VERSION}}-macos-x86.tar"
- "tar -cf codefresh-v${{PACKAGE_VERSION}}-macos-x86.tar README.md LICENSE -C ./dist ./codefresh-macos-x86 "
- "gzip codefresh-v${{PACKAGE_VERSION}}-macos-x86.tar"
- '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'
# upload win-x64 asset
- "rm -rf codefresh-v${{PACKAGE_VERSION}}-win-x64.zip"
- "zip codefresh-v${{PACKAGE_VERSION}}-win-x64.zip README.md LICENSE -j ./dist/codefresh-win-x64.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/codefresh/releases/${{GITHUB_RELEASE_ID}}/assets?name=codefresh-v${{PACKAGE_VERSION}}-win-x64.zip'
# upload win-x86 asset
- "rm -rf codefresh-v${{PACKAGE_VERSION}}-win-x86.zip"
- "zip codefresh-v${{PACKAGE_VERSION}}-win-x86.zip README.md LICENSE -j ./dist/codefresh-win-x86.exe "
- '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'

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
25 changes: 7 additions & 18 deletions codefresh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,15 @@ steps:
image-name: codefresh/cli
tag: ${{CF_BRANCH}}

push_to_registry:
title: "Pushing image to registry"
push_to_registry_revision:
title: "Pushing image tagged with revision to registry"
type: push
candidate: ${{build_step}}
tag: ${{CF_BRANCH}}
tag: ${{CF_SHORT_REVISION}}
registry: "CFCR"

push_to_registry_latest:
title: "Update dockerhub image latest tag"
push_to_registry_branch:
title: "Pushing image tagged with branch to registry"
type: push
candidate: ${{build_step}}
tag: latest
when:
branch:
only: [ master ]

deploy_to_npm:
title: Publishing To Npm
image: codefresh/npm-publish:master
commands:
- NPM_TOKEN=${{NPM_TOKEN}} npm run ci-publish
when:
branch:
only: [ master ]
tag: ${{CF_BRANCH}}
10 changes: 10 additions & 0 deletions examples/new-pipeline.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: pipeline
name: cool-pipeline
spec:
steps:
eslint:
title: 'Running linting logic'
image: codefresh/node-tester-image:8.8.0
commands:
- yarn eslint
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "codefresh",
"version": "0.3.0",
"version": "0.4.2",
"description": "Codefresh command line utility",
"main": "index.js",
"preferGlobal": true,
"scripts": {
"test": "jest unit.spec.js --coverage",
"eslint": "eslint lib/logic/**",
"ci-publish": "ci-publish",
"compile": "pkg . --out-path ./dist"
"pkg": "pkg . -t node9-macos-x64,node9-macos-x86,node9-linux-x64,node9-linux-x86,node9-win-x64,node9-win-x86 --out-path ./dist"
},
"bin": {
"codefresh": "./lib/interface/cli/index.js"
Expand Down