|
| 1 | +# this pipeline should only be executed on master branch |
1 | 2 | version: '1.0'
|
2 | 3 |
|
3 | 4 | steps:
|
4 | 5 |
|
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: |
6 | 25 | title: "Compiling executables"
|
7 |
| - image: node:9.2.0 |
| 26 | + image: codefresh/cli-build |
8 | 27 | commands:
|
| 28 | + - "rm -rf dist" |
9 | 29 | - "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 |
0 commit comments