release.yml 4.5 KB

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