-
Notifications
You must be signed in to change notification settings - Fork 0
258 lines (201 loc) · 12 KB
/
Copy pathrelease.yml
File metadata and controls
258 lines (201 loc) · 12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
name: Release
on:
push:
branches: [main]
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
tags: true
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23.0'
- name: Find CRLF in shell scripts
run: |
find . -type f -name "*.sh" -exec sed -i 's/\r$//' {} \;
- name: Build auto-commit binary (windows adm64)
run: |
GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -trimpath -o bin/auto-commit-windows-amd64 ./cmd
upx --best --lzma bin/auto-commit-windows-amd64 || true
- name: Build auto-commit binary (linux adm64)
run: |
sudo apt-get update && sudo apt-get install upx -y
GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -trimpath -o bin/auto-commit-linux-amd64 ./cmd
upx --best --lzma bin/auto-commit-linux-amd64 || true
- name: Build auto-commit binary (linux arm64)
run: |
sudo apt-get update && sudo apt-get install upx -y
GOOS=linux GOARCH=arm64 go build -ldflags="-s -w" -trimpath -o bin/auto-commit-linux-arm64 ./cmd
upx --best --lzma bin/auto-commit-linux-arm64 || true
- name: Build auto-commit binary (macOS intel)
run: |
GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -trimpath -o bin/auto-commit-macos-amd64 ./cmd
- name: Build auto-commit binary (macOS Apple Silicon / M1, M2)
run: |
GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w" -trimpath -o bin/auto-commit-macos-arm64 ./cmd
- name: Set up Git
run: |
git config user.name "github-actions"
git config user.email "github-actions@github.com"
- name: Get current date
id: date
run: echo "date=$(date +'%Y/%m/%d')" >> $GITHUB_OUTPUT
- name: Get next version tag
id: version
run: |
latest=$(git tag --sort=-v:refname | grep '^v' | head -n 1)
echo "Последний тег: $latest"
if [ -z "$latest" ]; then
version="v0.1.0"
else
raw_version=${latest#v}
major=$(echo "$raw_version" | cut -d. -f1)
minor=$(echo "$raw_version" | cut -d. -f2)
patch=$(echo "$raw_version" | cut -d. -f3)
bug_count=0
dependencies_count=0
issues=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/issues?state=closed&per_page=100")
bug_count=$(echo "$issues" | jq '[.[] | select(.labels? != null) | select((.labels[]?.name // "") == "bug")] | length')
dependencies_count=$(echo "$issues" | jq '[.[] | select(.labels? != null) | select((.labels[]?.name // "") == "dependencies")] | length')
if [ $bug_count -gt 0 ] || [ $dependencies_count -gt 0 ]; then
patch=$((patch + bug_count + dependencies_count))
fi
minor=$((minor + 1))
version="v$major.$minor.$patch"
fi
echo "version=$version" >> $GITHUB_OUTPUT
- name: Create tag
run: |
git tag ${{ steps.version.outputs.version }}
git push origin ${{ steps.version.outputs.version }}
- name: Generate changelog from merged PRs and closed issues
id: changelog
uses: actions/github-script@v7
with:
script: |
const currentVersion = "${{ steps.version.outputs.version }}";
const { data: releases } = await github.rest.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo,
});
const lastRelease = releases.find(r => !r.prerelease && r.tag_name !== currentVersion);
let since;
if (lastRelease) {
since = new Date(lastRelease.created_at).toISOString();
} else {
since = "1970-01-01T00:00:00Z";
}
const { data: pulls } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: "closed",
sort: "updated",
direction: "desc",
per_page: 100
});
const mergedPRs = pulls.filter(pr => pr.merged_at && pr.merged_at > since);
const prChangelog = mergedPRs.map(pr => `- ${pr.title} (#${pr.number})`).join("\n");
const { data: issues } = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: "closed",
sort: "updated",
direction: "desc",
per_page: 100
});
const closedIssues = issues.filter(issue => !issue.pull_request && new Date(issue.closed_at) > new Date(since));
const labelGroups = {};
closedIssues.forEach(issue => {
if (issue.labels.length === 0) {
if (!labelGroups["Other"]) labelGroups["Other"] = [];
labelGroups["Other"].push(issue);
} else {
issue.labels.forEach(label => {
const name = label.name;
if (!labelGroups[name]) labelGroups[name] = [];
labelGroups[name].push(issue);
});
}
});
let issueChangelogByLabel = "";
const labelTitles = {
new: "## Enhancements",
bug: "## Bug Fixes",
git: "## Git",
Other: "## Other"
};
for (const [label, items] of Object.entries(labelGroups)) {
const title = labelTitles[label] || `## ${label.charAt(0).toUpperCase() + label.slice(1)}`;
const list = items.map(issue => `- ${issue.title} (#${issue.number})`).join("\n");
issueChangelogByLabel += `${title}\n\n${list}\n\n`;
}
core.setOutput("changelog_pr", prChangelog);
core.setOutput("changelog_issues_by_label", issueChangelogByLabel.trim());
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.version.outputs.version }}
name: '${{ steps.version.outputs.version }}'
body: |
## Git auto-commit - automatic commit generation tool
> A new version of git-auto-commit is available `${{ steps.version.outputs.version }}`! A command-line utility that analyzes changes and automatically generates the name of the commit it.
Git Auto-Commit is an extension for the Git version control system designed to automatically generate meaningful and context—sensitive commit messages based on changes made to the codebase. The tool simplifies developers' workflows by allowing them to focus on the content of edits rather than on the formulation of descriptions for commits.
The development is conducted as an open source project and is distributed under the MIT license (or other compatible licensing, depending on the implementation). Git Auto-Commit can be integrated into CI/CD pipelines, hook scripts, or used manually via the command line.
Main features:
- Analysis of changes in the work tree and automatic generation of commit messages in natural language.
- Integration with Git via the `git auto` sub-command or configuration of user aliases.
- Support for templates and configurations for configuring the message structure in accordance with project standards (Conventional Commits, Semantic Commit Messages, etc.).
- Scalability: works both in small projects and in large monorepositories.
### Install
#### If you're on windows
Go to the root of the project and run the command.
```bash
iex ((New-Object Net.WebClient).DownloadString('https://github.com/thefuture-industries/git-auto-commit/blob/main/scripts/install-windows-auto-commit.ps1?raw=true'))
```
#### If you're on linux
Go to the root of the project and run the command.
```bash
curl -fsSL https://github.com/thefuture-industries/git-auto-commit/blob/main/scripts/install-linux-auto-commit.sh?raw=true | bash
```
#### If you're on macOS
Go to the root of the project and run the command.
```bash
echo Y | curl -fsSL https://github.com/thefuture-industries/git-auto-commit/blob/main/scripts/install-macos-auto-commit.sh?raw=true | bash
```
### Setting up
#### Launch
Everything is ready now, after making changes to the code, just run:
```bash
git add .
git auto
git push
```
${{ steps.changelog.outputs.changelog_issues_by_label }}
### Pull Requests
${{ steps.changelog.outputs.changelog_pr }}
[©thefuture-industries](https://github.com/thefuture-industries)
files: |
./bin/auto-commit-windows-amd64
./bin/auto-commit-linux-amd64
./bin/auto-commit-linux-arm64
./bin/auto-commit-macos-amd64
./bin/auto-commit-macos-arm64
./scripts/install-windows-auto-commit.ps1
./scripts/install-linux-auto-commit.sh
./scripts/install-macos-auto-commit.sh
- name: Create new branch for next version
run: |
raw_version="${{ steps.version.outputs.version }}"
raw_version=${raw_version#v}
major=$(echo "$raw_version" | cut -d. -f1)
minor=$(echo "$raw_version" | cut -d. -f2)
next_minor=$((minor + 1))
next_version="v$major.$next_minor.x"
git checkout -b "$next_version"
git push origin "$next_version" || git push origin "$next_version"