From 54caec28ce1fdafb701100fcb6d3ee9816c7e183 Mon Sep 17 00:00:00 2001 From: godcong Date: Tue, 10 Jan 2023 17:26:24 +0800 Subject: [PATCH] feat(fate): split build yml --- .github/workflows/{go.yml => build_linux.yml} | 19 +-- .github/workflows/build_macos.yml | 158 ++++++++++++++++++ .github/workflows/build_windows.yml | 97 +++++++++++ 3 files changed, 260 insertions(+), 14 deletions(-) rename .github/workflows/{go.yml => build_linux.yml} (91%) create mode 100644 .github/workflows/build_macos.yml create mode 100644 .github/workflows/build_windows.yml diff --git a/.github/workflows/go.yml b/.github/workflows/build_linux.yml similarity index 91% rename from .github/workflows/go.yml rename to .github/workflows/build_linux.yml index 180221ae..2e475b52 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/build_linux.yml @@ -15,19 +15,10 @@ jobs: strategy: matrix: go-version: [ 1.19.x ] - platform: [ windows-latest, ubuntu-latest, macos-latest ] + platform: [ ubuntu-latest ] arch: [ 386, amd64 ] runs-on: ${{ matrix.platform }} steps: - - name: Cleanup pre-installed tools - if: matrix.platform != 'windows-latest' - run: | - # This is a fix for https://github.com/actions/virtual-environments/issues/1918 - sudo rm -rf /usr/share/dotnet - sudo rm -rf /opt/ghc - sudo rm -rf "/usr/local/share/boost" - sudo rm -rf "$AGENT_TOOLSDIRECTORY" - - name: Check out code into the Go module directory uses: actions/checkout@v3 @@ -48,7 +39,7 @@ jobs: echo "FATENAME=fate_$(go env GOOS)_$(go env GOARCH)" >> $GITHUB_ENV echo "$(go env GOOS) $(go env GOARCH)" - echo "buiding" + echo "building" go build -o fate_$(go env GOOS)_$(go env GOARCH) -v ./cmd/console echo "compress" @@ -70,7 +61,7 @@ jobs: echo "FATENAME=fate_$(go env GOOS)_$(go env GOARCH)" >> $GITHUB_ENV echo "$(go env GOOS) $(go env GOARCH)" - echo "buiding" + echo "building" go build -o fate_$(go env GOOS)_$(go env GOARCH) -v ./cmd/console echo "compress" @@ -86,7 +77,7 @@ jobs: set GOARCH=${{ matrix.arch }} set CGO_ENABLED=1 echo "FATENAME=fate_windows_amd64" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - echo "buiding" + echo "building" go build -o fate_windows_amd64.exe -v ./cmd/console echo "compress" @@ -102,7 +93,7 @@ jobs: set GOARCH=${{ matrix.arch }} set CGO_ENABLED=1 echo "FATENAME=fate_windows_386" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - echo "buiding" + echo "building" go build -o fate_windows_386.exe -v ./cmd/console echo "compress" diff --git a/.github/workflows/build_macos.yml b/.github/workflows/build_macos.yml new file mode 100644 index 00000000..de3b044c --- /dev/null +++ b/.github/workflows/build_macos.yml @@ -0,0 +1,158 @@ +name: Go + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] +env: + UPLOAD_BIN_FILE: true + +jobs: + + build: + name: Build + strategy: + matrix: + go-version: [ 1.19.x ] + platform: [ macos-latest ] + arch: [ 386, amd64 ] + runs-on: ${{ matrix.platform }} + steps: + - name: Check out code into the Go module directory + uses: actions/checkout@v3 + + - name: Install Go + uses: actions/setup-go@v3 + with: + go-version: ${{ matrix.go-version }} + + - name: Build ${{ matrix.platform }} ${{ matrix.arch }} with Go + if: (matrix.platform == 'ubuntu-latest' || matrix.platform == 'macos-latest') && matrix.arch == 'amd64' && env.UPLOAD_BIN_FILE + id: build_linux_amd64 + env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true' + run: | + go mod tidy + export GOARCH=${{ matrix.arch }} + export CGO_ENABLED=1 + echo "FATENAME=fate_$(go env GOOS)_$(go env GOARCH)" >> $GITHUB_ENV + echo "$(go env GOOS) $(go env GOARCH)" + + echo "building" + go build -o fate_$(go env GOOS)_$(go env GOARCH) -v ./cmd/console + + echo "compress" + tar -zcvf fate_$(go env GOOS)_$(go env GOARCH).tar.gz ./fate_$(go env GOOS)_$(go env GOARCH) + + - name: Build ${{ matrix.platform }} ${{ matrix.arch }} with Go + if: matrix.platform == 'ubuntu-latest' && matrix.arch == '386' && env.UPLOAD_BIN_FILE + id: build_linux_386 + env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true' + run: | + go mod tidy + export GOARCH=${{ matrix.arch }} + export CGO_ENABLED=1 + sudo apt-get install -y gcc-i686-linux-gnu g++-i686-linux-gnu + export AR="/usr/bin/i686-linux-gnu-ar -m32" + export CXX="/usr/bin/i686-linux-gnu-cpp -m32" + export CC="/usr/bin/i686-linux-gnu-gcc -m32" + echo "FATENAME=fate_$(go env GOOS)_$(go env GOARCH)" >> $GITHUB_ENV + echo "$(go env GOOS) $(go env GOARCH)" + + echo "building" + go build -o fate_$(go env GOOS)_$(go env GOARCH) -v ./cmd/console + + echo "compress" + tar -zcvf fate_$(go env GOOS)_$(go env GOARCH).tar.gz ./fate_$(go env GOOS)_$(go env GOARCH) + + - name: Build ${{ matrix.platform }} ${{ matrix.arch }} with Go + if: matrix.platform == 'windows-latest' && matrix.arch == 'amd64' && env.UPLOAD_BIN_FILE + id: build_windows_amd64 + env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true' + run: | + go mod tidy + set GOARCH=${{ matrix.arch }} + set CGO_ENABLED=1 + echo "FATENAME=fate_windows_amd64" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + echo "building" + go build -o fate_windows_amd64.exe -v ./cmd/console + + echo "compress" + Compress-Archive -Path fate_windows_amd64.exe -DestinationPath fate_windows_amd64.zip + + - name: Build ${{ matrix.platform }} ${{ matrix.arch }} with Go + if: matrix.platform == 'windows-latest' && matrix.arch == '386' && env.UPLOAD_BIN_FILE + id: build_windows_386 + env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true' + run: | + go mod tidy + set GOARCH=${{ matrix.arch }} + set CGO_ENABLED=1 + echo "FATENAME=fate_windows_386" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + echo "building" + go build -o fate_windows_386.exe -v ./cmd/console + + echo "compress" + Compress-Archive -Path fate_windows_386.exe -DestinationPath fate_windows_386.zip + + - name: Upload Linux + uses: actions/upload-artifact@master + if: (matrix.platform == 'ubuntu-latest' || matrix.platform == 'macos-latest') && env.UPLOAD_BIN_FILE + env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true' + with: + name: ${{ env.FATENAME }}.tar.gz + path: ${{ env.FATENAME }}.tar.gz + + - name: Upload Windows + uses: actions/upload-artifact@master + if: matrix.platform == 'windows-latest' && env.UPLOAD_BIN_FILE + env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true' + with: + name: ${{ env.FATENAME }}.zip + path: ${{ env.FATENAME }}.zip + + + - name: Create Release + id: create_release_windows + if: matrix.platform == 'windows-latest' && env.UPLOAD_BIN_FILE + uses: ncipollo/release-action@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token + ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true' + with: + artifacts: "${{ env.FATENAME }}.zip" + allowUpdates: true + commit: master + tag: auto_build + body: | + this is only a latest build from master + version: https://github.com/babyname/fate/commit/${{ github.sha }} + token: ${{ secrets.GITHUB_TOKEN }} + draft: false + prerelease: false + + - name: Create Release + id: create_release_linux + if: (matrix.platform == 'ubuntu-latest' || matrix.platform == 'macos-latest') && env.UPLOAD_BIN_FILE + uses: ncipollo/release-action@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token + ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true' + with: + artifacts: "${{ env.FATENAME }}.tar.gz" + allowUpdates: true + commit: master + tag: auto_build + body: | + this is only a latest build from master + version: https://github.com/babyname/fate/commit/${{ github.sha }} + token: ${{ secrets.GITHUB_TOKEN }} + draft: false + prerelease: false + diff --git a/.github/workflows/build_windows.yml b/.github/workflows/build_windows.yml new file mode 100644 index 00000000..24038121 --- /dev/null +++ b/.github/workflows/build_windows.yml @@ -0,0 +1,97 @@ +name: Go + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] +env: + UPLOAD_BIN_FILE: true + +jobs: + + build: + name: Build + strategy: + matrix: + go-version: [ 1.19.x ] + platform: [ windows-latest] + arch: [ 386, amd64 ] + runs-on: ${{ matrix.platform }} + steps: + - name: Cleanup pre-installed tools + if: matrix.platform != 'windows-latest' + run: | + # This is a fix for https://github.com/actions/virtual-environments/issues/1918 + sudo rm -rf /usr/share/dotnet + sudo rm -rf /opt/ghc + sudo rm -rf "/usr/local/share/boost" + sudo rm -rf "$AGENT_TOOLSDIRECTORY" + + - name: Check out code into the Go module directory + uses: actions/checkout@v3 + + - name: Install Go + uses: actions/setup-go@v3 + with: + go-version: ${{ matrix.go-version }} + + - name: Build ${{ matrix.platform }} ${{ matrix.arch }} with Go + if: matrix.platform == 'windows-latest' && matrix.arch == 'amd64' && env.UPLOAD_BIN_FILE + id: build_windows_amd64 + env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true' + run: | + go mod tidy + set GOARCH=${{ matrix.arch }} + set CGO_ENABLED=1 + echo "FATENAME=fate_windows_amd64" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + echo "building" + go build -o fate_windows_amd64.exe -v ./cmd/console + + echo "compress" + Compress-Archive -Path fate_windows_amd64.exe -DestinationPath fate_windows_amd64.zip + + - name: Build ${{ matrix.platform }} ${{ matrix.arch }} with Go + if: matrix.platform == 'windows-latest' && matrix.arch == '386' && env.UPLOAD_BIN_FILE + id: build_windows_386 + env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true' + run: | + go mod tidy + set GOARCH=${{ matrix.arch }} + set CGO_ENABLED=1 + echo "FATENAME=fate_windows_386" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + echo "building" + go build -o fate_windows_386.exe -v ./cmd/console + + echo "compress" + Compress-Archive -Path fate_windows_386.exe -DestinationPath fate_windows_386.zip + + - name: Upload Windows + uses: actions/upload-artifact@master + if: matrix.platform == 'windows-latest' && env.UPLOAD_BIN_FILE + env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true' + with: + name: ${{ env.FATENAME }}.zip + path: ${{ env.FATENAME }}.zip + + - name: Create Release + id: create_release_windows + if: matrix.platform == 'windows-latest' && env.UPLOAD_BIN_FILE + uses: ncipollo/release-action@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token + ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true' + with: + artifacts: "${{ env.FATENAME }}.zip" + allowUpdates: true + commit: master + tag: auto_build + body: | + this is only a latest build from master + version: https://github.com/babyname/fate/commit/${{ github.sha }} + token: ${{ secrets.GITHUB_TOKEN }} + draft: false + prerelease: false