dikderoy/tagrelease

View on GitHub
.github/workflows/build.yml

Summary

Maintainability
Test Coverage
name: build
on: push
jobs:
  build:
    strategy:
      matrix:
        go-version: [ 1.21.x ]
        os: [ ubuntu-latest, macos-latest ]
        include:
          - os: ubuntu-latest
            goos: linux
          - os: macos-latest
            goos: darwin

    runs-on: ${{ matrix.os }}

    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-go@v4
        with:
          go-version: ${{ matrix.go-version }}
        id: go
      - name: Test
        run: go test -v ./...
      - name: Build
        env:
          GOOS: ${{ matrix.goos }}
          GOARCH: amd64
          CGO_ENABLED: '0'
        run: go build -a -ldflags='-w -s -extldflags "-static"' -o ./build/tagrelease-$GOOS-$GOARCH
      - name: upload build artifact
        uses: actions/upload-artifact@v3
        with:
          name: binaries
          path: build/*

  release:
    needs: build
    if: startsWith(github.ref, 'refs/tags/')
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - name: download build artifacts
        uses: actions/download-artifact@v3
        with:
          name: binaries
          path: build
      - name: list build artifacts
        run: ls -l ./build
      - name: publish release
        uses: softprops/action-gh-release@v1
        with:
          files: |
            build/*