release.yml 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. name: Create Release & Upload Assets
  2. on:
  3. push:
  4. # Sequence of patterns matched against refs/tags
  5. tags:
  6. - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
  7. jobs:
  8. test:
  9. name: Lint, Test, Build
  10. runs-on: ubuntu-20.04
  11. strategy:
  12. matrix:
  13. go: [ '1.15', '1.16' ]
  14. outputs:
  15. is_prerelease: ${{ steps.is_prerelease.outputs.IS_PRERELEASE }}
  16. steps:
  17. -
  18. name: Checkout
  19. uses: actions/checkout@v2
  20. -
  21. name: Setup Go
  22. uses: actions/setup-go@v2
  23. with:
  24. go-version: ${{ matrix.go }}
  25. -
  26. name: Install Deps
  27. id: install-deps
  28. run: sudo apt-get -y install libpcsclite-dev
  29. -
  30. name: golangci-lint
  31. uses: golangci/golangci-lint-action@v2
  32. with:
  33. # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
  34. version: 'latest'
  35. # Optional: working directory, useful for monorepos
  36. # working-directory: somedir
  37. # Optional: golangci-lint command line arguments.
  38. args: --timeout=30m
  39. # Optional: show only new issues if it's a pull request. The default value is `false`.
  40. # only-new-issues: true
  41. # Optional: if set to true then the action will use pre-installed Go.
  42. # skip-go-installation: true
  43. # Optional: if set to true then the action don't cache or restore ~/go/pkg.
  44. # skip-pkg-cache: true
  45. # Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
  46. # skip-build-cache: true
  47. -
  48. name: Test, Build
  49. id: lint_test_build
  50. run: V=1 make ci
  51. create_release:
  52. name: Create Release
  53. needs: test
  54. runs-on: ubuntu-20.04
  55. outputs:
  56. is_prerelease: ${{ steps.is_prerelease.outputs.IS_PRERELEASE }}
  57. steps:
  58. -
  59. name: Is Pre-release
  60. id: is_prerelease
  61. run: |
  62. set +e
  63. echo ${{ github.ref }} | grep "\-rc.*"
  64. OUT=$?
  65. if [ $OUT -eq 0 ]; then IS_PRERELEASE=true; else IS_PRERELEASE=false; fi
  66. echo "::set-output name=IS_PRERELEASE::${IS_PRERELEASE}"
  67. -
  68. name: Create Release
  69. id: create_release
  70. uses: actions/create-release@v1
  71. env:
  72. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  73. with:
  74. tag_name: ${{ github.ref }}
  75. release_name: Release ${{ github.ref }}
  76. draft: false
  77. prerelease: ${{ steps.is_prerelease.outputs.IS_PRERELEASE }}
  78. goreleaser:
  79. name: Upload Assets To Github w/ goreleaser
  80. runs-on: ubuntu-20.04
  81. needs: create_release
  82. steps:
  83. -
  84. name: Checkout
  85. uses: actions/checkout@v2
  86. with:
  87. fetch-depth: 0
  88. -
  89. name: Set up Go
  90. uses: actions/setup-go@v2
  91. with:
  92. go-version: 1.16
  93. -
  94. name: Install cosign
  95. uses: sigstore/cosign-installer@main
  96. with:
  97. cosign-release: 'v1.1.0'
  98. -
  99. name: Write cosign key to disk
  100. id: write_key
  101. run: echo "${{ secrets.COSIGN_KEY }}" > "/tmp/cosign.key"
  102. -
  103. name: Run GoReleaser
  104. uses: goreleaser/goreleaser-action@5a54d7e660bda43b405e8463261b3d25631ffe86 # v2.7.0
  105. with:
  106. version: latest
  107. args: release --rm-dist
  108. env:
  109. GITHUB_TOKEN: ${{ secrets.PAT }}
  110. COSIGN_PWD: ${{ secrets.COSIGN_PWD }}
  111. release_deb:
  112. name: Build & Upload Debian Package To Github
  113. runs-on: ubuntu-20.04
  114. needs: create_release
  115. steps:
  116. -
  117. name: Checkout
  118. uses: actions/checkout@v2
  119. with:
  120. fetch-depth: 0
  121. -
  122. name: Set up Go
  123. uses: actions/setup-go@v2
  124. with:
  125. go-version: '1.16'
  126. -
  127. name: APT Install
  128. id: aptInstall
  129. run: sudo apt-get -y install build-essential debhelper fakeroot
  130. -
  131. name: Build Debian package
  132. id: build
  133. run: |
  134. PATH=$PATH:/usr/local/go/bin:/home/admin/go/bin
  135. make debian
  136. -
  137. name: Upload Debian Package
  138. id: upload_deb
  139. run: |
  140. tag_name="${GITHUB_REF##*/}"
  141. hub release edit $(find ./.releases -type f -printf "-a %p ") -m "" "$tag_name"
  142. env:
  143. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  144. build_upload_docker:
  145. name: Build & Upload Docker Images
  146. runs-on: ubuntu-20.04
  147. needs: test
  148. steps:
  149. -
  150. name: Checkout
  151. uses: actions/checkout@v2
  152. -
  153. name: Setup Go
  154. uses: actions/setup-go@v2
  155. with:
  156. go-version: '1.16'
  157. -
  158. name: Install cosign
  159. uses: sigstore/cosign-installer@main
  160. with:
  161. cosign-release: 'v1.1.0'
  162. -
  163. name: Write cosign key to disk
  164. id: write_key
  165. run: echo "${{ secrets.COSIGN_KEY }}" > "/tmp/cosign.key"
  166. -
  167. name: Build
  168. id: build
  169. run: |
  170. PATH=$PATH:/usr/local/go/bin:/home/admin/go/bin
  171. make docker-artifacts
  172. env:
  173. DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
  174. DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
  175. COSIGN_PWD: ${{ secrets.COSIGN_PWD }}