diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 0000000..04c2eef --- /dev/null +++ b/.github/release.yml @@ -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: + - "*" diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e898178..7349fd8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -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 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..d189a9f --- /dev/null +++ b/.github/workflows/release.yaml @@ -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 }} diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..e924334 --- /dev/null +++ b/.goreleaser.yaml @@ -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: zeroalphat + name: necoperf-cli + prerelease: auto + name_template: "Release {{ .Tag }}" diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 9115790..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,12 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. -This project adheres to [Semantic Versioning](http://semver.org/). - -## [Unreleased] - -### Added -### Changed -### Removed - -[Unreleased]: https://github.com/cybozu-go/neco-template/compare/4b825dc642cb6eb9a060e54bf8d69288fbee4904...HEAD diff --git a/docs/release.md b/docs/release.md index 5bdd2a8..779a1cc 100644 --- a/docs/release.md +++ b/docs/release.md @@ -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 @@ -38,40 +23,13 @@ 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 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