Skip to content

Commit

Permalink
Add release flow (#14)
Browse files Browse the repository at this point in the history
* Add release flow

Signed-off-by: zeroalphat <[email protected]>

---------

Signed-off-by: zeroalphat <[email protected]>
  • Loading branch information
zeroalphat authored Nov 13, 2023
1 parent ab536a4 commit 36a2ca4
Show file tree
Hide file tree
Showing 6 changed files with 159 additions and 80 deletions.
30 changes: 30 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
changelog:
exclude:
labels:
- ignore-for-release
- ci
- documentation
- refactoring
- test
categories:
- title: Features
labels:
- enhancement
- title: Bug Fixes
labels:
- bug
- title: Deprecated
labels:
- deprecate
- title: Removed
labels:
- remove
- title: Security
labels:
- security
- title: Dependencies
labels:
- dependencies
- title: Others
labels:
- "*"
30 changes: 15 additions & 15 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@ jobs:
name: Small tests
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
- run: make test
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
- run: make test
e2e:
name: End-to-end tests
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
- run: make setup
working-directory: e2e
- run: make start
working-directory: e2e
- run: make test
working-directory: e2e
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
- run: make setup
working-directory: e2e
- run: make start
working-directory: e2e
- run: make test
working-directory: e2e
49 changes: 49 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Release
on:
push:
tags:
- 'v*'
jobs:
image:
name: Push Container Image
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
with:
platforms: linux/amd64
- uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ inputs.github_token }}
- name: Build necoperf-cli and necoperf-daemon image
run: make docker-build
- name: Push necoperf-cli and necoperf-daemon image
run: |
IMAGE_TAG=${GITHUB_REF#refs/tags/v} # Remove "v" prefix.
docker tag necoperf-cli:dev ghcr.io/cybozu-go/necoperf-cli:$IMAGE_TAG
docker push ghcr.io/cybozu-go/necoperf-cli:$IMAGE_TAG
docker tag necoperf-daemon:dev ghcr.io/cybozu-go/necoperf-daemon:$IMAGE_TAG
docker push ghcr.io/cybozu-go/necoperf-daemon:$IMAGE_TAG
release:
name: Release on GitHub
needs: image
runs-on: ubuntu-22.04
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version-file: 'go.mod'
- name: GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53 changes: 53 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
builds:
- id: necoperf-cli
main: ./cmd/necoperf-cli
binary: necoperf-cli
env:
- CGO_ENABLED=0
goos:
- linux
- darwin
goarch:
- amd64
- arm64
- id: necoperf-daemon
main: ./cmd/necoperf-daemon
binary: necoperf-daemon
env:
- CGO_ENABLED=0
goos:
- linux
- darwin
goarch:
- amd64
- arm64

archives:
- id: necoperf-cli
builds: [necoperf-cli]
name_template: "necoperf-cli_{{ .Tag }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
wrap_in_directory: false
format: tar.gz
files:
- LICENSE

- id: necoperf-daemon
builds: [necoperf-daemon]
name_template: "necoperf-daemon_{{ .Tag }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
wrap_in_directory: false
format: tar.gz
files:
- LICENSE

checksum:
name_template: "checksums.txt"

changelog:
use: github-native

release:
github:
owner: cybozu-go
name: necoperf
prerelease: auto
name_template: "Release {{ .Tag }}"
12 changes: 0 additions & 12 deletions CHANGELOG.md

This file was deleted.

65 changes: 12 additions & 53 deletions docs/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,15 @@ Release procedure

This document describes how to release a new version.

## Versioning

Follow [semantic versioning 2.0.0][semver] to choose the new version number.

## Prepare change log entries

Add notable changes since the last release to [CHANGELOG.md](CHANGELOG.md).
It should look like:

```markdown
(snip)
## [Unreleased]
## Labeling

### Added
- Implement ... (#35)
Release notes are automatically generated based on PRs included in the release.
Those PRs are categorized based on the label assigned to them.
Please refer to `.github/release.yml` for the kind of labels.

### Changed
- Fix a bug in ... (#33)

### Removed
- Deprecated `-option` is removed ... (#39)
## Versioning

(snip)
```
Follow [semantic versioning 2.0.0][semver] to choose the new version number.

## Bump version

Expand All @@ -38,40 +23,14 @@ It should look like:
$ echo $VERSION
```

2. Make a branch to release
2. Add a git tag to the main HEAD, then push it.

```console
$ git neco dev "bump-$VERSION"
git checkout main
git pull
git tag -a -m "Release v$VERSION" "v$VERSION"
git tag -ln | grep $VERSION
git push origin v$VERSION
```

3. Edit `CHANGELOG.md` for the new version ([example][]).
4. Commit the change and push it.

```console
$ git commit -a -m "Bump version to $VERSION"
$ git neco review
```

5. Merge this branch.
6. Add a git tag to the main HEAD, then push it.

```console
# Set VERSION again.
$ VERSION=x.y.z
$ echo $VERSION

$ git checkout main
$ git pull
$ git tag -a -m "Release v$VERSION" "v$VERSION"

# Make sure the release tag exists.
$ git tag -ln | grep $VERSION

$ git push origin "v$VERSION"
```

GitHub actions will build and push artifacts such as container images and
create a new GitHub release.

[semver]: https://semver.org/spec/v2.0.0.html
[example]: https://github.com/cybozu-go/etcdpasswd/commit/77d95384ac6c97e7f48281eaf23cb94f68867f79

0 comments on commit 36a2ca4

Please sign in to comment.