name: Build and Release on: push: branches: - main tags: - 'v*' pull_request: branches: - main jobs: build: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3 - name: Set up Go uses: actions/setup-go@v4 with: go-version: '1.19' - name: Build run: go build -v ./... - name: Test run: go test -v ./... release: runs-on: ubuntu-latest needs: build if: startsWith(github.ref, 'refs/tags/v') strategy: matrix: include: - os: linux arch: amd64 goos: linux goarch: amd64 - os: linux arch: arm64 goos: linux goarch: arm64 - os: darwin arch: amd64 goos: darwin goarch: amd64 - os: darwin arch: arm64 goos: darwin goarch: arm64 - os: windows arch: amd64 goos: windows goarch: amd64 steps: - name: Checkout code uses: actions/checkout@v3 - name: Set up Go uses: actions/setup-go@v4 with: go-version: '1.19' - name: Build binary env: GOOS: ${{ matrix.goos }} GOARCH: ${{ matrix.goarch }} CGO_ENABLED: 0 run: | if [ "${{ matrix.os }}" = "windows" ]; then go build -o unhttpx-${{ matrix.os }}-${{ matrix.arch }}.exe -ldflags="-s -w" . else go build -o unhttpx-${{ matrix.os }}-${{ matrix.arch }} -ldflags="-s -w" . fi - name: Create Release uses: actions/gitea-release-action@v1 with: files: unhttpx-* token: ${{ secrets.GITHUB_TOKEN }}