ci.yml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. name: CI
  2. on:
  3. push:
  4. branches: [main]
  5. pull_request:
  6. schedule:
  7. # Weekly, so newly published vulnerabilities in Go or a dependency
  8. # show up even when nothing has changed here.
  9. - cron: "17 6 * * 1"
  10. permissions:
  11. contents: read
  12. jobs:
  13. lint:
  14. runs-on: ubuntu-latest
  15. steps:
  16. - uses: actions/checkout@v7
  17. # The oldest Go that go.mod allows, so it keeps building there.
  18. - uses: actions/setup-go@v7
  19. with:
  20. go-version-file: go.mod
  21. - name: gofmt
  22. run: |
  23. unformatted=$(gofmt -l .)
  24. if [ -n "$unformatted" ]; then
  25. echo "These files need gofmt:"
  26. echo "$unformatted"
  27. exit 1
  28. fi
  29. - name: go vet
  30. run: go vet ./...
  31. - name: staticcheck
  32. run: go run honnef.co/go/tools/cmd/staticcheck@2026.2.2 ./...
  33. release-build:
  34. # Builds every release binary without publishing, so a broken release
  35. # config shows up on the PR rather than when a version is tagged.
  36. runs-on: ubuntu-latest
  37. steps:
  38. - uses: actions/checkout@v7
  39. with:
  40. fetch-depth: 0
  41. - uses: actions/setup-go@v7
  42. with:
  43. go-version: stable
  44. check-latest: true
  45. - uses: goreleaser/goreleaser-action@v7
  46. with:
  47. version: "~> v2"
  48. args: release --snapshot --clean
  49. vulncheck:
  50. # Reports known vulnerabilities in the Go standard library and the
  51. # dependencies that the code actually calls.
  52. runs-on: ubuntu-latest
  53. steps:
  54. - uses: actions/checkout@v7
  55. - uses: actions/setup-go@v7
  56. with:
  57. go-version: stable
  58. check-latest: true
  59. - name: govulncheck
  60. run: go run golang.org/x/vuln/cmd/govulncheck@v1.9.0 ./...
  61. test:
  62. strategy:
  63. fail-fast: false
  64. matrix:
  65. os: [ubuntu-latest, macos-latest, windows-latest]
  66. runs-on: ${{ matrix.os }}
  67. steps:
  68. - uses: actions/checkout@v7
  69. - uses: actions/setup-go@v7
  70. with:
  71. go-version: stable
  72. check-latest: true
  73. - uses: actions/setup-java@v6
  74. with:
  75. distribution: temurin
  76. java-version: "21"
  77. - name: Download epubcheck
  78. shell: bash
  79. run: |
  80. curl -sSL -o "$RUNNER_TEMP/epubcheck.zip" \
  81. https://github.com/w3c/epubcheck/releases/download/v${EPUBCHECK_VERSION}/epubcheck-${EPUBCHECK_VERSION}.zip
  82. unzip -q "$RUNNER_TEMP/epubcheck.zip" -d "$RUNNER_TEMP"
  83. echo "EPUBCHECK_JAR=$RUNNER_TEMP/epubcheck-${EPUBCHECK_VERSION}/epubcheck.jar" >> "$GITHUB_ENV"
  84. env:
  85. EPUBCHECK_VERSION: "5.2.1"
  86. - name: Test
  87. run: go test -race ./...
  88. - name: Build
  89. run: go build ./cmd/rekopub
  90. - name: Build with build.cmd
  91. if: runner.os == 'Windows'
  92. shell: cmd
  93. run: |
  94. call build.cmd || exit /b 1
  95. rekopub.exe -h || exit /b 1
  96. rekopub.exe -VERSION || exit /b 1