main.yml 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. name: Go
  2. on:
  3. push:
  4. branches: [ master ]
  5. pull_request:
  6. branches: [ master ]
  7. jobs:
  8. test:
  9. runs-on: [ ubuntu-latest ]
  10. if: github.ref=='refs/heads/master' || github.ref=='refs/heads/main' || starts-with(github.ref, 'refs/tags/')
  11. steps:
  12. - uses: actions/checkout@v4
  13. - uses: actions/setup-go@v1
  14. - name: Test
  15. run: |
  16. go test -v ./...
  17. build:
  18. name: Build
  19. strategy:
  20. matrix:
  21. os: [ubuntu-latest, macos-latest, windows-latest]
  22. include:
  23. - os: ubuntu-latest
  24. path: |
  25. ~/.cache/go-build
  26. ~/go/pkg/mod
  27. - os: macos-latest
  28. path: |
  29. ~/Library/Caches/go-build
  30. ~/go/pkg/mod
  31. - os: windows-latest
  32. path: |
  33. %LocalAppData%\go-build
  34. ~/go/pkg/mod
  35. runs-on: ${{matrix.os}}
  36. steps:
  37. - name: Set up Go 1.13
  38. uses: actions/setup-go@v1
  39. with:
  40. go-version: 1.13
  41. id: go
  42. - name: Check out code into the Go module directory
  43. uses: actions/checkout@v4
  44. - name: cache
  45. id: cache
  46. uses: actions/cache@v2
  47. with:
  48. path: ${{ matrix.path }}
  49. key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
  50. restore-keys: |
  51. ${{ runner.os }}-go-
  52. - name: Get dependencies
  53. run: |
  54. go get -v -t -d ./...
  55. if [ -f Gopkg.toml ]; then
  56. curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
  57. dep ensure
  58. fi
  59. working-directory: ./server
  60. - name: Build
  61. run: go build -v . -o output
  62. working-directory: ./server
  63. - name: artifact
  64. uses: actions/upload-artifact@v1
  65. with:
  66. name: artifact
  67. path: output
  68. - name: Run GoReleaser
  69. uses: goreleaser/goreleaser-action@v1
  70. with:
  71. version: latest
  72. args: release --rm-dist
  73. key: ${{ secrets.YOUR_PRIVATE_KEY }}
  74. env:
  75. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}