Skip to content

Commit 0cc5286

Browse files
docs: several improvements
1 parent edb12a1 commit 0cc5286

File tree

1 file changed

+131
-40
lines changed

1 file changed

+131
-40
lines changed

README.md

Lines changed: 131 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,41 +6,161 @@
66

77
> fully automated package/module/image publishing
88
9-
A more lightweight and standalone version of [semantic-release](https://github.com/semantic-release/semantic-release).
9+
This project aims to be an alternative to the original [semantic-release](https://github.com/semantic-release/semantic-release) implementation. Using Go, `semantic-release` can be installed by downloading a single binary and is, therefore, easier to install and does not require Node.js and npm. Furthermore, `semantic-release` has a built-in plugin system that allows to extend and customize its functionality.
10+
11+
### Features
12+
13+
- Automated version and release management
14+
- No external dependencies required
15+
- Runs on Linux, macOS and Windows
16+
- Fully extensible via plugins
17+
- Automated changelog generation
18+
- Supports GitHub, GitLab and git
19+
- Support for maintaining multiple major version releases
1020

1121
## How does it work?
12-
Instead of writing [meaningless commit messages](http://whatthecommit.com/), we can take our time to think about the changes in the codebase and write them down. Following the [AngularJS Commit Message Conventions](https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit) it is then possible to generate a helpful changelog and to derive the next semantic version number from them.
22+
Instead of writing [meaningless commit messages](http://whatthecommit.com/), we can take our time to think about the changes in the codebase and write them down. Following the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification it is then possible to generate a helpful changelog and to derive the next semantic version number from them.
1323

1424
When `semantic-release` is setup it will do that after every successful continuous integration build of your default branch and publish the new version for you. This way no human is directly involved in the release process and your releases are guaranteed to be [unromantic and unsentimental](http://sentimentalversioning.org/).
1525

1626
_Source: [semantic-release/semantic-release#how-does-it-work](https://github.com/semantic-release/semantic-release#how-does-it-work)_
1727

1828
You can enforce semantic commit messages using [a git hook](https://github.com/hazcod/semantic-commit-hook).
1929

20-
2130
## Installation
2231

2332

2433
### Option 1: Use the go-semantic-release GitHub Action ([go-semantic-release/action](https://github.com/go-semantic-release/action))
2534

26-
### Option 2: Install `semantic-release` manually
35+
### Option 2: Install manually
2736

2837
```bash
2938
curl -SL https://get-release.xyz/semantic-release/linux/amd64 -o ./semantic-release && chmod +x ./semantic-release
3039
```
3140

41+
### Option 3: Install via npm
42+
43+
```bash
44+
npm install -g go-semantic-release
45+
```
46+
47+
## Examples
48+
49+
### Releasing a Go application with GitHub Actions
50+
Full example can be found at [go-semantic-release/example-go-application](https://github.com/go-semantic-release/example-go-application).
51+
52+
Example [.github/workflows/ci.yml](https://github.com/go-semantic-release/example-go-application/blob/main/.github/workflows/ci.yml) config:
53+
```yaml
54+
name: CI
55+
on:
56+
push:
57+
branches:
58+
- '**'
59+
pull_request:
60+
branches:
61+
- '**'
62+
jobs:
63+
lint:
64+
runs-on: ubuntu-latest
65+
steps:
66+
- uses: actions/checkout@v3
67+
- uses: actions/setup-go@v3
68+
with:
69+
go-version: 1.19
70+
- uses: golangci/golangci-lint-action@v3
71+
test:
72+
runs-on: ubuntu-latest
73+
needs: lint
74+
steps:
75+
- uses: actions/checkout@v3
76+
- uses: actions/setup-go@v3
77+
with:
78+
go-version: 1.19
79+
- run: go test -v ./...
80+
release:
81+
runs-on: ubuntu-latest
82+
needs: test
83+
permissions:
84+
contents: write
85+
steps:
86+
- uses: actions/checkout@v3
87+
- uses: actions/setup-go@v3
88+
with:
89+
go-version: 1.19
90+
- uses: go-semantic-release/action@v1
91+
with:
92+
hooks: goreleaser
93+
env:
94+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
95+
```
96+
97+
### Example GitLab CI Config
98+
99+
#### GitLab token
100+
It is necessary to create a new Gitlab personal access token with the `api` scope [here](https://gitlab.com/profile/personal_access_tokens).
101+
Ensure the CI variable is protected and masked as the `GITLAB_TOKEN` has a lot of rights. There is an open issue for project specific [tokens](https://gitlab.com/gitlab-org/gitlab/issues/756)
102+
You can set the GitLab token via the `GITLAB_TOKEN` environment variable or the `-token` flag.
103+
104+
.gitlab-ci.yml
105+
```yml
106+
stages:
107+
# other stages
108+
- release
109+
110+
release:
111+
image: registry.gitlab.com/go-semantic-release/semantic-release:latest
112+
stage: release
113+
# Remove this if you want a release created for each push to master
114+
when: manual
115+
only:
116+
- master
117+
script:
118+
- release
119+
```
120+
32121
## Plugin System
33122

34123
Since v2, semantic-release is equipped with a plugin system. The plugins are standalone binaries that use [hashicorp/go-plugin](https://github.com/hashicorp/go-plugin) as a plugin library. `semantic-release` automatically downloads the necessary plugins if they don't exist locally. The plugins are stored in the `.semrel` directory of the current working directory in the following format: `.semrel/<os>_<arch>/<plugin name>/<version>/`. The go-semantic-release plugins registry (https://registry.go-semantic-release.xyz/) is used to resolve plugins and to download the correct binary. With the new [plugin-registry](https://github.com/go-semantic-release/plugin-registry) service the API also supports batch requests to resolve multiple plugins at once and caching of the plugins.
35124

36-
### Plugin Types
125+
### Running semantic-release in an air-gapped environment
126+
As plugins are only downloaded if they do not exist in the `.semrel` folder, it is possible to download the plugins and archive the `.semrel` folder. This way it is possible to run `semantic-release` in an air-gapped environment.
37127

38-
* Commit Analyzer ([Docs](https://pkg.go.dev/github.com/go-semantic-release/semantic-release/v2/pkg/analyzer?tab=doc#CommitAnalyzer), [Example](https://github.com/go-semantic-release/commit-analyzer-cz))
39-
* CI Condition ([Docs](https://pkg.go.dev/github.com/go-semantic-release/semantic-release/v2/pkg/condition?tab=doc#CICondition), [Example](https://github.com/go-semantic-release/condition-github))
40-
* Changelog Generator ([Docs](https://pkg.go.dev/github.com/go-semantic-release/semantic-release/v2/pkg/generator?tab=doc#ChangelogGenerator), [Example](https://github.com/go-semantic-release/changelog-generator-default))
41-
* Provider ([Docs](https://pkg.go.dev/github.com/go-semantic-release/semantic-release/v2/pkg/provider?tab=doc#Provider), [Example](https://github.com/go-semantic-release/provider-github))
42-
* Files Updater ([Docs](https://pkg.go.dev/github.com/go-semantic-release/semantic-release/v2/pkg/updater?tab=doc#FilesUpdater), [Example](https://github.com/go-semantic-release/files-updater-npm))
43-
* Hooks ([Docs](https://pkg.go.dev/github.com/go-semantic-release/semantic-release/v2/pkg/hooks?tab=doc#Hooks), [Example](https://github.com/go-semantic-release/hooks-goreleaser))
128+
```bash
129+
# specify all required plugins and download them
130+
./semantic-release --download-plugins --show-progress --provider github --ci-condition github --hooks goreleaser
131+
# archive the .semrel folder
132+
tar -czvf ./semrel-plugins.tgz .semrel/
133+
134+
# copy the archive to the air-gapped environment
135+
136+
# extract the archive
137+
tar -xzvf ./semrel-plugins.tgz
138+
# run semantic-release
139+
./semantic-release --provider github --condition github --hooks goreleaser
140+
```
141+
142+
### Plugins
143+
144+
* Provider ([Docs](https://pkg.go.dev/github.com/go-semantic-release/semantic-release/v2/pkg/provider?tab=doc#Provider))
145+
* [GitHub](https://github.com/go-semantic-release/provider-github)
146+
* [GitLab](https://github.com/go-semantic-release/provider-gitlab)
147+
* [Git](https://github.com/go-semantic-release/provider-git)
148+
* CI Condition ([Docs](https://pkg.go.dev/github.com/go-semantic-release/semantic-release/v2/pkg/condition?tab=doc#CICondition))
149+
* [GitHub Actions](https://github.com/go-semantic-release/condition-github)
150+
* [GitLab CI](https://github.com/go-semantic-release/condition-gitlab)
151+
* [Bitbucket Pipelines](https://github.com/go-semantic-release/condition-bitbucket)
152+
* [Default](https://github.com/go-semantic-release/condition-default)
153+
* Commit Analyzer ([Docs](https://pkg.go.dev/github.com/go-semantic-release/semantic-release/v2/pkg/analyzer?tab=doc#CommitAnalyzer))
154+
* [Conventional Commits](https://github.com/go-semantic-release/commit-analyzer-cz)
155+
* Changelog Generator ([Docs](https://pkg.go.dev/github.com/go-semantic-release/semantic-release/v2/pkg/generator?tab=doc#ChangelogGenerator))
156+
* [Default](https://github.com/go-semantic-release/changelog-generator-default)
157+
* Hooks ([Docs](https://pkg.go.dev/github.com/go-semantic-release/semantic-release/v2/pkg/hooks?tab=doc#Hooks))
158+
* [GoReleaser](https://github.com/go-semantic-release/hooks-goreleaser)
159+
* [npm-binary-releaser](https://github.com/go-semantic-release/hooks-npm-binary-releaser)
160+
* [plugin-registry-update](https://github.com/go-semantic-release/hooks-plugin-registry-update)
161+
* Files Updater ([Docs](https://pkg.go.dev/github.com/go-semantic-release/semantic-release/v2/pkg/updater?tab=doc#FilesUpdater))
162+
* [npm](https://github.com/go-semantic-release/files-updater-npm)
163+
* [helm](https://github.com/go-semantic-release/files-updater-helm)
44164

45165
### Configuration
46166

@@ -74,35 +194,6 @@ Plugins can be configured using CLI flags or the `.semrelrc` config file. By usi
74194
}
75195
```
76196

77-
## Example GitHub Actions
78-
79-
For examples, look at the [go-semantic-release GitHub Action](https://github.com/go-semantic-release/action).
80-
81-
## Example GitLab CI Config
82-
83-
### GitLab token
84-
It is necessary to create a new Gitlab personal access token with the `api` scope [here](https://gitlab.com/profile/personal_access_tokens).
85-
Ensure the CI variable is protected and masked as the `GITLAB_TOKEN` has a lot of rights. There is an open issue for project specific [tokens](https://gitlab.com/gitlab-org/gitlab/issues/756)
86-
You can set the GitLab token via the `GITLAB_TOKEN` environment variable or the `-token` flag.
87-
88-
.gitlab-ci.yml
89-
```yml
90-
stages:
91-
# other stages
92-
- release
93-
94-
release:
95-
image: registry.gitlab.com/go-semantic-release/semantic-release:latest # Replace this with the current release
96-
stage: release
97-
# Remove this if you want a release created for each push to master
98-
when: manual
99-
only:
100-
- master
101-
script:
102-
- release
103-
```
104-
105-
106197
## Beta release support
107198
Beta release support empowers you to release beta, rc, etc. versions with `semantic-release` (e.g. v2.0.0-beta.1). To enable this feature you need to create a new branch (e.g. beta/v2) and check in a `.semrelrc` file with the following content:
108199
```

0 commit comments

Comments
 (0)