github.com/goreleaser/goreleaser@v1.25.1/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  Initialize modules with
    17  ```sh
    18  go mod init main
    19  ```
    20  
    21  Run the [init](/cmd/goreleaser_init/) command to create an example `.goreleaser.yaml` file:
    22  
    23  ```sh
    24  goreleaser init
    25  ```
    26  
    27  Now, lets run a "local-only" release to see if it works using the [release](/cmd/goreleaser_release/) command:
    28  
    29  ```sh
    30  goreleaser release --snapshot --clean
    31  ```
    32  
    33  At this point, you can [customize](/customization/) the generated `.goreleaser.yaml` or leave it as-is, it's up to you.
    34  It is best practice to check `.goreleaser.yaml` into the source control.
    35  
    36  You can verify your `.goreleaser.yaml` is valid by running the [check](/cmd/goreleaser_check/) command:
    37  
    38  ```sh
    39  goreleaser check
    40  ```
    41  
    42  You can also use GoReleaser to [build](/cmd/goreleaser_build/) the binary only for a given GOOS/GOARCH, which is useful for local development:
    43  
    44  ```sh
    45  goreleaser build --single-target
    46  ```
    47  
    48  To release to GitHub, you'll need to export a `GITHUB_TOKEN` environment variable, which should contain a valid GitHub token with the `repo` scope.
    49  It will be used to deploy releases to your GitHub repository.
    50  You can create a new GitHub token [here](https://github.com/settings/tokens/new?scopes=repo,write:packages).
    51  
    52  !!! info
    53      The minimum permissions the `GITHUB_TOKEN` should have to run this are `write:packages`
    54  
    55  ```sh
    56  export GITHUB_TOKEN="YOUR_GH_TOKEN"
    57  ```
    58  
    59  GoReleaser will use the latest [Git tag](https://git-scm.com/book/en/v2/Git-Basics-Tagging) of your repository.
    60  
    61  Now, create a tag and push it to GitHub:
    62  
    63  ```sh
    64  git tag -a v0.1.0 -m "First release"
    65  git push origin v0.1.0
    66  ```
    67  
    68  !!! info
    69      Check if your tag adheres to [semantic versioning](/limitations/semver/).
    70  
    71  !!! info
    72      If you don't want to create a tag yet, you can also run GoReleaser without publishing based on the latest commit by using the `--snapshot` flag:
    73  
    74      ```sh
    75      goreleaser release --snapshot
    76      ```
    77  
    78  Now you can run GoReleaser at the root of your repository:
    79  
    80  ```sh
    81  goreleaser release
    82  ```
    83  
    84  That's all it takes!
    85  
    86  GoReleaser will build the binaries for your app for Windows, Linux and macOS, both amd64 and i386 architectures.
    87  You can customize that by changing the `builds` section. Check the [documentation](/customization/build/) for more information.
    88  
    89  After building the binaries, GoReleaser will create an archive for each OS/Arch pair into a separate file.
    90  You can customize several things by changing the `archive` section, including releasing only the binaries and not creating archives at all.
    91  Check the [documentation](/customization/archive/) for more information.
    92  
    93  Finally, it will create a release on GitHub with all the artifacts.
    94  
    95  Check your GitHub project's releases page!
    96  
    97  <a href="https://github.com/goreleaser/example/releases">
    98    <figure>
    99      <img src="https://img.carlosbecker.dev/goreleaser-github.png"/>
   100      <figcaption>Example release on GitHub.</figcaption>
   101    </figure>
   102  </a>
   103  
   104  ## Dry run
   105  
   106  If you want to test everything before doing a release "for real", you can
   107  use the following techniques.
   108  
   109  ### Build-only Mode
   110  
   111  Build command will build the project
   112  
   113  ```sh
   114  goreleaser build
   115  ```
   116  
   117  This can be useful as part of CI pipelines to verify the project builds
   118  without errors for all build targets.
   119  
   120  You can check the other options by running:
   121  
   122  ```sh
   123  goreleaser build --help
   124  ```
   125  
   126  ### Release Flags
   127  
   128  Use the `--skip=publish` flag to skip publishing:
   129  
   130  ```sh
   131  goreleaser release --skip=publish
   132  ```
   133  
   134  You can check the other options by running:
   135  
   136  ```sh
   137  goreleaser --help
   138  ```
   139  
   140  and
   141  
   142  ```sh
   143  goreleaser release --help
   144  ```