-
Notifications
You must be signed in to change notification settings - Fork 28
124 lines (109 loc) · 3.45 KB
/
merge-post.yml
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
name: Post Merge
on:
pull_request:
types: [closed]
push:
tags:
- v*
branches:
- main
permissions:
contents: write
issues: write
jobs:
sync-version:
name: Sync Version
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
branch: main
fetch-depth: 0
ssh-key: "${{ secrets.COMMIT_KEY }}"
fetch-tags: true
- name: Update Version
run: |
# Get tag without 'v' prefix
TAG_VERSION=${GITHUB_REF#refs/tags/v}
# Checkout main branch
git fetch origin main
git checkout main
# Update version in .cz.toml
sed -i "s/^version = \".*\"/version = \"$TAG_VERSION\"/" .cz.toml
# Configure git
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
# Commit and push if there are changes
if git diff --quiet; then
echo "Version already synchronized"
else
git add .cz.toml
git commit -m "chore: sync version to ${TAG_VERSION} [skip ci]"
git push origin main
fi
bump-version:
name: Cz Bump
if: |
github.event.pull_request.merged == true &&
github.event.pull_request.user.login != 'dependabot[bot]' &&
github.event.pull_request.user.login != 'dependabot-preview[bot]'
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v4
with:
fetch-depth: 0
ssh-key: "${{ secrets.COMMIT_KEY }}"
- name: Create bump and changelog
uses: commitizen-tools/commitizen-action@master
with:
push: false
increment: patch
branch: main
- name: Push using ssh
run: |
git push origin main --tags
new-release:
name: Create Release
needs: [sync-version]
if: startsWith(github.ref, 'refs/tags/')
permissions: write-all
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
repository: onsonr/sonr
fetch-depth: 0
fetch-tags: true
- uses: actions/setup-go@v5
with:
go-version: "1.23"
check-latest: true
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Fetch Release Date
run: |
echo "RELEASE_DATE=$(date +%Y).$(date +%V).$(date +%u)" >> $GITHUB_ENV
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
if: startsWith(github.ref, 'refs/tags/')
with:
version: "~> v2"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GH_RELEASER_TOKEN }}
GITHUB_PERSONAL_AUTH_TOKEN: ${{ secrets.GH_RELEASER_TOKEN }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
REDDIT_APP_ID: ${{ secrets.REDDIT_APP_ID }}
REDDIT_SECRET: ${{ secrets.REDDIT_SECRET }}
REDDIT_USERNAME: ${{ secrets.REDDIT_USERNAME }}
REDDIT_PASSWORD: ${{ secrets.REDDIT_PASSWORD }}
RELEASE_DATE: ${{ env.RELEASE_DATE }}