mirror of
https://gitee.com/samwaf/SamWaf.git
synced 2025-12-06 06:58:54 +08:00
152 lines
5.1 KiB
YAML
152 lines
5.1 KiB
YAML
name: goreleaser
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
|
|
permissions:
|
|
contents: write
|
|
env:
|
|
REGISTRY: docker.io
|
|
jobs:
|
|
goreleaser:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v4
|
|
with:
|
|
go-version: '1.21.4'
|
|
- name: Install dependencies for Windows cross-compilation
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y gcc-mingw-w64-x86-64 gcc-mingw-w64-i686 build-essential
|
|
- name: Run GoReleaser
|
|
uses: goreleaser/goreleaser-action@v4
|
|
with:
|
|
# either 'goreleaser' (default) or 'goreleaser-pro'
|
|
distribution: goreleaser
|
|
version: '2.1.0'
|
|
args: release --clean
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution
|
|
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
|
|
- name: List Folder
|
|
run: |
|
|
ls
|
|
cd dist
|
|
- name: Get current tag
|
|
run: echo "IMAGE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
|
|
# Build Docker Image
|
|
- name: Build Docker Image
|
|
run: |
|
|
docker build -t samwaf/samwaf:latest .
|
|
docker tag samwaf/samwaf:latest samwaf/samwaf:${{ env.IMAGE_TAG }}
|
|
# Login Docker
|
|
- name: login to docker REGISTRY
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ secrets.DOCKER_HUB_USER }}
|
|
password: ${{ secrets.DOCKER_HUB_TOKEN }}
|
|
# Push Docker Image to Docker Hub
|
|
- name: Push Docker Image
|
|
run: |
|
|
docker push samwaf/samwaf:latest
|
|
docker push samwaf/samwaf:${{ env.IMAGE_TAG }}
|
|
|
|
# Test the Docker Image
|
|
- name: Test Docker Image
|
|
run: |
|
|
# Start the Docker container
|
|
docker run -d --name=samwaf-instance \
|
|
-p 26666:26666 \
|
|
samwaf/samwaf:latest
|
|
|
|
# Wait for a few seconds to allow the application to start
|
|
sleep 5
|
|
|
|
# Test the application by sending a request
|
|
curl -f http://localhost:26666 || (echo "Test failed" && exit 1)
|
|
|
|
# Optionally, stop and remove the container after testing
|
|
docker stop samwaf-instance
|
|
docker rm samwaf-instance
|
|
win7win2008r2:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: '1.23'
|
|
|
|
- name: Install dependencies for Windows cross-compilation
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y gcc-mingw-w64-x86-64 gcc-mingw-w64-i686 build-essential
|
|
|
|
- name: Install UPX
|
|
run: |
|
|
sudo apt-get install -y upx
|
|
|
|
- name: DownLoad New SamWafWeb
|
|
run: |
|
|
curl -L https://github.com/samwafgo/SamWafWeb/releases/latest/download/dist.tar.gz -o dist.tar.gz
|
|
tar -zxvf dist.tar.gz
|
|
rm -rf public/dist
|
|
mv -f dist public
|
|
rm -rf dist.tar.gz
|
|
ls
|
|
ls public
|
|
ls public/dist
|
|
|
|
- name: Revert Golang1.23 commit for Windows7/8
|
|
run: |
|
|
cd $(go env GOROOT)
|
|
patch --verbose -p 1 < $GITHUB_WORKSPACE/.github/win7patch/patch_go123/9ac42137ef6730e8b7daca016ece831297a1d75b.diff
|
|
patch --verbose -p 1 < $GITHUB_WORKSPACE/.github/win7patch/patch_go123/21290de8a4c91408de7c2b5b68757b1e90af49dd.diff
|
|
patch --verbose -p 1 < $GITHUB_WORKSPACE/.github/win7patch/patch_go123/6a31d3fa8e47ddabc10bd97bff10d9a85f4cfb76.diff
|
|
patch --verbose -p 1 < $GITHUB_WORKSPACE/.github/win7patch/patch_go123/69e2eed6dd0f6d815ebf15797761c13f31213dd6.diff
|
|
|
|
- name: Get current tag
|
|
id: get_tag
|
|
run: echo "CURRENT_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
|
|
|
|
- name: Set BUILDTIME environment variable
|
|
run: echo "BUILDTIME=$(date +'%Y%m%d')" >> $GITHUB_ENV
|
|
|
|
- name: Build Win7/Win8/Windows2008r2
|
|
env:
|
|
GOOS: windows
|
|
GOARCH: amd64
|
|
CGO_ENABLED: 1
|
|
CC: x86_64-w64-mingw32-gcc
|
|
CXX: x86_64-w64-mingw32-g++
|
|
CGO_CFLAGS: -Wno-unused-variable -Wno-implicit-function-declaration
|
|
BUILDTIME: ${{ env.BUILDTIME }}
|
|
CURRENT_TAG: ${{ env.CURRENT_TAG }}
|
|
run: |
|
|
go build -ldflags="-X SamWaf/global.GWAF_RUNTIME_WIN7_VERSION=true -X SamWaf/global.GWAF_RELEASE=true -X SamWaf/global.GWAF_RELEASE_VERSION_NAME=${BUILDTIME} -X SamWaf/global.GWAF_RELEASE_VERSION=${CURRENT_TAG} -s -w -extldflags '-static'" -o ./release/SamWaf64ForWin7Win8Win2008.exe main.go
|
|
|
|
- name: Archive artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: SamWaf64ForWin7Win8Win2008
|
|
path: release/SamWaf64ForWin7Win8Win2008.exe
|
|
- name: Release
|
|
uses: softprops/action-gh-release@v2
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
with:
|
|
files: |
|
|
release/SamWaf64ForWin7Win8Win2008.exe
|
|
needs: goreleaser |