fix: adapt go v1.18 #4
Workflow file for this run
This file contains hidden or 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*.*.*" | |
| workflow_dispatch: | |
| jobs: | |
| goreleaser: | |
| runs-on: ubuntu-22.04 | |
| environment: release | |
| env: | |
| EDITION: ${{ vars.EDITION || 'community' }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| submodules: recursive | |
| - name: Install dependencies | |
| run: | | |
| sudo dpkg --add-architecture i386 | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| gcc-multilib \ | |
| g++-multilib \ | |
| libc6-dev-i386 \ | |
| upx \ | |
| zip \ | |
| mingw-w64 \ | |
| gcc-mingw-w64-i686 \ | |
| gcc-mingw-w64-x86-64 | |
| - name: Set up GCC | |
| uses: egor-tensin/setup-gcc@v1 | |
| with: | |
| version: latest | |
| platform: x64 | |
| - name: Set up Go | |
| uses: actions/setup-go@v3 | |
| with: | |
| go-version: 1.18 | |
| - name: Run GoReleaser | |
| uses: goreleaser/goreleaser-action@v4 | |
| with: | |
| distribution: goreleaser | |
| version: latest | |
| args: release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GOPATH: "/home/runner/go" | |
| - name: Build Libraries | |
| run: | | |
| mkdir -p dist/lib | |
| # Windows DLL (64-bit) | |
| echo "Building Windows x64 DLL..." | |
| CGO_ENABLED=1 \ | |
| GOOS=windows \ | |
| GOARCH=amd64 \ | |
| CC=x86_64-w64-mingw32-gcc \ | |
| go build -buildmode=c-shared \ | |
| -o dist/lib/rem_${EDITION}_windows_amd64.dll \ | |
| -ldflags "-s -w -X 'github.com/chainreactors/rem/cmd/cmd.ver=${{ github.ref_name }}'" \ | |
| -buildvcs=false ./cmd/export/ | |
| # Windows DLL (32-bit) | |
| echo "Building Windows x86 DLL..." | |
| CGO_ENABLED=1 \ | |
| GOOS=windows \ | |
| GOARCH=386 \ | |
| CC=i686-w64-mingw32-gcc \ | |
| go build -buildmode=c-shared \ | |
| -o dist/lib/rem_${EDITION}_windows_386.dll \ | |
| -ldflags "-s -w -X 'github.com/chainreactors/rem/cmd/cmd.ver=${{ github.ref_name }}'" \ | |
| -buildvcs=false ./cmd/export/ | |
| # Linux .so (64-bit) | |
| echo "Building Linux x64 SO..." | |
| CGO_ENABLED=1 \ | |
| GOOS=linux \ | |
| GOARCH=amd64 \ | |
| go build -buildmode=c-shared \ | |
| -o dist/lib/rem_${EDITION}_linux_amd64.so \ | |
| -ldflags "-s -w -X 'github.com/chainreactors/rem/cmd/cmd.ver=${{ github.ref_name }}'" \ | |
| -buildvcs=false ./cmd/export/ | |
| # Linux .so (32-bit) | |
| echo "Building Linux x86 SO..." | |
| CGO_ENABLED=1 \ | |
| GOOS=linux \ | |
| GOARCH=386 \ | |
| PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig \ | |
| go build -buildmode=c-shared \ | |
| -o dist/lib/rem_${EDITION}_linux_386.so \ | |
| -ldflags "-s -w -X 'github.com/chainreactors/rem/cmd/cmd.ver=${{ github.ref_name }}'" \ | |
| -buildvcs=false ./cmd/export/ | |
| # Static Libraries (.a) | |
| echo "Building Linux x64 Static Library..." | |
| CGO_ENABLED=1 \ | |
| GOOS=linux \ | |
| GOARCH=amd64 \ | |
| go build -buildmode=c-archive \ | |
| -o dist/lib/librem_${EDITION}_linux_amd64.a \ | |
| -ldflags "-s -w -X 'github.com/chainreactors/rem/cmd/cmd.ver=${{ github.ref_name }}'" \ | |
| -buildvcs=false ./cmd/export/ | |
| echo "Building Windows x64 Static Library..." | |
| CGO_ENABLED=1 \ | |
| GOOS=windows \ | |
| GOARCH=amd64 \ | |
| CC=x86_64-w64-mingw32-gcc \ | |
| go build -buildmode=c-archive \ | |
| -o dist/lib/librem_${EDITION}_windows_amd64.a \ | |
| -ldflags "-s -w -X 'github.com/chainreactors/rem/cmd/cmd.ver=${{ github.ref_name }}'" \ | |
| -buildvcs=false ./cmd/export/ | |
| - name: Zip files | |
| run: | | |
| zip -r -j dist/rem_archive.zip dist/rem* | |
| zip -r dist/rem_lib.zip dist/lib/ -x "*.h" | |
| - name: Upload binaries to release | |
| uses: svenstaro/upload-release-action@v2 | |
| with: | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| file: dist/rem* | |
| tag: ${{ github.ref }} | |
| overwrite: true | |
| file_glob: true | |
| draft: true |