Skip to content

Commit

Permalink
Merge pull request #35 from suba327777/main
Browse files Browse the repository at this point in the history
Merge main into release
  • Loading branch information
suba327777 authored May 26, 2024
2 parents 348baef + bc54798 commit a3f05df
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 12 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/release-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Create release branch PR

on:
pull_request:
types: [closed]
branches:
- main

jobs:
create-release-pr:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: fetch previous tag
id: pre_tag
run: |
pre_tag=$(gh api repos/${{ github.repository }}/releases/latest | jq -r .tag_name)
echo "pre_tag=$pre_tag" >> $GITHUB_OUTPUT
- name: fetch list of merged PRs since latest release
id: merged_prs
run: |
previous_tag=${{ steps.pre_tag.outputs.pre_tag }}
merged_prs=$(gh api --method POST /repos/{owner}/{repo}/releases/generate-notes -f "tag_name=tmp" -f "target_commitish=main" -f "previous_tag_name=$previous_tag" | jq -r .body)
echo "merged_prs<<EOF" >> $GITHUB_OUTPUT
echo "$merged_prs" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create PR to release branch
run: |
PR_EXISTS=$(gh pr list --head main --base release --state open --json number --jq '.[].number')
merged_prs="${{ steps.merged_prs.outputs.merged_prs }}"
pr_body=$merged_prs
if [ -z "$PR_EXISTS" ]; then
gh pr create --title "Merge main into release" --body "$pr_body" --base release --head main
else
gh pr edit $PR_EXISTS --body "$pr_body"
gh pr comment $PR_EXISTS --body "Additional PRs merged:\n$merged_prs"
fi
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ linters:
- gosimple
- varcheck
- misspell
- lll
- gofumpt
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,26 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- name: Use README.Mountain
uses: suba327777/README.Mountain@main
uses: suba327777/README.Mountain@release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
USERNAME: ${{ github.repository_owner }}
# select theme
THEME: "default"
- name: Diff
id: diff
run: |
git add -N .
git diff --name-only --exit-code
continue-on-error: true
- name: commit & push
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "[μRM] generate svg."
git push
if: steps.diff.outcome == 'failure'
```

## dependency, environments
Expand Down
21 changes: 11 additions & 10 deletions ui/card.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,28 @@ func title(mountainIcon, textColor, username string) string {
return fmt.Sprintf(`
<g>
<g transform="translate(5,8)">%s</g>
<text x="45" y="26" font-size="16" dominant-baseline="middle" text-anchor="start" fill="%s">%s</text>
<text x="45" y="26" font-size="16" dominant-baseline="middle" text-anchor="start" font-weight="bold" fill="%s">%s</text>
</g>
`, mountainIcon, textColor, username)
}

func leftInfo(dailyCommitsMonthCount, endOfMonth, commitsYearCount int, treeIcon, climberIcon, textColor string) string {
func leftInfo(dailyCommitsMonthCount, endOfMonth int, treeIcon, climberIcon, textColor, formatCommitsYearCount string) string {
return fmt.Sprintf(`
<g>
<g>
<g transform="translate(5,75)">%s</g>
<text x="48" y="85" font-size="11" dominant-baseline="middle" text-anchor="start" fill="%s">commit day</text>
<text x="50" y="100" font-size="11" dominant-baseline="middle" text-anchor="start" fill="%s">per month</text>
<text x="125" y="90" font-size="10" dominant-baseline="middle" text-anchor="start" fill="%s">%d/%d</text>
<text x="48" y="85" font-size="11" dominant-baseline="middle" text-anchor="start" font-weight="bold" fill="%s">Commit Day</text>
<text x="50" y="100" font-size="11" dominant-baseline="middle" text-anchor="start" font-weight="bold" fill="%s">Per Month</text>
<text x="133" y="90" font-size="10" dominant-baseline="middle" text-anchor="start" font-weight="bold" fill="%s">%d/%d</text>
</g>
<g>
<g transform="translate(5,140)">%s</g> <text x="40" y="150" font-size="11" dominant-baseline="middle" text-anchor="start" fill="%s">Total Commits</text>
<text x="60" y="165" font-size="11" dominant-baseline="middle" text-anchor="start" fill="%s">(2024)</text>
<text x="130" y="155" font-size="10" dominant-baseline="middle" text-anchor="start" fill="%s">%d</text>
<g transform="translate(5,140)">%s</g> <text x="40" y="150" font-size="11" dominant-baseline="middle" text-anchor="start" font-weight="bold" fill="%s">Total Commits</text>
<text x="60" y="165" font-size="11" dominant-baseline="middle" text-anchor="start" font-weight="bold" fill="%s">(2024)</text>
<text x="140" y="155" font-size="10" dominant-baseline="middle" text-anchor="start" font-weight="bold" fill="%s">%s</text>
</g>
</g>
`, treeIcon, textColor, textColor, textColor, dailyCommitsMonthCount, endOfMonth, climberIcon, textColor, textColor, textColor, commitsYearCount)
`, treeIcon, textColor, textColor, textColor, dailyCommitsMonthCount, endOfMonth, climberIcon, textColor, textColor, textColor, formatCommitsYearCount)
}

func rightInfo(bgColor, borderColor, grass string) string {
Expand All @@ -64,11 +64,12 @@ func GenerateCard(username string, dailyCommitsSince1MonthCount, dailyCommitsMon
climberIcon := changeIconColor(Climber, theme.IconColor)
treeIcon := changeIconColor(Tree, theme.IconColor)
grassMountain := generateMountain(dailyCommitsSince1MonthCount, theme.Name, theme.TriangleMountainColor)
formatCommitsYearCount := formatNumber(commitsYearCount)

svg := startSVG()
svg += rect(theme.BgColor, theme.BorderColor)
svg += title(mountainIcon, theme.TitleColor, username)
svg += leftInfo(dailyCommitsMonthCount, endOfMonth, commitsYearCount, treeIcon, climberIcon, theme.TextColor)
svg += leftInfo(dailyCommitsMonthCount, endOfMonth, treeIcon, climberIcon, theme.TextColor, formatCommitsYearCount)
svg += rightInfo(theme.BgColor, theme.BorderColor, grassMountain)
svg += endSVG()

Expand Down
11 changes: 11 additions & 0 deletions ui/utils.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package ui

import "fmt"

func formatNumber(num int) string {
if num >= 1000 {
return fmt.Sprintf("%.1fk", float64(num)/1000)
} else {
return fmt.Sprintf("%d", num)
}
}

0 comments on commit a3f05df

Please sign in to comment.