github.com/bepass-org/wireguard-go@v1.0.4-rc2.0.20240304192354-ebce6572bc24/.github/workflows/go-build.yaml (about)

     1  name: Go
     2  
     3  on:
     4    workflow_dispatch:
     5    release:
     6      types: [published]
     7    push:
     8  
     9  jobs:
    10    build:
    11      permissions:
    12        contents: write
    13      strategy:
    14        fail-fast: false
    15        matrix:
    16          include:
    17            - goos: darwin
    18              goarch: amd64
    19            - goos: darwin
    20              goarch: arm64
    21  
    22            - goos: android
    23              goarch: arm64
    24  
    25            - goos: linux
    26              goarch: amd64
    27            - goos: linux
    28              goarch: arm64
    29            - goos: linux
    30              goarch: riscv64
    31            - goos: linux
    32              goarch: mips64
    33            - goos: linux
    34              goarch: mips64le
    35            - goos: linux
    36              goarch: arm
    37              goarm: 7
    38  
    39            - goos: windows
    40              goarch: amd64
    41            - goos: windows
    42              goarch: arm64
    43  
    44      runs-on: ubuntu-latest
    45      env:
    46        GOOS: ${{ matrix.goos }}
    47        GOARCH: ${{ matrix.goarch }}
    48        GOARM: ${{ matrix.goarm }}
    49        CGO_ENABLED: 0
    50      steps:
    51        - name: Checkout codebase
    52          uses: actions/checkout@v3
    53  
    54        - name: Show workflow information
    55          run: |
    56            export _NAME=$GOOS-$GOARCH$GOARM$GOMIPS.${GITHUB_SHA::6}
    57            echo "GOOS: $GOOS, GOARCH: $GOARCH, GOARM: $GOARM, GOMIPS: $GOMIPS, RELEASE_NAME: $_NAME"
    58            echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV
    59  
    60        - name: Set up Go
    61          uses: actions/setup-go@v4
    62          with:
    63            go-version: '1.20'
    64            check-latest: true
    65  
    66        - name: Build warp
    67          run: |
    68            mkdir -p build_assets
    69            go build -v -o build_assets/warp -trimpath -ldflags "-s -w -buildid=" ./main.go
    70  
    71        - name: Rename Windows warp
    72          if: matrix.goos == 'windows'
    73          run: |
    74            cd ./build_assets || exit 1
    75            mv warp warp.exe
    76  
    77        - name: Copy README.md & LICENSE
    78          run: |
    79            cp ${GITHUB_WORKSPACE}/README.md ./build_assets/README.md
    80            cp ${GITHUB_WORKSPACE}/LICENSE ./build_assets/LICENSE
    81  
    82        - name: Create ZIP archive
    83          shell: bash
    84          run: |
    85            pushd ./build_assets || exit 1
    86            touch -mt $(date +%Y01010000) *
    87            zip -9vr ../warp-${{ env.ASSET_NAME }}.zip .
    88            popd || exit 1
    89            FILE=./warp-${{ env.ASSET_NAME }}.zip
    90            DGST=$FILE.dgst
    91            for METHOD in {"md5","sha256","sha512"}
    92            do
    93              openssl dgst -$METHOD $FILE | sed 's/([^)]*)//g' >>$DGST
    94            done
    95  
    96        - name: Change the name
    97          run: |
    98            mv ./build_assets ./warp-${{ env.ASSET_NAME }}
    99  
   100        - name: Upload files to Artifacts
   101          uses: actions/upload-artifact@v3
   102          with:
   103            name: warp-${{ env.ASSET_NAME }}
   104            path: |
   105              ./warp-${{ env.ASSET_NAME }}/*
   106  
   107        - name: Upload binaries to release
   108          uses: svenstaro/upload-release-action@v2
   109          if: github.event_name == 'release'
   110          with:
   111            repo_token: ${{ secrets.GITHUB_TOKEN }}
   112            file: ./warp-${{ env.ASSET_NAME }}.zip*
   113            tag: ${{ github.ref }}
   114            file_glob: true