Skip to content

Commit ada25bb

Browse files
committed
🚀 deployment: update Github Workflows #2
1 parent 73eee51 commit ada25bb

3 files changed

Lines changed: 77 additions & 137 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: 12 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,27 @@
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:
15-
# This job will build and test the Go project across multiple OS and Go versions
16-
# to validate cross-platform compatibility (Linux, macOS, Windows).
15+
# This job will build and test the Go project
16+
# It will run on the latest Ubuntu environment
1717
build:
18-
runs-on: ${{ matrix.os }}
19-
permissions:
20-
contents: read
18+
runs-on: ubuntu-latest
2119
strategy:
22-
fail-fast: false
2320
matrix:
24-
os: [ubuntu-latest, macos-latest] # windows-latest
25-
go: ["1.21.x", "1.23.x", "1.24.x", "1.25.x"] # Add Go versions as needed, previous version "1.19", "1.20.x"
21+
go: ["1.23.x", "1.24.x", "1.25.x"]
2622
steps:
27-
- uses: actions/checkout@v3
23+
- uses: actions/checkout@v4
2824

2925
- name: Set up Go
30-
uses: actions/setup-go@v3
26+
uses: actions/setup-go@v4
3127
with:
3228
go-version: ${{ matrix.go }}
3329

@@ -36,41 +32,3 @@ jobs:
3632

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

0 commit comments

Comments
 (0)