Merge pull request #99 from samwafgo/bug_ssl_path #66
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 gcc-aarch64-linux-gnu g++-aarch64-linux-gnu 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 | |
ls | |
- name: Get current tag | |
run: echo "IMAGE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV | |
- name: Check if the tag contains "beta" | |
id: check_beta | |
run: | | |
echo "Is the tag beta? ${GITHUB_REF}" | |
if [[ "${GITHUB_REF}" == *"beta"* ]]; then | |
echo "is_beta=true" >> $GITHUB_ENV | |
else | |
echo "is_beta=false" >> $GITHUB_ENV | |
fi | |
# Login to Docker Hub | |
- name: Login to Docker Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ secrets.DOCKER_HUB_USER }} | |
password: ${{ secrets.DOCKER_HUB_TOKEN }} | |
# Set up Docker Buildx | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
# Build and Push Docker Image for Multi-Arch | |
- name: Build and Push Docker Image for Multi-Arch | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 # Support for both architectures | |
push: true # Push to Docker Hub | |
tags: | | |
samwaf/samwaf:${{ env.IMAGE_TAG }} | |
${{ env.is_beta == 'false' && 'samwaf/samwaf:latest' || '' }} | |
# Test the Docker Image (latest) | |
- name: Test Docker Image (latest) | |
run: | | |
echo "Testing Docker image with 'latest' tag..." | |
docker run -d --name=samwaf-latest-instance \ | |
-p 26666:26666 \ | |
samwaf/samwaf:latest | |
# 等待服务启动 | |
sleep 5 | |
# 测试服务是否正常运行 | |
curl -f http://localhost:26666 || (echo "Test for 'latest' tag failed" && exit 1) | |
# 停止并移除容器 | |
docker stop samwaf-latest-instance | |
docker rm samwaf-latest-instance | |
- name: Test Docker Image (current tag) | |
run: | | |
echo "Testing Docker image with tag '${{ env.IMAGE_TAG }}'..." | |
docker run -d --name=samwaf-current-instance \ | |
-p 26666:26666 \ | |
samwaf/samwaf:${{ env.IMAGE_TAG }} | |
# 等待服务启动 | |
sleep 5 | |
# 测试服务是否正常运行 | |
curl -f http://localhost:26666 || (echo "Test for current tag '${{ env.IMAGE_TAG }}' failed" && exit 1) | |
# 停止并移除容器 | |
docker stop samwaf-current-instance | |
docker rm samwaf-current-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 |