Skip to content

Commit 52fb1ef

Browse files
committed
🚀 deployment: update Github Workflows #2
1 parent bcf5541 commit 52fb1ef

3 files changed

Lines changed: 74 additions & 130 deletions

File tree

.github/workflows/gh_wrk_base.yml

Lines changed: 0 additions & 71 deletions
This file was deleted.

.github/workflows/gh_wrk_news.yml

Lines changed: 65 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@ name: GH Workflow News
55

66
on:
77
push:
8-
branches: ["master"]
98
tags:
109
- "v*"
11-
pull_request:
12-
branches: ["master"]
1310

1411
jobs:
1512
# This job is responsible for building the project.
@@ -31,9 +28,9 @@ jobs:
3128
id: check
3229
run: |
3330
if [[ -z "${{ secrets.TELEGRAM_CHAT_ID }}" || -z "${{ secrets.TELEGRAM_BOT_TOKEN }}" ]]; then
34-
echo "::set-output name=skip::true"
31+
echo "skip=true" >> $GITHUB_OUTPUT
3532
else
36-
echo "::set-output name=skip::false"
33+
echo "skip=false" >> $GITHUB_OUTPUT
3734
fi
3835
- name: Send Telegram Notification
3936
if: steps.check.outputs.skip == 'false'
@@ -55,7 +52,6 @@ jobs:
5552
# It checks if the tag exists, generates a changelog, creates a GitHub release, and sends a notification via Telegram.
5653
deploy:
5754
runs-on: ubuntu-latest
58-
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
5955
needs: build
6056
steps:
6157
- name: Checkout repository
@@ -80,25 +76,82 @@ jobs:
8076
id: check
8177
run: |
8278
if [[ -z "${{ secrets.TELEGRAM_CHAT_ID }}" || -z "${{ secrets.TELEGRAM_BOT_TOKEN }}" ]]; then
83-
echo "::set-output name=skip::true"
79+
echo "skip=true" >> $GITHUB_OUTPUT
8480
else
85-
echo "::set-output name=skip::false"
81+
echo "skip=false" >> $GITHUB_OUTPUT
8682
fi
8783
84+
- name: Get Previous Tag
85+
id: prev_tag
86+
run: |
87+
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
88+
echo "prev_tag=${PREV_TAG}" >> $GITHUB_OUTPUT
89+
8890
- name: Generate Changelog
8991
id: changelog
9092
run: |
91-
# Generate your changelog here and set it as an output variable
92-
CHANGELOG=$(git log --pretty=format:"%h - %s" -n 10)
93-
echo "::set-output name=changelog::$CHANGELOG"
93+
PREV_TAG="${{ steps.prev_tag.outputs.prev_tag }}"
94+
RELEASE_DATE=$(date +'%Y-%m-%d')
95+
echo "release_date=${RELEASE_DATE}" >> $GITHUB_OUTPUT
96+
if [ -n "$PREV_TAG" ]; then
97+
CHANGELOG=$(git log --pretty=format:"%h - %s (@%an)" "${PREV_TAG}..HEAD")
98+
else
99+
CHANGELOG=$(git log --pretty=format:"%h - %s (@%an)" -n 10)
100+
fi
101+
{
102+
echo "changelog<<EOF"
103+
echo "$CHANGELOG"
104+
echo "EOF"
105+
} >> $GITHUB_OUTPUT
94106
95107
- name: Create GitHub Release
96108
id: create_release
97109
uses: softprops/action-gh-release@v1
98110
with:
99111
tag_name: ${{ env.TAG }}
100112
body: |
101-
:gem: released new version ${{ env.TAG }}
113+
## 📦 Release ${{ env.TAG }}
114+
115+
**Release Date:** ${{ steps.changelog.outputs.release_date }}
116+
**Author:** @${{ github.actor }}
117+
118+
---
119+
120+
### 🚀 Features
121+
<!-- List new features introduced in this release -->
122+
123+
### 🐛 Bug Fixes
124+
<!-- List bugs fixed in this release -->
125+
126+
### ⚡ Improvements
127+
<!-- Performance optimizations, refactoring, dependency updates -->
128+
129+
---
130+
131+
### 🔨 Commits in this release
132+
133+
${{ steps.changelog.outputs.changelog }}
134+
135+
---
136+
137+
### 📌 Additional Notes
138+
- Breaking changes (if any)
139+
- Upgrade instructions
140+
- Known issues
141+
142+
---
143+
144+
### 🔗 Links
145+
- Compare: `${{ steps.prev_tag.outputs.prev_tag }}...${{ env.TAG }}`
146+
- Repository: `https://github.com/${{ github.repository }}`
147+
148+
---
149+
150+
### ⚙️ Automation Tip
151+
Generate commit list automatically:
152+
```bash
153+
git log --pretty=format:"%h - %s (%an)" ${{ steps.prev_tag.outputs.prev_tag }}..${{ env.TAG }}
154+
```
102155
draft: false
103156
prerelease: false
104157
env:

.github/workflows/gh_wrk_news_go.yml

Lines changed: 9 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33

44
name: GH Workflow News Golang
55

6+
# on:
7+
# push:
8+
# branches: ["master"]
9+
# pull_request:
10+
# branches: ["master"]
611
on:
7-
push:
8-
branches: ["master"]
9-
tags:
10-
- "v*"
11-
pull_request:
12-
branches: ["master"]
12+
workflow_dispatch: # disabled: previously triggered on push/PR to master and version tags
1313

1414
jobs:
1515
# This job will build and test the Go project
@@ -18,12 +18,12 @@ jobs:
1818
runs-on: ubuntu-latest
1919
strategy:
2020
matrix:
21-
go: ["1.21.x", "1.23.x"] # # Add Go versions as needed, previous version "1.19", "1.20.x"
21+
go: ["1.23.x", "1.24.x", "1.25.x"]
2222
steps:
23-
- uses: actions/checkout@v3
23+
- uses: actions/checkout@v4
2424

2525
- name: Set up Go
26-
uses: actions/setup-go@v3
26+
uses: actions/setup-go@v4
2727
with:
2828
go-version: ${{ matrix.go }}
2929

@@ -32,41 +32,3 @@ jobs:
3232

3333
- name: Test
3434
run: go test -v ./...
35-
# This job will create a GitHub release when a tag is pushed
36-
# It will only run if the tag starts with 'v' (e.g., v1.0.0)
37-
# It will also check if the tag already exists to avoid duplicate releases
38-
create-release:
39-
runs-on: ubuntu-latest
40-
if: startsWith(github.ref, 'refs/tags/v') # Only run this job when a valid tag is pushed
41-
steps:
42-
- name: Check if tag exists
43-
id: check_tag
44-
run: |
45-
if [ -n "$GITHUB_REF" ]; then
46-
TAG=${GITHUB_REF#refs/tags/}
47-
# echo "::set-output name=tag::$TAG"
48-
echo "TAG=${TAG}" >> $GITHUB_ENV
49-
else
50-
# echo "::set-output name=tag::"
51-
echo "TAG=" >> $GITHUB_ENV
52-
fi
53-
shell: bash
54-
55-
- name: Checkout repository
56-
uses: actions/checkout@v3
57-
with:
58-
fetch-depth: 0 # Ensure all history is fetched
59-
60-
- name: Create GitHub Release
61-
id: create_release
62-
uses: softprops/action-gh-release@v1
63-
with:
64-
tag_name: ${{ env.TAG }}
65-
body: |
66-
:gem: released new version ${{ env.TAG }}
67-
Changelog:
68-
${{ env.CHANGELOG }}
69-
draft: false
70-
prerelease: false
71-
env:
72-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)