Taskfile.yml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. version: '3'
  2. includes:
  3. website:
  4. aliases: [w, docs, d]
  5. taskfile: ./website
  6. dir: ./website
  7. vars:
  8. BIN: "{{.ROOT_DIR}}/bin"
  9. env:
  10. CGO_ENABLED: '0'
  11. tasks:
  12. default:
  13. cmds:
  14. - task: lint
  15. - task: test
  16. install:
  17. desc: Installs Task
  18. aliases: [i]
  19. sources:
  20. - './**/*.go'
  21. cmds:
  22. - go install -v ./cmd/task
  23. generate:
  24. desc: Runs Mockery to create mocks
  25. aliases: [gen, g]
  26. deps: [install:mockery]
  27. sources:
  28. - "internal/fingerprint/checker.go"
  29. generates:
  30. - "internal/mocks/*.go"
  31. cmds:
  32. - "{{.BIN}}/mockery --dir ./internal/fingerprint --name SourcesCheckable"
  33. - "{{.BIN}}/mockery --dir ./internal/fingerprint --name StatusCheckable"
  34. install:mockery:
  35. desc: Installs mockgen; a tool to generate mock files
  36. vars:
  37. MOCKERY_VERSION: v2.24.0
  38. env:
  39. GOBIN: "{{.BIN}}"
  40. status:
  41. - go version -m {{.BIN}}/mockery | grep github.com/vektra/mockery | grep {{.MOCKERY_VERSION}}
  42. cmds:
  43. - go install github.com/vektra/mockery/v2@{{.MOCKERY_VERSION}}
  44. mod:
  45. desc: Downloads and tidy Go modules
  46. cmds:
  47. - go mod download
  48. - go mod tidy
  49. clean:
  50. desc: Cleans temp files and folders
  51. aliases: [clear]
  52. cmds:
  53. - rm -rf dist/
  54. - rm -rf tmp/
  55. lint:
  56. desc: Runs golangci-lint
  57. aliases: [l]
  58. sources:
  59. - './**/*.go'
  60. - .golangci.yml
  61. cmds:
  62. - golangci-lint run
  63. lint:fix:
  64. desc: Runs golangci-lint and fixes any issues
  65. sources:
  66. - './**/*.go'
  67. - .golangci.yml
  68. cmds:
  69. - golangci-lint run --fix
  70. sleepit:build:
  71. desc: Builds the sleepit test helper
  72. sources:
  73. - ./cmd/sleepit/**/*.go
  74. generates:
  75. - "{{.BIN}}/sleepit"
  76. cmds:
  77. - go build -o {{.BIN}}/sleepit{{exeExt}} ./cmd/sleepit
  78. sleepit:run:
  79. desc: Builds the sleepit test helper
  80. deps: [sleepit:build]
  81. cmds:
  82. - "{{.BIN}}/sleepit {{.CLI_ARGS}}"
  83. silent: true
  84. test:
  85. desc: Runs test suite
  86. aliases: [t]
  87. deps: [install]
  88. cmds:
  89. - go test {{catLines .GO_PACKAGES}}
  90. vars:
  91. GO_PACKAGES:
  92. sh: go list ./...
  93. test:all:
  94. desc: Runs test suite with signals and watch tests included
  95. deps: [install, sleepit:build]
  96. cmds:
  97. - go test {{catLines .GO_PACKAGES}} -tags 'signals watch'
  98. vars:
  99. GO_PACKAGES:
  100. sh: go list ./...
  101. goreleaser:test:
  102. desc: Tests release process without publishing
  103. cmds:
  104. - goreleaser --snapshot --clean
  105. goreleaser:install:
  106. desc: Installs goreleaser
  107. cmds:
  108. - go install github.com/goreleaser/goreleaser@latest
  109. release:*:
  110. desc: Prepare the project for a new release
  111. summary: |
  112. This task will do the following:
  113. - Update the version and date in the CHANGELOG.md file
  114. - Update the version in the package.json and package-lock.json files
  115. - Copy the latest docs to the "current" version on the website
  116. - Commit the changes
  117. - Create a new tag
  118. - Push the commit/tag to the repository
  119. - Create a GitHub release
  120. To use the task, simply run "task release:<version>" where "<version>" is is one of:
  121. - "major" - Bumps the major number
  122. - "minor" - Bumps the minor number
  123. - "patch" - Bumps the patch number
  124. - A semver compatible version number (e.g. "1.2.3")
  125. vars:
  126. VERSION:
  127. sh: "go run ./cmd/release --version {{index .MATCH 0}}"
  128. COMPLETE_MESSAGE: |
  129. Creating release with GoReleaser: https://github.com/go-task/task/actions/workflows/release.yml
  130. Please wait for the CI to finish and then do the following:
  131. - Copy the changelog for v{{.VERSION}} to the GitHub release
  132. - Publish the package to NPM with `task npm:publish`
  133. - Update and push the snapcraft manifest in https://github.com/go-task/snap/blob/main/snap/snapcraft.yaml
  134. preconditions:
  135. - sh: test $(git rev-parse --abbrev-ref HEAD) = "main"
  136. msg: "You must be on the main branch to release"
  137. - sh: "[[ -z $(git diff --shortstat main) ]]"
  138. msg: "You must have a clean working tree to release"
  139. prompt: "Are you sure you want to release version {{.VERSION}}?"
  140. cmds:
  141. - cmd: echo "Releasing v{{.VERSION}}"
  142. silent: true
  143. - "go run ./cmd/release {{.VERSION}}"
  144. - "git add --all"
  145. - "git commit -m v{{.VERSION}}"
  146. - "git push"
  147. - "git tag v{{.VERSION}}"
  148. - "git push origin tag v{{.VERSION}}"
  149. - cmd: printf "%s" '{{.COMPLETE_MESSAGE}}'
  150. silent: true
  151. npm:publish:
  152. desc: Publish release to npm
  153. cmds:
  154. - npm publish --access=public
  155. packages:
  156. cmds:
  157. - echo '{{.GO_PACKAGES}}'
  158. vars:
  159. GO_PACKAGES:
  160. sh: go list ./...
  161. silent: true