ci: improve release automation workflow

- Add a new GitHub Actions workflow for releases that triggers on any tag push, sets up Go environment, caches dependencies, and runs GoReleaser with Gitea token.
- Create a new GoReleaser configuration file that skips the build process, enables changelog generation with sorting, groups commits into categories for changelog, and excludes certain commit messages from the changelog.
- Define Gitea API and download URLs in the GoReleaser configuration.

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu 2024-02-16 10:47:57 +08:00
parent 52993a9e36
commit 7885fb7422
No known key found for this signature in database
2 changed files with 110 additions and 0 deletions

View File

@ -0,0 +1,50 @@
name: release-main
on:
push:
tags:
- "*"
env:
GOPATH: /go_path
GOCACHE: /go_cache
jobs:
release-image:
runs-on: ubuntu-latest
container:
image: catthehacker/ubuntu:act-20.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # all history for all branches and tags
- uses: actions/setup-go@v5
with:
go-version: "^1"
- uses: https://gitea.com/actions/go-hashfiles@v0.0.1
id: hash-go
with:
patterns: |
go.mod
go.sum
- name: cache go
id: cache-go
uses: actions/cache@v4
with:
path: |
/go_path
/go_cache
key: go_path-${{ steps.hash-go.outputs.hash }
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
version: latest
args: release --clean
env:
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GORELEASER_FORCE_TOKEN: "gitea"

60
.goreleaser.yaml Normal file
View File

@ -0,0 +1,60 @@
project_name: go
builds:
- # If true, skip the build.
# Useful for library projects.
# Default is false
skip: true
changelog:
# Set it to true if you wish to skip the changelog generation.
# This may result in an empty release notes on GitHub/GitLab/Gitea.
disable: false
# Changelog generation implementation to use.
#
# Valid options are:
# - `git`: uses `git log`;
# - `github`: uses the compare GitHub API, appending the author login to the changelog.
# - `gitlab`: uses the compare GitLab API, appending the author name and email to the changelog.
# - `github-native`: uses the GitHub release notes generation API, disables the groups feature.
#
# Defaults to `git`.
use: git
# Sorts the changelog by the commit's messages.
# Could either be asc, desc or empty
# Default is empty
sort: asc
# Group commits messages by given regex and title.
# Order value defines the order of the groups.
# Proving no regex means all commits will be grouped under the default group.
# Groups are disabled when using github-native, as it already groups things by itself.
#
# Default is no groups.
groups:
- title: Features
regexp: "^.*feat[(\\w)]*:+.*$"
order: 0
- title: "Bug fixes"
regexp: "^.*fix[(\\w)]*:+.*$"
order: 1
- title: "Enhancements"
regexp: "^.*chore[(\\w)]*:+.*$"
order: 2
- title: Others
order: 999
filters:
# Commit messages matching the regexp listed here will be removed from
# the changelog
# Default is empty
exclude:
- "^docs"
- "CICD"
- typo
gitea_urls:
api: https://gitea.mediatek.inc/api/v1
download: https://gitea.mediatek.inc