build-and-release.yml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. ---
  2. name: "Build & Release pipeline"
  3. on:
  4. pull_request:
  5. paths:
  6. - '.github/workflows/build-and-release.yml'
  7. - '.goreleaser.yml'
  8. - 'Dockerfile.multiarches'
  9. - 'Dockerfile.singlearch'
  10. - 'Makefile'
  11. - 'frontend/**'
  12. - 'integration-tests/**'
  13. - 'proto/**'
  14. - 'service/**'
  15. workflow_dispatch:
  16. push:
  17. tags:
  18. - '*'
  19. branches:
  20. - main
  21. - next
  22. - beta
  23. paths:
  24. - '.github/workflows/build-and-release.yml'
  25. - '.goreleaser.yml'
  26. - 'Dockerfile.multiarches'
  27. - 'Dockerfile.singlearch'
  28. - 'Makefile'
  29. - 'frontend/**'
  30. - 'integration-tests/**'
  31. - 'proto/**'
  32. - 'service/**'
  33. jobs:
  34. build:
  35. runs-on: ubuntu-latest
  36. steps:
  37. - name: Checkout
  38. uses: actions/checkout@v6
  39. with:
  40. fetch-depth: 0
  41. - name: Set up QEMU
  42. id: qemu
  43. uses: docker/setup-qemu-action@v4
  44. with:
  45. image: tonistiigi/binfmt:latest
  46. platforms: arm64,arm
  47. - name: Setup node (npm cache)
  48. if: github.event_name != 'pull_request'
  49. uses: actions/setup-node@v6.4.0
  50. with:
  51. cache: 'npm'
  52. cache-dependency-path: frontend/package-lock.json
  53. - name: Setup node
  54. if: github.event_name == 'pull_request'
  55. uses: actions/setup-node@v6.4.0
  56. - name: Setup Go
  57. uses: actions/setup-go@v6
  58. with:
  59. go-version-file: 'service/go.mod'
  60. cache: true
  61. cache-dependency-path: 'service/go.mod'
  62. - name: Print go version
  63. run: go version
  64. - name: Login to Docker Hub
  65. uses: docker/login-action@v4
  66. with:
  67. username: ${{ secrets.DOCKERHUB_USERNAME }}
  68. password: ${{ secrets.DOCKERHUB_KEY }}
  69. - name: Login to ghcr
  70. uses: docker/login-action@v3
  71. with:
  72. registry: ghcr.io
  73. username: ${{ github.actor }}
  74. password: ${{ secrets.CONTAINER_TOKEN }}
  75. - name: get date
  76. run: |
  77. echo "DATE=$(date +'%Y-%m-%d')" >> "$GITHUB_ENV"
  78. - name: make webui
  79. run: make -w webui-dist
  80. - name: unit tests
  81. run: make -w service-unittests
  82. - name: build service
  83. run: make -w service
  84. - name: integration tests
  85. run: cd integration-tests && make -w
  86. - name: Archive integration tests
  87. uses: actions/upload-artifact@v7
  88. if: always()
  89. with:
  90. name: "OliveTin-integration-tests-${{ env.DATE }}-${{ github.sha }}"
  91. path: |
  92. integration-tests
  93. !integration-tests/node_modules
  94. - name: Install goreleaser
  95. uses: goreleaser/goreleaser-action@v6
  96. with:
  97. install-only: true
  98. - name: Set up Docker Buildx
  99. uses: docker/setup-buildx-action@v3
  100. - name: release
  101. if: github.ref_type != 'tag'
  102. uses: cycjimmy/semantic-release-action@v4
  103. with:
  104. extra_plugins: |
  105. @semantic-release/commit-analyzer
  106. @semantic-release/exec
  107. @semantic-release/git
  108. env:
  109. GITHUB_TOKEN: ${{ secrets.CONTAINER_TOKEN }}
  110. GH_TOKEN: ${{ secrets.CONTAINER_TOKEN }}
  111. - name: Archive binaries
  112. uses: actions/upload-artifact@v4.3.1
  113. with:
  114. name: "OliveTin-snapshot-${{ env.DATE }}-${{ github.sha }}"
  115. path: dist/OliveTin*.*