github.com/joselitofilho/goreleaser@v0.155.1-0.20210123221854-e4891856c593/www/docs/quick-start.md (about)

     1  # Quick Start
     2  
     3  In this example we will build, archive and release a sample Go project.
     4  
     5  Create a GitHub repository and add a single main package:
     6  
     7  ```go
     8  // main.go
     9  package main
    10  
    11  func main() {
    12    println("Ba dum, tss!")
    13  }
    14  ```
    15  
    16  Run `goreleaser init` to create an example `.goreleaser.yml` file:
    17  
    18  ```sh
    19  goreleaser init
    20  ```
    21  
    22  You can [customize](/customization/) the generated `.goreleaser.yml` or leave
    23  it as-is, it's up to you. It is best practice to check `.goreleaser.yml` into the source control.
    24  
    25  You can test the configuration at any time by running GoReleaser with a few
    26  extra parameters to not require a version tag, skip publishing to GitHub,
    27  and remove any already-built files:
    28  
    29  ```sh
    30  goreleaser --snapshot --skip-publish --rm-dist
    31  ```
    32  
    33  If you are not using vgo or Go modules, then you will need to comment out the
    34  before hooks in the generated config file or update them to match your setup
    35  accordingly.
    36  
    37  GoReleaser will build the binaries for your app for Windows, Linux and macOS,
    38  both amd64 and i386 architectures. You can customize that by changing the
    39  `builds` section. Check the [documentation](/customization/build) for more information.
    40  
    41  After building the binaries, GoReleaser will create an archive for each OS/Arch
    42  pair into a separate file. You can customize several things by changing
    43  the `archive` section, including releasing only the binaries and not creating
    44  archives at all. Check the [documentation](/customization/archive) for more information.
    45  
    46  You'll need to export either a `GITHUB_TOKEN` **or** `GITLAB_TOKEN` environment variable, which should
    47  contain a valid GitHub token with the `repo` scope or GitLab token with `api` scope.
    48  It will be used to deploy releases to your GitHub/GitLab repository.
    49  You can create a token [here](https://github.com/settings/tokens/new) for GitHub or [here](https://gitlab.com/profile/personal_access_tokens) for GitLab.
    50  
    51  ```sh
    52  export GITHUB_TOKEN="YOUR_GH_TOKEN"
    53  ```
    54  
    55  or
    56  
    57  ```sh
    58  export GITLAB_TOKEN="YOUR_GL_TOKEN"
    59  ```
    60  
    61  GoReleaser will use the latest
    62  [Git tag](https://git-scm.com/book/en/v2/Git-Basics-Tagging) of your repository.
    63  Create a tag and push it to GitHub:
    64  
    65  ```sh
    66  git tag -a v0.1.0 -m "First release"
    67  git push origin v0.1.0
    68  ```
    69  
    70  !!! info
    71      Check if your tag adheres to [semantic versioning](/limitations/semver).
    72  
    73  If you don't want to create a tag yet, you can also run GoReleaser without publishing
    74  based on the latest commit by using the `--snapshot` flag:
    75  
    76  ```sh
    77  goreleaser --snapshot
    78  ```
    79  
    80  Now you can run GoReleaser at the root of your repository:
    81  
    82  ```sh
    83  goreleaser release
    84  ```
    85  
    86  That's all!
    87  
    88  Check your GitHub project's releases page!
    89  
    90  <a href="https://github.com/goreleaser/example/releases">
    91    <figure>
    92      <img src="https://img.carlosbecker.dev/goreleaser-github.png"/>
    93      <figcaption>Example release on GitHub.</figcaption>
    94    </figure>
    95  </a>
    96  
    97  Or, if you released to GitLab, check it out too!
    98  
    99  <a href="https://gitlab.com/goreleaser/example/-/releases">
   100    <figure>
   101      <img src="https://img.carlosbecker.dev/goreleaser-gitlab.png"/>
   102      <figcaption>Example release on GitLab.</figcaption>
   103    </figure>
   104  </a>
   105  
   106  !!! note
   107      Releasing to a private-hosted GitLab CE will only work for version `v11.7+`,
   108      because the release feature was introduced in this
   109      [version](https://docs.gitlab.com/ee/user/project/releases/index.html).
   110  
   111  ## Dry run
   112  
   113  If you want to test everything before doing a release "for real", you can
   114  use the following techniques.
   115  
   116  ### Build-only Mode
   117  
   118  Build command will build the project
   119  
   120  ```sh
   121  goreleaser build
   122  ```
   123  
   124  This can be useful as part of CI pipelines to verify the project builds
   125  without errors for all build targets.
   126  
   127  You can check the other options by running:
   128  
   129  ```sh
   130  goreleaser build --help
   131  ```
   132  
   133  ### Release Flags
   134  
   135  Use the `--skip-publish` flag to skip publishing:
   136  
   137  ```sh
   138  goreleaser release --skip-publish
   139  ```
   140  
   141  You can check the other options by running:
   142  
   143  ```sh
   144  goreleaser --help
   145  ```
   146  
   147  and
   148  
   149  ```sh
   150  goreleaser release --help
   151  ```