build-and-release.yml 4.2 KB

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