build-and-release.yml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. node-version: '22'
  52. cache: 'npm'
  53. cache-dependency-path: frontend/package-lock.json
  54. - name: Setup node
  55. if: github.event_name == 'pull_request'
  56. uses: actions/setup-node@v6.4.0
  57. with:
  58. node-version: '22'
  59. - name: Setup Go
  60. uses: actions/setup-go@v6
  61. with:
  62. go-version-file: 'service/go.mod'
  63. cache: true
  64. cache-dependency-path: 'service/go.mod'
  65. - name: Print go version
  66. run: go version
  67. - name: Login to Docker Hub
  68. uses: docker/login-action@v4
  69. with:
  70. username: ${{ secrets.DOCKERHUB_USERNAME }}
  71. password: ${{ secrets.DOCKERHUB_KEY }}
  72. - name: Login to ghcr
  73. uses: docker/login-action@v3
  74. with:
  75. registry: ghcr.io
  76. username: ${{ github.actor }}
  77. password: ${{ secrets.CONTAINER_TOKEN }}
  78. - name: get date
  79. run: |
  80. echo "DATE=$(date +'%Y-%m-%d')" >> "$GITHUB_ENV"
  81. - name: make webui
  82. run: make -w webui-dist
  83. - name: unit tests
  84. run: make -w service-unittests
  85. - name: build service
  86. run: make -w service
  87. - name: integration tests
  88. run: cd integration-tests && make -w
  89. - name: Archive integration tests
  90. uses: actions/upload-artifact@v7
  91. if: always()
  92. with:
  93. name: "OliveTin-integration-tests-${{ env.DATE }}-${{ github.sha }}"
  94. path: |
  95. integration-tests
  96. !integration-tests/node_modules
  97. - name: Install goreleaser
  98. uses: goreleaser/goreleaser-action@v6
  99. with:
  100. install-only: true
  101. - name: Set up Docker Buildx
  102. uses: docker/setup-buildx-action@v3
  103. - name: release
  104. if: github.ref_type != 'tag'
  105. uses: cycjimmy/semantic-release-action@v4
  106. with:
  107. extra_plugins: |
  108. @semantic-release/commit-analyzer
  109. @semantic-release/exec
  110. @semantic-release/git
  111. env:
  112. GITHUB_TOKEN: ${{ secrets.CONTAINER_TOKEN }}
  113. GH_TOKEN: ${{ secrets.CONTAINER_TOKEN }}
  114. - name: Archive binaries
  115. uses: actions/upload-artifact@v4.3.1
  116. with:
  117. name: "OliveTin-snapshot-${{ env.DATE }}-${{ github.sha }}"
  118. path: dist/OliveTin*.*