Add Gitea Actions CI/CD workflow for automated builds and releases
All checks were successful
Build & Release / build-latest (push) Has been skipped
Build & Release / version-release (push) Successful in 10m16s

This commit is contained in:
Salastil
2025-11-16 16:20:34 -05:00
parent 04f3ef2500
commit 404afe4786
4 changed files with 179 additions and 2 deletions

159
.gitea/workflows/build.yml Normal file
View File

@@ -0,0 +1,159 @@
name: Build & Release
on:
push:
branches: ["master"]
tags:
- 'v*.*'
jobs:
build-latest:
runs-on: ubuntu-latest
if: github.ref_type == 'branch'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "1.22"
- name: Build Binary
run: |
go mod tidy
go build -o Sneedchat-Discord-Bridge .
- name: Delete Previous Latest Release
continue-on-error: true
env:
GITEA_TOKEN: ${{ secrets.CI_TOKEN }}
run: |
curl -X DELETE \
-H "Authorization: token ${GITEA_TOKEN}" \
"https://git.salastil.com/api/v1/repos/Salastil/Sneedchat-Discord-Bridge-Go/releases/tags/latest"
- name: Delete Latest Tag
continue-on-error: true
run: |
git push origin :refs/tags/latest || true
- name: Create Latest Tag
run: |
git config user.name "Gitea Actions"
git config user.email "actions@gitea.local"
git tag latest
git push origin latest
- name: Create Latest Release and Upload Binary
env:
GITEA_TOKEN: ${{ secrets.CI_TOKEN }}
run: |
set -x
# Verify token exists
if [ -z "$GITEA_TOKEN" ]; then
echo "ERROR: CI_TOKEN secret is not set!"
exit 1
fi
# Create release
RESPONSE=$(curl -X POST \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"tag_name": "latest",
"name": "Latest Build (Development)",
"body": "Automated build from master branch commit ${{ github.sha }}",
"draft": false,
"prerelease": true
}' \
"https://git.salastil.com/api/v1/repos/Salastil/Sneedchat-Discord-Bridge-Go/releases")
echo "Create release response: $RESPONSE"
# Extract release ID
RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | head -1 | grep -o '[0-9]*')
echo "Release ID: $RELEASE_ID"
if [ -z "$RELEASE_ID" ]; then
echo "Failed to create release or extract release ID"
exit 1
fi
# Upload binary
curl -X POST \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/octet-stream" \
--data-binary @Sneedchat-Discord-Bridge \
"https://git.salastil.com/api/v1/repos/Salastil/Sneedchat-Discord-Bridge-Go/releases/$RELEASE_ID/assets?name=Sneedchat-Discord-Bridge"
version-release:
runs-on: ubuntu-latest
if: github.ref_type == 'tag' && startsWith(github.ref_name, 'v')
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "1.22"
- name: Build Multi-Platform Binaries
run: |
mkdir -p dist
go mod tidy
GOOS=linux GOARCH=amd64 go build -o dist/Sneedchat-Discord-Bridge-linux-amd64 .
GOOS=linux GOARCH=arm64 go build -o dist/Sneedchat-Discord-Bridge-linux-arm64 .
GOOS=windows GOARCH=amd64 go build -o dist/Sneedchat-Discord-Bridge-windows-amd64.exe .
GOOS=darwin GOARCH=amd64 go build -o dist/Sneedchat-Discord-Bridge-darwin-amd64 .
GOOS=darwin GOARCH=arm64 go build -o dist/Sneedchat-Discord-Bridge-darwin-arm64 .
- name: Create Version Release and Upload Binaries
env:
GITEA_TOKEN: ${{ secrets.CI_TOKEN }}
run: |
set -x
# Verify token exists
if [ -z "$GITEA_TOKEN" ]; then
echo "ERROR: CI_TOKEN secret is not set!"
exit 1
fi
# Create release
RESPONSE=$(curl -X POST \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"tag_name": "${{ github.ref_name }}",
"name": "Release ${{ github.ref_name }}",
"body": "Release ${{ github.ref_name }}",
"draft": false,
"prerelease": false
}' \
"https://git.salastil.com/api/v1/repos/Salastil/Sneedchat-Discord-Bridge-Go/releases")
echo "Create release response: $RESPONSE"
# Extract release ID
RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | head -1 | grep -o '[0-9]*')
echo "Release ID: $RELEASE_ID"
if [ -z "$RELEASE_ID" ]; then
echo "Failed to create release or extract release ID"
exit 1
fi
# Upload all binaries
for file in dist/*; do
filename=$(basename "$file")
echo "Uploading $filename..."
curl -X POST \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/octet-stream" \
--data-binary @"$file" \
"https://git.salastil.com/api/v1/repos/Salastil/Sneedchat-Discord-Bridge-Go/releases/$RELEASE_ID/assets?name=$filename"
done

1
.gitignore vendored
View File

@@ -1,3 +1,2 @@
go.sum
Sneedchat-Discord-Bridge Sneedchat-Discord-Bridge
file.log file.log

View File

@@ -14,7 +14,7 @@ A high-performance bridge written in Go that synchronizes messages between Kiwi
**Typical resource usage:** **Typical resource usage:**
- **CPU**: Efficient, easily handled by a Raspberry Pi, a few % on cpu usage at heavy load. - **CPU**: Efficient, easily handled by a Raspberry Pi, a few % on cpu usage at heavy load.
- **Memory**: 50-70 MB at full load in a busy channel - **Memory**: 10-15 MB at full load in a busy channel
- **Network**: Minimal (< 1 MB/minute) except when uploading attachments - **Network**: Minimal (< 1 MB/minute) except when uploading attachments
## Requirements ## Requirements

19
go.sum Normal file
View File

@@ -0,0 +1,19 @@
github.com/bwmarrin/discordgo v0.27.1 h1:ib9AIc/dom1E/fSIulrBwnez0CToJE113ZGt4HoliGY=
github.com/bwmarrin/discordgo v0.27.1/go.mod h1:NJZpH+1AfhIcyQsPeuBKsUtYrRnjkyu0kIVMCHkZtRY=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY=
github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=