UNPKG

37.5 kBMarkdownView Raw
1<p align="center">
2 <img src="img/logo.svg" width="280">
3 <br />
4</p>
5
6# Craft: Universal Release Tool (And More) <!-- omit in toc -->
7
8[![Travis](https://img.shields.io/travis/getsentry/craft.svg)](https://travis-ci.org/getsentry/craft)
9[![GitHub release](https://img.shields.io/github/release/getsentry/craft.svg)](https://github.com/getsentry/craft/releases/latest)
10[![npm version](https://img.shields.io/npm/v/@sentry/craft.svg)](https://www.npmjs.com/package/@sentry/craft)
11[![license](https://img.shields.io/github/license/getsentry/craft.svg)](https://github.com/getsentry/craft/blob/master/LICENSE)
12
13`craft` is a command line tool that helps to automate and pipeline package releases. It suggests, and
14then enforces a specific workflow for managing release branches, changelogs, artifact publishing, etc.
15
16## Table of Contents <!-- omit in toc -->
17
18- [Installation](#installation)
19- [Usage](#usage)
20- [Caveats](#caveats)
21- [Global Configuration](#global-configuration)
22 - [Environment Files](#environment-files)
23- [Workflow](#workflow)
24 - [`craft prepare`: Preparing a New Release](#craft-prepare-preparing-a-new-release)
25 - [`craft publish`: Publishing the Release](#craft-publish-publishing-the-release)
26 - [Example](#example)
27- [Configuration File: `.craft.yml`](#configuration-file-craftyml)
28 - [GitHub project](#github-project)
29 - [Pre-release Command](#pre-release-command)
30 - [Release Branch Name](#release-branch-name)
31 - [Changelog Policies](#changelog-policies)
32 - [Minimal Version](#minimal-version)
33 - [Required Files](#required-files)
34- [Status Provider](#status-provider)
35- [Artifact Provider](#artifact-provider)
36 - [Using Github Actions with Github Artifact Provider](#using-github-actions-with-github-artifact-provider)
37- [Target Configurations](#target-configurations)
38 - [Per-target options](#per-target-options)
39 - [GitHub (`github`)](#github-github)
40 - [NPM (`npm`)](#npm-npm)
41 - [Python Package Index (`pypi`)](#python-package-index-pypi)
42 - [Homebrew (`brew`)](#homebrew-brew)
43 - [NuGet (`nuget`)](#nuget-nuget)
44 - [Rust Crates (`crates`)](#rust-crates-crates)
45 - [Google Cloud Storage (`gcs`)](#google-cloud-storage-gcs)
46 - [GitHub Pages (`gh-pages`)](#github-pages-gh-pages)
47 - [Sentry Release Registry (`registry`)](#sentry-release-registry-registry)
48 - [Cocoapods (`cocoapods`)](#cocoapods-cocoapods)
49 - [Docker (`docker`)](#docker-docker)
50 - [Ruby Gems Index (`gem`)](#ruby-gems-index-gem)
51- [Integrating Your Project with `craft`](#integrating-your-project-with-craft)
52- [Pre-release (Version-bumping) Script: Conventions](#pre-release-version-bumping-script-conventions)
53- [Development](#development)
54 - [Logging Level](#logging-level)
55 - [Dry-run Mode](#dry-run-mode)
56 - [Sentry Support](#sentry-support)
57 - [Releasing](#releasing)
58
59## Installation
60
61The tool is distributed as an NPM package and can be installed via `npm` or `yarn`:
62
63```bash
64yarn global add @sentry/craft
65
66# Or (not preferred):
67
68npm install -g @sentry/craft
69```
70
71## Usage
72
73```plain
74$ craft -h
75craft <command>
76
77Commands:
78 craft prepare NEW-VERSION 🚢 Prepare a new release branch
79 [aliases: p, prerelease, prepublish, prepare, release]
80 craft publish NEW-VERSION 🛫 Publish artifacts [aliases: pp, publish]
81
82Options:
83 --no-input Suppresses all user prompts [boolean] [default: false]
84 --dry-run Dry run mode: do not perform any real actions
85 [boolean] [default: false]
86 -v, --version Show version number [boolean]
87 -h, --help Show help [boolean]
88```
89
90## Caveats
91
92- When interacting with remote GitHub repositories, `craft` uses by default the
93 "origin" remote. If you have a different setup, set the `CRAFT_REMOTE`
94 environment variable.
95
96## Global Configuration
97
98Global configuration for `craft` can be done either by using environment variables
99or by adding values to a configuration file (see below).
100
101In either case, at least the following two values must be configured in order
102for craft to function properly:
103
104- `GITHUB_API_TOKEN`
105
106 Get your personal GitHub API token here: https://github.com/settings/tokens
107
108 The token only needs "repo" scope ("repo:status" and "public_repo" subscopes, to be even more precise).
109
110- `ZEUS_API_TOKEN`
111
112 You can generate your personal Zeus token here: https://zeus.ci/settings/token
113
114 Required only for `craft publish`.
115
116Additional configuration may be required when publishing to specific
117targets (e.g. `TWINE_USERNAME` and `TWINE_PASSWORD` for PyPI target).
118
119### Environment Files
120
121`craft` will read configuration variables (keys, tokens, etc.) from the
122following locations:
123
124- `$HOME/.craft.env`
125- `$PROJECT_DIR/.craft.env`
126- the shell's environment
127
128...where `$HOME` is the current user's home directory, and `$PROJECT_DIR` is the directory where `.craft.yml` is located.
129
130The above locations will be checked in the order specified above, with values
131found in one location overwriting anything found in previous locations. In other
132words, environment variables will take precedence over either configuration
133file, and the project-specific file will take precedence over the file in
134`$HOME`.
135
136The files must be written in shell (`sh`/`bash`) format. Leading `export` is allowed.
137
138Example:
139
140```sh
141# ~/.craft.env
142GITHUB_API_TOKEN=token123
143export NUGET_API_TOKEN=abcdefgh
144```
145
146## Workflow
147
148### `craft prepare`: Preparing a New Release
149
150This command will create a new release branch, check the changelog entries,
151run a version-bumping script, and push the new branch to GitHub.
152
153```plain
154craft prepare NEW-VERSION
155
156🚢 Prepare a new release branch
157
158Positionals:
159 NEW-VERSION The new version you want to release [string] [required]
160
161Options:
162 --no-input Suppresses all user prompts [boolean] [default: false]
163 --dry-run Dry run mode: do not perform any real actions
164 [boolean] [default: false]
165 --no-push Do not push the release branch [boolean] [default: false]
166 --no-git-checks Ignore local git changes and unsynchronized remotes
167 [boolean] [default: false]
168 --no-changelog Do not check for changelog entries [boolean] [default: false]
169 --publish Run "publish" right after "release"[boolean] [default: false]
170```
171
172### `craft publish`: Publishing the Release
173
174The command will find a release branch for the provided version (tag) and
175publish the existing artifacts from the configured artifact provider to selected targets.
176
177```plain
178craft publish NEW-VERSION
179
180🛫 Publish artifacts
181
182Positionals:
183 NEW-VERSION Version to publish [string] [required]
184
185Options:
186 --no-input Suppresses all user prompts [boolean] [default: false]
187 --dry-run Dry run mode: do not perform any real actions
188 [boolean] [default: false]
189 --target, -t Publish to this target
190 [string] [choices: "brew", "cocoapods", "crates", "gcs", "gh-pages", "github",
191 "npm", "nuget", "pypi", "registry", "all", "none"] [default: "all"]
192 --rev, -r Source revision to publish [string]
193 --no-merge Do not merge the release branch after publishing
194 [boolean] [default: false]
195 --keep-branch Do not remove release branch after merging it
196 [boolean] [default: false]
197 --keep-downloads Keep all downloaded files [boolean] [default: false]
198 --no-status-check Do not check for build status in Zeus
199 [boolean] [default: false]
200```
201
202### Example
203
204Let's imagine we want to release a new version of our package, and the version
205in question is `1.2.3`.
206
207We run `prepare` command first:
208
209`$ craft prepare 1.2.3`
210
211After some basic sanity checks this command creates a new release branch
212`release/1.2.3`, runs the version-bumping script (`scripts/bump-version.sh`),
213commits the changes made by the script, and then pushes the new branch to
214GitHub. At this point CI systems kick in, and the results of those builds, as
215well as built artifacts (binaries, NPM archives, Python wheels) are gradually
216uploaded to Zeus.
217
218To publish the built artifacts we run `publish`:
219
220`$ craft publish 1.2.3`
221
222This command will find our release branch (`release/1.2.3`), check the build
223status of the respective git revision in Zeus, and then publish available
224artifacts to configured targets (for example, to GitHub and NPM in the case of
225Craft).
226
227## Configuration File: `.craft.yml`
228
229Project configuration for `craft` is stored in `.craft.yml` configuration file,
230located in the project root.
231
232### GitHub project
233
234One of the required settings you need to specify is GitHub project parameters. For example:
235
236```yaml
237github:
238 owner: getsentry
239 repo: sentry-javascript
240```
241
242### Pre-release Command
243
244This command will run on your newly created release branch as part of `prepare`
245command. By default, it is set to "bash scripts/bump-version.sh". Please refer
246to [this section](#pre-release-version-bumping-script-conventions) for more details.
247
248```yaml
249preReleaseCommand: bash scripts/bump-version.sh
250```
251
252### Release Branch Name
253
254This overrides the prefix for the release branch name. The full branch name used
255for a release is `{releaseBranchPrefix}/{version}`. The prefix defaults to
256`"release"`.
257
258```yaml
259releaseBranchPrefix: publish
260```
261
262### Changelog Policies
263
264`craft` can help you to maintain change logs for your projects. At the moment,
265`craft` supports two approaches: `simple`, and `auto` to changelog management.
266
267In `simple` mode, `craft prepare` will remind you to add a changelog entry to the
268changelog file (`CHANGELOG.md` by default).
269
270In `auto` mode, `craft prepare` will use the following logic:
271
2721. If there's already an entry for the given version, use that
2732. Else if there is an entry named `Unreleased`, rename that to the given
274 version
2753. Else, create a new section for the version and populate it with a default
276 text: `- No documented changes for this release.`
277
278**Configuration**
279
280| Option | Description |
281| ----------------- | ------------------------------------------------------------------------------------------ |
282| `changelog` | **optional**. Path to the changelog file. Defaults to `CHANGELOG.md` |
283| `changelogPolicy` | **optional**. Changelog management mode (`none`, `simple`, or `auto`). Defaults to `none`. |
284
285**Example (`simple`):**
286
287```yaml
288changelog: CHANGES
289changelogPolicy: simple
290```
291
292**Valid changelog example:**
293
294```text
295## 1.3.5
296
297* Removed something
298
299## 1.3.4
300
301* Added something
302```
303
304**Example (`auto`):**
305
306```yaml
307changelog: CHANGES
308changelogPolicy: auto
309```
310
311**Changelog with staged changes example:**
312
313```text
314## Unreleased
315
316* Removed something
317
318## 1.3.4
319
320* Added something
321```
322
323Additionally, `.craft.yml` is used for listing targets where you want to
324publish your new release.
325
326### Minimal Version
327
328It is possible to specify minimal `craft` version that is required to work with
329your configuration.
330
331**Example:**
332
333```yaml
334minVersion: '0.5.0'
335```
336
337### Required Files
338
339You can provide a list of patterns for files that _have to be_ available before
340proceeding with publishing. In other words, for every pattern in the given list
341there has to be a file present that matches that pattern. This might be helpful
342to ensure that we're not trying to do an incomplete release.
343
344**Example:**
345
346```yaml
347requireNames:
348 - /^sentry-craft.*\.tgz$/
349 - /^gh-pages.zip$/
350```
351
352## Status Provider
353
354You can configure which status providers `craft` will use to check for your build status.
355By default, it will take Zeus but you can also use GitHub directly.
356This is helpful if you don't want to rely on Zeus for asking if you build is green or not.
357
358**Configuration**
359
360| Option | Description |
361| -------- | -------------------------------------------------------------------------------------------------- |
362| `name` | Name of the status provider: either `zeus` (default) or `github` |
363| `config` | In case of `github`: may include `contexts` key that contains a list of required contexts (checks) |
364
365**Example:**
366
367```yaml
368statusProvider:
369 name: github
370 config:
371 contexts:
372 - Travis CI - Branch
373```
374
375## Artifact Provider
376
377You can configure which artifact providers `craft` will use to fetch artifacts from.
378By default, Zeus is used, but in case you don't need use any artifacts in your
379project, you can set it to `none`.
380
381**Configuration**
382
383| Option | Description |
384| ------ | -------------------------------------------------------------------------- |
385| `name` | Name of the artifact provider: can be `zeus` (default), `github` or `none` |
386
387**Example:**
388
389```yaml
390artifactProvider:
391 name: none
392```
393
394### Using Github Actions with Github Artifact Provider
395
396When using Github Action you can use the Github Artifact Provider for managing your release artifacts.
397The way it works is simple, use the official GHA `actions/upload-artifact@v2` action to upload your assets.
398Craft can work with them and use it instead of Zeus.
399Here is an example config (step) of an archive job:
400
401```yaml
402- name: Archive Artifacts
403 uses: actions/upload-artifact@v2
404 with:
405 name: ${{ github.sha }}
406 path: |
407 ${{ github.workspace }}/*.tgz
408 ${{ github.workspace }}/packages/tracing/build/**
409 ${{ github.workspace }}/packages/**/*.tgz
410```
411
412A few important things to note:
413- The name of the artifacts is very important and needs to be `name: ${{ github.sha }}`. Craft uses this as a unique id to fetch the artifacts.
414- Keep in mind that this action maintains the folder structure and zips everything together. Craft will download the zip and recursively walk it to find all assets.
415
416
417## Target Configurations
418
419The configuration specifies which release targets to run for the repository. To
420run more targets, list the target identifiers under the `targets` key in
421`.craft.yml`.
422
423**Example:**
424
425```yaml
426targets:
427 - name: github
428 - name: npm
429```
430
431### Per-target options
432
433The following options can be applied to every target individually:
434
435| Name | Description |
436| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
437| `includeNames` | **optional**. Regular expression: only matched files will be processed by the target. There is one special case that `includeNames` supports, if your build doesn't any artifacts you can write `includeNames: /none/`, this will skip the check for artifacts towards Zeus entirely. |
438| `excludeNames` | **optional**. Regular expression: the matched files will be skipped by the target. Matching is performed after testing for inclusion (via `includeNames`). |
439
440If neither option is included, all artifacts for the release will be processed by the target.
441
442**Example:**
443
444```yaml
445targets:
446 - name: github
447 includeNames: /^.*\.exe$/
448 excludeNames: /^test.exe$/
449```
450
451### GitHub (`github`)
452
453Create a release on Github. If a Markdown changelog is present in the
454repository, this target tries to read the release name and description from the
455changelog. Otherwise, defaults to the tag name and tag's commit message.
456
457If `previewReleases` is set to `true` (which is the default), the release
458created on GitHub will be marked as a pre-release version if the release name
459contains any one of `preview`, `pre`, `rc`, `dev`,`alpha`, `beta`, `unstable`,
460`a`, or `b`.
461
462**Environment**
463
464| Name | Description |
465| ------------------ | ------------------------------------------------------------------ |
466| `GITHUB_API_TOKEN` | Personal GitHub API token (see https://github.com/settings/tokens) |
467
468**Configuration**
469
470| Option | Description |
471| ----------------- | -------------------------------------------------------------------------------------------- |
472| `tagPrefix` | **optional**. Prefix for new git tags (e.g. "v"). Empty by default. |
473| `previewReleases` | **optional**. Automatically detect and create preview releases. `true` by default. |
474| `annotatedTag` | **optional**. Creates an annotated tag, set to false for lightweight tag. `true` by default. |
475
476**Example:**
477
478```yaml
479targets:
480 - name: github
481 tagPrefix: v
482 previewReleases: false
483 annotatedTag: false
484```
485
486### NPM (`npm`)
487
488Releases an NPM package to the public registry. This requires a package tarball
489generated by `npm pack` in the artifacts. The file will be uploaded to the
490registry with `npm publish`, or with `yarn publish` if `npm` is not found. This
491requires NPM to be authenticated with sufficient permissions to publish the package.
492
493**Environment**
494
495The `npm` utility must be installed on the system.
496
497| Name | Description |
498| ------------------- | ------------------------------------------------------------------- |
499| `NPM_BIN` | **optional**. Path to the npm executable. Defaults to `npm` |
500| `YARN_BIN` | **optional**. Path to the yarn executable. Defaults to `yarn` |
501| `CRAFT_NPM_USE_OTP` | **optional**. If set to "1", you will be asked for an OTP (for 2FA) |
502
503**Configuration**
504
505| Option | Description |
506| -------- | -------------------------------------------------------------------------------- |
507| `access` | **optional**. Visibility for scoped packages: `restricted` (default) or `public` |
508
509**Example**
510
511```yaml
512targets:
513 - name: npm
514 access: public
515```
516
517### Python Package Index (`pypi`)
518
519Uploads source dists and wheels to the Python Package Index via [twine](https://pypi.org/project/twine/).
520The source code bundles and/or wheels must be in the release assets.
521
522**Environment**
523
524The `twine` Python package must be installed on the system.
525
526| Name | Description |
527| ---------------- | ----------------------------------------------------- |
528| `TWINE_USERNAME` | User name for PyPI with access rights for the package |
529| `TWINE_PASSWORD` | Password for the PyPI user |
530| `TWINE_BIN` | **optional**. Path to twine. Defaults to `twine` |
531
532**Configuration**
533
534_none_
535
536**Example**
537
538```yaml
539targets:
540 - name: pypi
541```
542
543### Homebrew (`brew`)
544
545Pushes a new or updated homebrew formula to a brew tap repository. The formula
546is committed directly to the master branch of the tap on GitHub, therefore the
547bot needs rights to commit to `master` on that repository. Therefore, formulas
548on `homebrew/core` are not supported, yet.
549
550The tap is configured with the mandatory `tap` parameter in the same format as
551the `brew` utility. A tap `<org>/<name>` will expand to the GitHub repository
552`github.com:<org>/homebrew-<name>`.
553
554The formula contents are given as configuration value and can be interpolated
555with Mustache template syntax (`{{ variable }}`). The interpolation context
556contains the following variables:
557
558- `version`: The new version
559- `revision`: The tag's commit SHA
560- `checksums`: A map containing sha256 checksums for every release asset. Use
561 the full filename to access the sha, e.g. `checksums.MyProgram-x86`
562
563**Environment**
564
565| Name | Description |
566| ------------------ | ------------------------------------------------------------------ |
567| `GITHUB_API_TOKEN` | Personal GitHub API token (seeh ttps://github.com/settings/tokens) |
568
569**Configuration**
570
571| Option | Description |
572| ---------- | ------------------------------------------------------------------ |
573| `tap` | The name of the homebrew tap used to access the GitHub repo |
574| `template` | The template for contents of the formula file (ruby code) |
575| `formula` | **optional**. Name of the formula. Defaults to the repository name |
576| `path` | **optional**. Path to store the formula in. Defaults to `Formula` |
577
578**Example**
579
580```yaml
581targets:
582 - name: brew
583 tap: octocat/tools # Expands to github.com:octocat/homebrew-tools
584 formula: myproject # Creates the file myproject.rb
585 path: HomebrewFormula # Creates the file in HomebrewFormula/
586 template: >
587 class MyProject < Formula
588 desc "This is a test for homebrew formulae"
589 homepage "https://github.com/octocat/my-project"
590 url "https://github.com/octocat/my-project/releases/download/{{version}}/binary-darwin"
591 version "{{version}}"
592 sha256 "{{checksums.binary-darwin}}"
593
594 def install
595 mv "binary-darwin", "myproject"
596 bin.install "myproject"
597 end
598 end
599```
600
601### NuGet (`nuget`)
602
603Uploads packages to [NuGet](https://www.nuget.org/) via [.NET Core](https://github.com/dotnet/core).
604By default, `craft` publishes all packages with `.nupkg` extension.
605
606**Environment**
607
608The `dotnet` tool must be available on the system.
609
610| Name | Description |
611| ------------------ | ---------------------------------------------------------------- |
612| `NUGET_API_TOKEN` | NuGet personal API token (https://www.nuget.org/account/apikeys) |
613| `NUGET_DOTNET_BIN` | **optional**. Path to .NET Core. Defaults to `dotnet` |
614
615**Configuration**
616
617_none_
618
619**Example**
620
621```yaml
622targets:
623 - name: nuget
624```
625
626### Rust Crates (`crates`)
627
628Publishes a single Rust package or entire workspace on the public crate registry
629([crates.io](https://crates.io)). If the workspace contains multiple crates,
630they are published in an order depending on their dependencies.
631
632**Environment**
633
634"cargo" must be installed and configured on the system.
635
636| Name | Description |
637| ----------------- | ------------------------------------------------- |
638| `CRATES_IO_TOKEN` | The access token to the crates.io account |
639| `CARGO_BIN` | **optional**. Path to cargo. Defaults to `cargo`. |
640
641**Configuration**
642
643| Option | Description |
644| ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
645| `noDevDeps` | **optional**. Strips `devDependencies` from crates before publishing. This is useful if a workspace crate uses circular dependencies for docs. Requires [`cargo-hack`](https://github.com/taiki-e/cargo-hack#readme) installed. Defaults to `false`. |
646
647**Example**
648
649```yaml
650targets:
651 - name: crates
652 noDevDeps: false
653```
654
655### Google Cloud Storage (`gcs`)
656
657Uploads artifacts to a bucket in Google Cloud Storage.
658
659The bucket paths (`paths`) can be interpolated using Mustache syntax (`{{ variable }}`). The interpolation context contains the following variables:
660
661- `version`: The new project version
662- `revision`: The SHA revision of the new version
663
664**Environment**
665
666Google Cloud credentials can be provided using either of the following two environment variables.
667
668| Name | Description |
669| ----------------------------- | ------------------------------------------------------------------------ |
670| `CRAFT_GCS_TARGET_CREDS_PATH` | Local filesystem path to Google Cloud credentials (service account file) |
671| `CRAFT_GCS_TARGET_CREDS_JSON` | Full service account file contents, as a JSON string |
672
673If defined, `CRAFT_GCS_TARGET_CREDS_JSON` will be preferred over `CRAFT_GCS_TARGET_CREDS_PATH`.
674
675_Note:_ `CRAFT_GCS_TARGET_CREDS_JSON` and `CRAFT_GCS_TARGET_CREDS_PATH` were formerly called `CRAFT_GCS_CREDENTIALS_JSON` and `CRAFT_GCS_CREDENTIALS_PATH`, respectively. While those names will continue to work for the foreseeable future, you'll receive a warning encouraging you to switch to the new names.
676
677**Configuration**
678
679| Option | Description |
680| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
681| `bucket` | The name of the GCS bucket where artifacts are uploaded. |
682| `paths` | A list of path objects that represent bucket paths. |
683| `paths.path` | Template-aware bucket path, which can contain `{{ version }}` and/or `{{ revision }}`. |
684| `paths.metadata` | **optional** [Metadata](https://cloud.google.com/storage/docs/json_api/v1/objects/insert#request_properties_JSON) for uploaded files. By default, it sets `Cache-Control` to `"public, max-age=300"`. |
685
686**Example**
687
688```yaml
689targets:
690 - name: gcs
691 bucket: bucket-name
692 paths:
693 - path: release/{{version}}/download
694 metadata:
695 cacheControl: `public, max-age=3600`
696 - path: release/{{revision}}/platform/package
697```
698
699### GitHub Pages (`gh-pages`)
700
701Extracts an archive with static assets and pushes them to the specified git
702branch (`gh-pages` by default). Thus, it can be used to publish documentation
703or any other assets to [GitHub Pages](https://pages.github.com/), so they will be later automatically rendered
704by GitHub.
705
706By default, this target will look for an artifact named `gh-pages.zip`, extract it,
707and commit its contents to `gh-pages` branch.
708
709_WARNING!_ The destination branch will be completely overwritten by the contents
710of the archive.
711
712**Environment**
713
714_none_
715
716**Configuration**
717
718| Option | Description |
719| ------------- | --------------------------------------------------------------------------------------- |
720| `branch` | **optional** The name of the branch to push the changes to. `gh-pages` by default. |
721| `githubOwner` | **optional** GitHub project owner, defaults to the value from the global configuration. |
722| `githubRepo` | **optional** GitHub project name, defaults to the value from the global configuration. |
723
724**Example**
725
726```yaml
727targets:
728 - name: gh-pages
729 branch: gh-pages
730```
731
732### Sentry Release Registry (`registry`)
733
734The target will update the Sentry release registry repo(https://github.com/getsentry/sentry-release-registry/) with the latest version of the
735project `craft` is used with. The release registry repository will be checked out
736locally, and then the new version file will be created there, along with the necessary
737symbolic links.
738
739Two package types are supported: "sdk" and "app". Type "sdk" means that the package
740is uploaded to one of the public registries (PyPI, NPM, Nuget, etc.), and that
741the corresponding package directory can be found inside "packages" directory of the
742release regsitry. Type "app" indicates that the package's version files are located
743in "apps" directory of the registry.
744
745**Environment**
746
747_none_
748
749**Configuration**
750
751| Option | Description |
752| ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
753| `type` | Type of the package: can be "sdk" or "app". |
754| `config.canonical` | Canonical name of the package that includes package registry name (e.g. NPM, PyPI) and the full package name. |
755| `urlTemplate` | **optional** URL template that will be used to generate download links for "app" package type. |
756| `linkPrereleases` | **optional** Update package versions even if the release is a preview release, "false" by default. |
757| `checksums` | **optional** A list of checksums that will be computed for matched files (see `includeNames`). Every checksum entry is an object with two attributes: algorithm (one of "sha256", "sha384", and "sha512) and format ("base64" and "hex"). |
758| `onlyIfPresent` | **optional** A file pattern. The target will be executed _only_ when the matched file is found. |
759
760**Example**
761
762```yaml
763targets:
764 - name: registry
765 type: sdk
766 config:
767 canonical: 'npm:@sentry/browser'
768
769 - name: registry
770 type: app
771 urlTemplate: 'https://example.com/{{version}}/{{file}}'
772 config:
773 canonical: 'npm:@sentry/browser'
774 checksums:
775 - algorithm: sha256
776 format: hex
777```
778
779### Cocoapods (`cocoapods`)
780
781Pushes a new podspec to the central cocoapods repository. The Podspec is fetched
782from the Github repository with the revision that is being released. No release
783assets are required for this target.
784
785**Environment**
786
787The `cocoapods` gem must be installed on the system.
788
789| Name | Description |
790| ----------------------- | ----------------------------------------- |
791| `COCOAPODS_TRUNK_TOKEN` | The access token to the cocoapods account |
792| `COCOAPODS_BIN` | **optional**. Path to `pod` executable. |
793
794**Configuration**
795
796| Option | Description |
797| ---------- | ------------------------------------------ |
798| `specPath` | Path to the Podspec file in the repository |
799
800**Example**
801
802```yaml
803targets:
804 - name: cocoapods
805 specPath: MyProject.podspec
806```
807
808### Docker (`docker`)
809
810Pulls an existing source image tagged with the revision SHA, and then pushed it
811to a new target tagged with the released version. No release
812assets are required for this target except for the source image at the provided
813source image location so it would be a good idea to add a status check that
814ensures the source image exists, otherwise `craft publish` will fail at the
815`docker pull` step, causing an interrupted publish. This is an issue for other,
816non-idempotent targets, not for the Docker target.
817
818**Environment**
819
820`docker` executable (or something equivalent) must be installed on the system.
821
822| Name | Description |
823| ----------------- | ------------------------------------------ |
824| `DOCKER_USERNAME` | The username for the Docker registry. |
825| `DOCKER_PASSWORD` | The personal access token for the account. |
826| `DOCKER_BIN` | **optional**. Path to `docker` executable. |
827
828**Configuration**
829
830| Option | Description |
831| -------------- | ------------------------------------------------------------------------ |
832| `source` | Path to the source Docker image to be pulled |
833| `sourceFormat` | Format for the source image name. Default: `{{{source}}}:{{{revision}}}` |
834| `target` | Path to the target Docker image to be pushed |
835| `targetFormat` | Format for the target image name. Default: `{{{target}}}:{{{version}}}` |
836
837**Example**
838
839```yaml
840targets:
841 - name: docker
842 source: us.gcr.io/sentryio/craft
843 target: getsentry/craft
844# Optional but strongly recommended
845statusProvider:
846 name: github
847 config:
848 contexts:
849 - Travis CI - Branch # or whatever builds and pushes your source image
850```
851
852### Ruby Gems Index (`gem`)
853
854Pushes a gem [Ruby Gems](https://rubygems.org).
855It also requires you to be logged in with `gem login`.
856
857**Environment**
858
859`gem` must be installed on the system.
860
861| Name | Description |
862| --------- | --------------------------------------------------------- |
863| `GEM_BIN` | **optional**. Path to "gem" executable. Defaults to `gem` |
864
865**Configuration**
866
867_none_
868
869**Example**
870
871```yaml
872targets:
873 - name: gem
874```
875
876## Integrating Your Project with `craft`
877
878Here is how you can integrate your GitHub project with `craft`:
879
880- Enable your project in Zeus: https://zeus.ci/settings/github/repos
881- Configure your CI systems (Travis, AppVeyor, etc.) to send build artifacts to Zeus
882 - Allow building release branches (their names follow `release/{VERSION}` by
883 default, configurable through `releaseBranchPrefix`)
884 - Add ZEUS_HOOK_BASE as protected to CI environment
885- Add `.craft.yml` configuration file to your project
886 - List there all the targets you want to publish to
887 - Configure additional options (changelog management policy, tag prefix, etc.)
888- Add a [pre-release script](#pre-release-version-bumping-script-conventions) to your project.
889- Get various [configuration tokens](#global-configuration)
890- Start releasing!
891
892## Pre-release (Version-bumping) Script: Conventions
893
894Among other actions, `craft prepare` runs an external project-specific command
895or script that is responsible for version bumping. By default, this script
896should be located at the following path: `scripts/bump-version.sh` (relative
897to the project root). The command can be configured by specifying
898`preReleaseCommand` configuration option in `craft.yml`.
899
900The following requirements are on the script interface and functionality:
901
902- The script must accept at least two arguments. Craft will pass the following
903 values as the last two arguments (in the specified order): the old ("from")
904 version, and the second one is the new ("to") version.
905- The script must replace all relevant occurrences of the old version string
906 with the new one.
907- The script must not commit the changes made.
908- The script must not change the state of the git repository (e.g. changing branches)
909
910**Example**
911
912```bash
913#!/bin/bash
914### Example of a version-bumping script for an NPM project.
915### Located at: scripts/bump-version.sh
916set -eux
917OLD_VERSION="${1}"
918NEW_VERSION="${2}"
919
920# Do not tag and commit changes made by "npm version"
921export npm_config_git_tag_version=false
922npm version "${NEW_VERSION}"
923```
924
925## Development
926
927### Logging Level
928
929Logging level for `craft` can be configured via setting `CRAFT_LOG_LEVEL`
930environment variable.
931
932Accepted values are: `debug`, `success` (default), `info`, `warn`, `error`.
933
934### Dry-run Mode
935
936Dry-run mode can be enabled via setting `DRY_RUN` environment variable to any
937truthy value (any value other than `unset`, `""`, `0`, `false` and `no`).
938
939In dry-run mode no destructive actions will be performed (creating branches,
940pushing tags, committing files, etc.)
941
942### Sentry Support
943
944Errors you encounter while using Craft can be sent to Sentry. To use this feature,
945add `CRAFT_SENTRY_DSN` variable to your environment (or "craft" configuration file) that
946contains a Sentry project's DSN.
947
948For example:
949
950```bash
951export CRAFT_SENTRY_DSN='https://1234@sentry.io/2345'
952```
953
954### Releasing
955
956`craft` obviously uses `craft` for preparing and publishing new releases!