Taskfile.yml 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. version: '3'
  2. vars:
  3. BINARY_EXT:
  4. sh: echo '{{if eq OS "windows"}}.exe{{end}}'
  5. tasks:
  6. default:
  7. deps: [build]
  8. web:
  9. desc: Build the binary and start the web server
  10. deps: [build]
  11. cmds:
  12. - ./gogs web
  13. build:
  14. desc: Build the binary
  15. cmds:
  16. - go build -v
  17. -ldflags '
  18. -X "{{.PKG_PATH}}.BuildTime={{.BUILD_TIME}}"
  19. -X "{{.PKG_PATH}}.BuildCommit={{.BUILD_COMMIT}}"
  20. '
  21. -tags '{{.TAGS}}'
  22. -trimpath -o gogs{{.BINARY_EXT}}
  23. vars:
  24. PKG_PATH: gogs.io/gogs/internal/conf
  25. BUILD_TIME:
  26. sh: date -u '+%Y-%m-%d %I:%M:%S %Z'
  27. BUILD_COMMIT:
  28. sh: git rev-parse HEAD
  29. sources:
  30. - go.mod
  31. - gogs.go
  32. - internal/**/*.go
  33. - conf/**/*
  34. - public/**/*
  35. - templates/**/*
  36. - custom/**/*
  37. method: timestamp
  38. generate-schemadoc:
  39. desc: Generate database schema documentation
  40. cmds:
  41. - go generate ./internal/database/schemadoc
  42. generate:
  43. desc: Run all go:generate commands
  44. cmds:
  45. - go generate ./...
  46. test:
  47. desc: Run all tests.
  48. cmds:
  49. - go test -cover -race ./...
  50. clean:
  51. desc: Cleans up system meta files
  52. cmds:
  53. - find . -name "*.DS_Store" -type f -delete
  54. release:
  55. desc: Build the binary and pack resources to a ZIP file
  56. deps: [build]
  57. cmds:
  58. - rm -rf {{.RELEASE_GOGS}}
  59. - mkdir -p {{.RELEASE_GOGS}}
  60. - cp -r gogs{{.BINARY_EXT}} LICENSE README.md README_ZH.md scripts {{.RELEASE_GOGS}}
  61. - cd {{.RELEASE_ROOT}} && zip -r gogs.zip "gogs"
  62. vars:
  63. RELEASE_ROOT: release
  64. RELEASE_GOGS: release/gogs
  65. less:
  66. desc: Generate CSS from LESS files
  67. cmds:
  68. - lessc --clean-css --source-map "public/less/gogs.less" public/css/gogs.min.css
  69. fixme:
  70. desc: Show all occurrences of "FIXME"
  71. cmds:
  72. - grep -rnw "FIXME" internal
  73. todo:
  74. desc: Show all occurrences of "TODO"
  75. cmds:
  76. - grep -rnw "TODO" internal
  77. legacy:
  78. desc: Identify legacy and deprecated lines
  79. cmds:
  80. - grep -rnw "\(LEGACY\|Deprecated\)" internal
  81. drop-test-db:
  82. desc: Drop the test database
  83. cmds:
  84. - |
  85. for dbname in $(psql -Xc "copy (select datname from pg_database where datname like 'gogs-%') to stdout"); do
  86. dropdb "$dbname"
  87. echo "dropped $dbname"
  88. done