build.yml 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. name: Build
  2. on:
  3. push:
  4. branches: [ master ]
  5. tags: [ 'v*' ]
  6. pull_request:
  7. branches: [ master ]
  8. jobs:
  9. # Build and test project
  10. build:
  11. runs-on: ubuntu-latest
  12. steps:
  13. - uses: actions/checkout@v4
  14. with:
  15. submodules: recursive
  16. - uses: actions/setup-go@v4
  17. with:
  18. go-version: stable
  19. - run: make build test
  20. # Create project release if tagged
  21. release:
  22. runs-on: ubuntu-latest
  23. if: startsWith(github.ref, 'refs/tags/')
  24. needs: build
  25. steps:
  26. - uses: actions/checkout@v4
  27. with:
  28. submodules: recursive
  29. - uses: actions/setup-go@v4
  30. with:
  31. go-version: stable
  32. - uses: actions/setup-node@v3
  33. with:
  34. node-version: current
  35. - run: npm install -g standard-changelog
  36. - run: make distribution
  37. - name: get CHANGELOG
  38. id: changelog
  39. uses: requarks/changelog-action@v1
  40. with:
  41. token: ${{ github.token }}
  42. tag: ${{ github.ref_name }}
  43. - uses: softprops/action-gh-release@v1
  44. with:
  45. body: ${{ steps.changelog.outputs.changes }}
  46. files: |
  47. release/webhookd-linux-amd64.tgz
  48. release/webhookd-linux-arm64.tgz
  49. release/webhookd-linux-arm.tgz
  50. release/webhookd-darwin-amd64.tgz
  51. env:
  52. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  53. # Publish Docker image
  54. publish:
  55. runs-on: ubuntu-latest
  56. needs: build
  57. strategy:
  58. fail-fast: false
  59. matrix:
  60. include:
  61. - target: slim
  62. suffix: ''
  63. - target: distrib
  64. suffix: -distrib
  65. steps:
  66. - uses: actions/checkout@v4
  67. with:
  68. submodules: recursive
  69. - name: extract metadata (tags, labels) for Docker
  70. id: meta
  71. uses: docker/metadata-action@v3
  72. with:
  73. images: ncarlier/webhookd
  74. flavor: suffix=${{ matrix.suffix }}
  75. tags: |
  76. type=edge
  77. type=semver,pattern={{major}}
  78. type=semver,pattern={{version}}
  79. - uses: docker/setup-qemu-action@v1
  80. with:
  81. image: tonistiigi/binfmt:latest
  82. platforms: arm64,arm
  83. - uses: docker/setup-buildx-action@v1
  84. - uses: docker/login-action@v1
  85. if: github.event_name != 'pull_request'
  86. with:
  87. username: ${{ secrets.DOCKER_HUB_USERNAME }}
  88. password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
  89. - name: Build and push Docker image (${{ matrix.target }})
  90. uses: docker/build-push-action@v2
  91. with:
  92. context: .
  93. target: ${{ matrix.target }}
  94. platforms: linux/amd64,linux/arm64,linux/arm/v7
  95. push: ${{ github.event_name != 'pull_request' }}
  96. tags: ${{ steps.meta.outputs.tags }}
  97. labels: ${{ steps.meta.outputs.labels }}