Skip to content

feat: add feature auto download mmdb database; editing readme #19

feat: add feature auto download mmdb database; editing readme

feat: add feature auto download mmdb database; editing readme #19

Workflow file for this run

name: Build and Release
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
os: [darwin, linux, windows]
arch: [amd64]
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.22'
- name: Build and Archive
run: |
mkdir -p GOWebServer
GOOS=${{ matrix.os }}
GOARCH=amd64
EXT=""
if [ "$GOOS" == "windows" ]; then
EXT=".exe"
fi
go clean
GOOS=$GOOS GOARCH=$GOARCH CGO_ENABLED=0 go build -trimpath -o GOWebServer/GOWebServer$EXT
mkdir -p GOWebServer/cache
echo "YOUR CACHE FILE HERE" > GOWebServer/cache/YOUR_CACHE_FILE_HERE
mkdir -p GOWebServer/ssl
cp -r ssl/* GOWebServer/ssl/ 2>/dev/null || echo "No SSL files found"
cp README.md GOWebServer/ 2>/dev/null || echo "No README found"
mkdir -p GOWebServer/scripts
cp scripts/setup-ddos-protection.sh GOWebServer/scripts/ 2>/dev/null || echo "No script found"
os=${{ matrix.os }}
arch=${{ matrix.arch }}
zip -r GOWebServer-${os}-${arch}.zip GOWebServer
shell: bash
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: GOWebServer-${{ matrix.os }}-${{ matrix.arch }}
path: GOWebServer-${{ matrix.os }}-${{ matrix.arch }}.zip
outputs:
matrix: ${{ toJSON(matrix) }}
fetch_deps:
runs-on: ubuntu-latest
steps:
- name: Clone Dependencies Repo
run: |
git clone https://codeberg.org/Vo/GOWebServer-Depedencies.git deps
- name: Archive Dependencies
run: |
cd deps
zip -j GeoLite2-City.zip GeoLite2-City.mmdb
- name: Upload Dependency Artifact
uses: actions/upload-artifact@v4
with:
name: GeoLite2-City
path: deps/GeoLite2-City.zip
release:
needs: [build, fetch_deps]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download Artifacts
uses: actions/download-artifact@v4
- name: Move Artifacts
run: |
for file in GOWebServer-*/*.zip; do
mv "$file" . || echo "Failed to move $file"
done
mv GeoLite2-City/*.zip . || echo "Failed to move dependency"
- name: Create Tag
id: create_tag
run: |
UNIQUE_CODE=$(openssl rand -hex 3)
TAG_NAME="releases-${UNIQUE_CODE}"
git tag $TAG_NAME
echo "tag_name=${UNIQUE_CODE}" >> $GITHUB_OUTPUT
shell: bash
- name: Upload Release Assets
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.create_tag.outputs.tag_name }}
name: releases-${{ steps.create_tag.outputs.tag_name }}
files: |
GOWebServer-darwin-amd64.zip
GOWebServer-linux-amd64.zip
GOWebServer-windows-amd64.zip
GeoLite2-City.zip
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}