Skip to content

continue work in pre-release (v3) - added script for delete \n\r wind… #23

continue work in pre-release (v3) - added script for delete \n\r wind…

continue work in pre-release (v3) - added script for delete \n\r wind… #23

Workflow file for this run

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"