Skip to content

Commit 8b635ea

Browse files
refactor: rewrite codebase from python to golang
Refactor entire codebase from Python to Golang for improved performance
2 parents a0518f8 + b314663 commit 8b635ea

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+2555
-1776
lines changed

.dockerignore

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

.github/workflows/build.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Package Build
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag:
7+
description: 'Tag to release'
8+
required: true
9+
push:
10+
tags:
11+
- '*'
12+
env:
13+
DOCKER_BUILDKIT: 1
14+
15+
jobs:
16+
build_image:
17+
name: Build Image
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Set up Docker Buildx
26+
uses: docker/setup-buildx-action@v3
27+
with:
28+
config-inline: |
29+
[worker.oci]
30+
platforms = ["linux/amd64", "linux/arm64"]
31+
max-parallelism = 4
32+
33+
- name: Login to GitHub Container Registry
34+
uses: docker/login-action@v3
35+
with:
36+
registry: ghcr.io
37+
username: ${{ github.actor }}
38+
password: ${{ secrets.GITHUB_TOKEN }}
39+
40+
- name: Setup ENV vars
41+
id: env-vars
42+
run: |
43+
echo "TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
44+
echo "IMAGE_NAME=ghcr.io/${GITHUB_ACTOR,,}/fsb" >> $GITHUB_ENV
45+
46+
- name: Build docker image and push
47+
uses: docker/build-push-action@v5
48+
with:
49+
context: ./
50+
pull: true
51+
push: true
52+
platforms: linux/amd64,linux/arm64
53+
tags: ${{ env.IMAGE_NAME }}:${{ env.TAG }} , ${{ env.IMAGE_NAME }}:latest

.github/workflows/generate_changelogs.sh

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

.github/workflows/release.yml

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,44 @@
1-
name: Release
1+
name: Goreleaser
2+
23
on:
34
workflow_dispatch:
5+
inputs:
6+
goReleaserArgs:
7+
description: 'Args goreleaser'
8+
required: false
9+
default: '--clean'
410
push:
11+
tags:
12+
- "*"
513

14+
permissions:
15+
contents: write
616

717
jobs:
8-
Release:
9-
if: "contains(github.event.head_commit.message, 'Bump version')"
10-
runs-on: ubuntu-22.04
18+
goreleaser:
19+
runs-on: ubuntu-latest
1120
steps:
1221
- name: Checkout
1322
uses: actions/checkout@v3
14-
- name: Setup ENV
15-
run: echo "VERSION=$(echo ${{ github.event.head_commit.message }} | sed -r 's/Bump\s+version\s+?(to\s+?)?`?v?([a-z0-9.\-_]+)`?$/\2/')" >> $GITHUB_ENV
16-
- name: Generate CHANGELOGS
17-
run: |
18-
chmod +x .github/workflows/generate_changelogs.sh
19-
./.github/workflows/generate_changelogs.sh > CHANGELOGS.md
20-
- name: Package Server
21-
run: |
22-
rm -fr .vscode .git*
23-
zip -r ${{ github.WORKSPACE }}/TG-FileStreamBot-v${{ env.VERSION }}-main.zip *
24-
- name: Release
25-
uses: softprops/action-gh-release@v1
2623
with:
27-
name: TG-FileStreamBot-v${{ env.VERSION }} (main)
28-
body_path: CHANGELOGS.md
29-
files: |
30-
${{ github.WORKSPACE }}/TG-FileStreamBot-v${{ env.VERSION }}-main.zip
31-
prerelease: false
32-
tag_name: v${{ env.VERSION }}
24+
fetch-depth: 0
25+
- run: git fetch --force --tags
26+
- name: Set up Go
27+
uses: actions/setup-go@v4
28+
with:
29+
go-version: 1.21
30+
- name: Import GPG key
31+
id: import_gpg
32+
uses: crazy-max/ghaction-import-gpg@v6
33+
with:
34+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
35+
passphrase: ${{ secrets.PASSPHRASE }}
36+
- name: Run GoReleaser
37+
uses: goreleaser/goreleaser-action@v5
38+
with:
39+
distribution: goreleaser
40+
version: latest
41+
args: release ${{ github.event.inputs.goReleaserArgs }}"
42+
env:
43+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}

.gitignore

Lines changed: 23 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -1,121 +1,33 @@
1-
# Byte-compiled / optimized / DLL files
2-
__pycache__/
3-
*.py[cod]
4-
*$py.class
5-
6-
# C extensions
1+
# Binaries for programs and plugins
2+
*.exe
3+
*.exe~
4+
*.dll
75
*.so
6+
*.dylib
87

9-
# Distribution / packaging
10-
.Python
11-
build/
12-
develop-eggs/
13-
dist/
14-
downloads/
15-
eggs/
16-
.eggs/
17-
lib/
18-
lib64/
19-
parts/
20-
sdist/
21-
var/
22-
wheels/
23-
*.egg-info/
24-
.installed.cfg
25-
*.egg
26-
MANIFEST
27-
28-
# PyInstaller
29-
# Usually these files are written by a python script from a template
30-
# before PyInstaller builds the exe, so as to inject date/other infos into it.
31-
*.manifest
32-
*.spec
33-
34-
# Installer logs
35-
pip-log.txt
36-
pip-delete-this-directory.txt
37-
38-
# Unit test / coverage reports
39-
htmlcov/
40-
.tox/
41-
.nox/
42-
.coverage
43-
.coverage.*
44-
.cache
45-
nosetests.xml
46-
coverage.xml
47-
*.cover
48-
.hypothesis/
49-
.pytest_cache/
50-
51-
# Translations
52-
*.mo
53-
*.pot
54-
55-
# Django stuff:
56-
*.log
57-
local_settings.py
58-
db.sqlite3
59-
60-
# Flask stuff:
61-
instance/
62-
.webassets-cache
63-
64-
# Scrapy stuff:
65-
.scrapy
8+
# Test binary, built with `go test -c`
9+
*.test
6610

67-
# Sphinx documentation
68-
docs/_build/
11+
# Output of the go coverage tool, specifically when used with LiteIDE
12+
*.out
6913

70-
# PyBuilder
71-
target/
14+
# Dependency directories
15+
vendor/
7216

73-
# Jupyter Notebook
74-
.ipynb_checkpoints
17+
# Go workspace file
18+
go.work
7519

76-
# IPython
77-
profile_default/
78-
ipython_config.py
79-
80-
# pyenv
81-
.python-version
82-
83-
# celery beat schedule file
84-
celerybeat-schedule
85-
86-
# SageMath parsed files
87-
*.sage.py
88-
89-
# Environments
20+
# Env files
21+
fsb.env
9022
.env
91-
.venv
92-
env/
93-
venv/
94-
ENV/
95-
env.bak/
96-
venv.bak/
97-
98-
# Spyder project settings
99-
.spyderproject
100-
.spyproject
10123

102-
# Rope project settings
103-
.ropeproject
24+
# Session files
25+
*.session*
26+
sessons/
10427

105-
# mkdocs documentation
106-
/site
107-
108-
# mypy
109-
.mypy_cache/
110-
.dmypy.json
111-
dmypy.json
112-
113-
# Pyre type checker
114-
.pyre/
28+
# build folder
29+
dist/
11530

116-
#session files
117-
sessions/
118-
*.session
119-
*.session-journal
120-
.env
121-
test.py
31+
# logs folder
32+
logs/
33+
*.log

.goreleaser.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
version: 1
2+
project_name: TG-FileStreamBot
3+
env:
4+
- GO111MODULE=on
5+
before:
6+
hooks:
7+
- go mod tidy
8+
- go generate ./...
9+
10+
builds:
11+
- main: ./cmd/fsb
12+
env:
13+
- CGO_ENABLED=0
14+
flags: -tags=musl
15+
ldflags: "-extldflags -static -s -w"
16+
binary: fsb
17+
goos:
18+
- linux
19+
- windows
20+
- darwin
21+
goarch:
22+
- amd64
23+
- arm64
24+
mod_timestamp: '{{ .CommitTimestamp }}'
25+
26+
archives:
27+
- format: tar.gz
28+
name_template: "{{ .ProjectName }}-{{ .Tag }}-{{ .Os }}-{{ .Arch }}"
29+
format_overrides:
30+
- goos: windows
31+
format: zip
32+
33+
signs:
34+
- artifacts: checksum
35+
cmd: gpg2
36+
args:
37+
- "--batch"
38+
- "-u"
39+
- "{{ .Env.GPG_FINGERPRINT }}"
40+
- "--output"
41+
- "${signature}"
42+
- "--detach-sign"
43+
- "${artifact}"
44+
45+
checksum:
46+
name_template: "{{ .ProjectName }}-{{ .Tag }}-checksums.txt"
47+
48+
changelog:
49+
sort: asc
50+
filters:
51+
exclude:
52+
- "^docs:"
53+
- "^test:"

0 commit comments

Comments
 (0)