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