Skip to content

Commit f2dade5

Browse files
committed
♻️ refactor: update codebase #2
1 parent 9ac648b commit f2dade5

8 files changed

Lines changed: 101 additions & 28 deletions

File tree

.github/workflows/gh_wrk_base.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# This GitHub Actions workflow is designed to run on pushes to the master branch and on pull requests.
2+
# It builds the project, runs tests, and deploys a release when a tag is pushed.
3+
# It also checks if the tag exists before creating a release.
4+
# The workflow uses the softprops/action-gh-release action to create a GitHub release.
5+
6+
name: GH Workflow Base
7+
8+
on:
9+
push:
10+
branches: ["master"]
11+
tags:
12+
- "v*"
13+
pull_request:
14+
branches: ["master"]
15+
16+
jobs:
17+
# This job runs on pushes to the master branch and pull requests.
18+
# It checks out the repository, installs dependencies, and runs tests.
19+
build:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v3
24+
25+
- name: Install dependencies
26+
run: |
27+
echo "Dependencies here"
28+
29+
- name: Run tests
30+
run: |
31+
echo "Test commands here"
32+
# This job runs on pushes to the master branch and pull requests.
33+
# It checks out the repository, installs dependencies, and runs tests.
34+
deploy:
35+
runs-on: ubuntu-latest
36+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
37+
needs: build
38+
steps:
39+
- name: Checkout repository
40+
uses: actions/checkout@v3
41+
with:
42+
fetch-depth: 0 # Ensure all history is fetched
43+
44+
- name: Check if tag exists
45+
id: check_tag
46+
run: |
47+
if [ -n "$GITHUB_REF" ]; then
48+
TAG=${GITHUB_REF#refs/tags/}
49+
# echo "::set-output name=tag::$TAG"
50+
echo "TAG=${TAG}" >> $GITHUB_ENV
51+
else
52+
# echo "::set-output name=tag::"
53+
echo "TAG=" >> $GITHUB_ENV
54+
fi
55+
shell: bash
56+
57+
- name: Install dependencies
58+
run: |
59+
echo "Dependencies here"
60+
61+
- name: Create GitHub Release
62+
id: create_release
63+
uses: softprops/action-gh-release@v1 # uses: actions/create-release@v1
64+
with:
65+
tag_name: ${{ env.TAG }}
66+
body: |
67+
:gem: released new version ${{ env.TAG }}
68+
draft: false
69+
prerelease: false
70+
env:
71+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
name: Notify
1+
# This snippet is a GitHub Actions workflow configuration file that defines a CI/CD pipeline for a project.
2+
# It includes steps for building, notifying, and deploying the project, with specific actions for sending notifications via Telegram and creating GitHub releases.
3+
4+
name: GH Workflow News
25

36
on:
47
push:
@@ -9,12 +12,17 @@ on:
912
branches: ["master"]
1013

1114
jobs:
15+
# This job is responsible for building the project.
16+
# It checks out the repository and prepares it for further actions.
1217
build:
1318
runs-on: ubuntu-latest
1419
steps:
1520
- name: Checkout Repository
1621
uses: actions/checkout@v3
1722

23+
# This job sends a notification via Telegram when a push or pull request is made.
24+
# It checks if the necessary secrets are available and sends a formatted message.
25+
# If the secrets are not set, it skips the notification step.
1826
notify:
1927
runs-on: ubuntu-latest
2028
needs: build
@@ -43,6 +51,8 @@ jobs:
4351
- *head*: `${{ github.event.head_commit.message }}`
4452
🍀 *See changes*: `https://github.com/${{ github.repository }}/commit/${{github.sha}}`
4553
54+
# This job is responsible for deploying the project when a tag is pushed.
55+
# It checks if the tag exists, generates a changelog, creates a GitHub release, and sends a notification via Telegram.
4656
deploy:
4757
runs-on: ubuntu-latest
4858
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This workflow will build a golang project
22
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
33

4-
name: Go
4+
name: GH Workflow News Golang
55

66
on:
77
push:
@@ -12,12 +12,13 @@ on:
1212
branches: ["master"]
1313

1414
jobs:
15+
# This job will build and test the Go project
16+
# It will run on the latest Ubuntu environment
1517
build:
1618
runs-on: ubuntu-latest
1719
strategy:
1820
matrix:
19-
# Add Go versions as needed
20-
go: ["1.21.x", "1.23.x"] # previous version "1.19", "1.20.x"
21+
go: ["1.21.x", "1.23.x"] # # Add Go versions as needed, previous version "1.19", "1.20.x"
2122
steps:
2223
- uses: actions/checkout@v3
2324

@@ -31,11 +32,12 @@ jobs:
3132

3233
- name: Test
3334
run: go test -v ./...
34-
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
3538
create-release:
3639
runs-on: ubuntu-latest
37-
# Only run this job when a valid tag is pushed
38-
if: startsWith(github.ref, 'refs/tags/v')
40+
if: startsWith(github.ref, 'refs/tags/v') # Only run this job when a valid tag is pushed
3941
steps:
4042
- name: Check if tag exists
4143
id: check_tag
@@ -53,17 +55,7 @@ jobs:
5355
- name: Checkout repository
5456
uses: actions/checkout@v3
5557
with:
56-
# Ensure all history is fetched
57-
fetch-depth: 0
58-
59-
- name: Apply changelog
60-
run: chmod +x git_changelog.sh
61-
62-
- name: Generate changelog
63-
id: changelog
64-
run: |
65-
CHANGELOG=$(./git_changelog.sh)
66-
echo "CHANGELOG=$CHANGELOG" >> $GITHUB_ENV
58+
fetch-depth: 0 # Ensure all history is fetched
6759

6860
- name: Create GitHub Release
6961
id: create_release

Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
LOG_DIR=logs
2+
3+
# Makefile for managing Go project tasks such as running, building, testing, and maintaining dependencies.
14
.PHONY: run build test tidy deps-upgrade deps-clean-cache
25

36
# ==============================================================================
@@ -43,3 +46,10 @@ deps-clean-cache:
4346
# Generates code coverage report and logs the results
4447
coverage:
4548
sh ./sh/go_deps.sh
49+
50+
# Generating project file tree
51+
# Creates a text file representing the project's directory structure, excluding certain directories
52+
tree:
53+
mkdir -p $(LOG_DIR)
54+
tree -I ".gradle|.idea|build|logs|.vscode|.git|.github|vendor" > ./$(LOG_DIR)/tree_source_oss.txt
55+
cat ./$(LOG_DIR)/tree_source_oss.txt
File renamed without changes.
File renamed without changes.

sh/git_changelog.sh

Lines changed: 0 additions & 10 deletions
This file was deleted.
File renamed without changes.

0 commit comments

Comments
 (0)