- name: Build Changelog
id: github_release
uses: https://proxy.ankio.top/dreamncn/release-changelog-builder-action@v4.0.1 # If someone is interested in trying, replace it with https://github.com/dreamncn/release-changelog-builder-action@v4.0.1.
with:
platform: "gitea" # gitea or github, default is github
baseUrl: "https://gitea.ankio.top" # default is https://api.github.com, if your platform is gitea, default is https://gitea.com
commitMode: true
configuration: "configuration.json"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Do not change this
Support for More Platforms
In src/repositories, create a class file, for example, named GitLabRepository and inherit the BaseRepository class.
You must implement these functions:
export class GitLabRepository extends BaseRepository {
get defaultUrl(): string {
return 'https://gitea.com' // Your platform API URL
}
constructor(token: string, url: string | undefined, repositoryPath: string) {
super(token, url, repositoryPath)
this.url = url || this.defaultUrl
// You must initialize your httpclient here.
}
// In this function, you must get the tag release date by the tag name
async fillTagInformation(repositoryPath: string, owner: string, repo: string, tagInfo: TagInfo): Promise<TagInfo> {
// Perform your HTTP request
// Just format your date
tagInfo.date = moment(response.data.commit.created)
// Don't forget the last line
return await this.getTagByCreateTime(repositoryPath, tagInfo)
}
// Get closed PRs within a time range
async getBetweenDates(
owner: string,
repo: string,
fromDate: moment.Moment,
toDate: moment.Moment,
maxPullRequests: number
): Promise<PullRequestInfo[]> {
const mergedPRs: PullRequestInfo[] = []
// Perform your HTTP request
// And create PullRequestInfo objects and push them into mergedPRs
return mergedPRs
}
// Get comparison of remote branches
async getDiffRemote(owner: string, repo: string, base: string, head: string): Promise<DiffInfo> {
// If your platform does not have an API about comparing commits, you can try the functionality in ./src/repositories/GiteaRepository.ts, which uses `git`
return {
changedFiles: changedFilesCount,
additions: additionCount,
deletions: deletionCount,
changes: changeCount,
commits: commitCount,
commitInfo
}
}
// Get pull request for commitHash
async getForCommitHash(owner: string, repo: string, commit_sha: string, maxPullRequests: number): Promise<PullRequestInfo[]> {
const mergedPRs: PullRequestInfo[] = []
// Execute your HTTP request, only selecting the status as 'closed'
// Make sure your hash is the merge_commit_sha
core.debug(`⚠️ No more PRs retrieved by the API. So far fetched: ${mergedPRs.length}`)
return mergedPRs
}
// Get open pull requests
async getOpen(owner: string, repo: string, maxPullRequests: number): Promise<PullRequestInfo[]> {
const openPrs: PullRequestInfo[] = []
// Perform your request
return openPrs
}
// Get all reviews from a PR
async getReviews(owner: string, repo: string, pr: PullRequestInfo): Promise<void> {
// You can use pr.number to get reviews
pr.reviews = prReviews
}
// Get all tags
async getTags(owner: string, repo: string, maxTagsToFetch: number): Promise<TagInfo[]> {
// Perform your HTTP request
// Build an array like this
core.info(`ℹ️ Retrieved ${tagsInfo.length} tags from GitHub API for ${owner}/${repo} (maximum fetch count: ${maxTagsToFetch})`)
return tagsInfo
}
// Your platform URL, not the API URL, such as https://gitea.com or https://github.com
get homeUrl(): string {
return 'https://gitea.com'
}
}
Changes
Usage
Focus on this part only:
Support for More Platforms
In
src/repositories
, create a class file, for example, namedGitLabRepository
and inherit theBaseRepository
class.You must implement these functions:
More information can be found here:
src/repositories/GiteaRepository.ts src/repositories/BaseRepository.ts
Add your class to the src/main.ts file at line 10, as shown below:
Use the
gitlab
platform in the YAML configuration:Tests
Others