release.yml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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', '1.17' ]
  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.17
  93. -
  94. name: APT Install
  95. id: aptInstall
  96. run: sudo apt-get -y install build-essential debhelper fakeroot
  97. -
  98. name: Build Debian package
  99. id: make_debian
  100. run: |
  101. PATH=$PATH:/usr/local/go/bin:/home/admin/go/bin
  102. make debian
  103. # need to restore the git state otherwise goreleaser fails due to dirty state
  104. git restore debian/changelog
  105. git clean -fd
  106. -
  107. name: Install cosign
  108. uses: sigstore/cosign-installer@v1.1.0
  109. with:
  110. cosign-release: 'v1.1.0'
  111. -
  112. name: Write cosign key to disk
  113. id: write_key
  114. run: echo "${{ secrets.COSIGN_KEY }}" > "/tmp/cosign.key"
  115. -
  116. name: Run GoReleaser
  117. uses: goreleaser/goreleaser-action@5a54d7e660bda43b405e8463261b3d25631ffe86 # v2.7.0
  118. with:
  119. version: latest
  120. args: release --rm-dist
  121. env:
  122. GITHUB_TOKEN: ${{ secrets.PAT }}
  123. COSIGN_PWD: ${{ secrets.COSIGN_PWD }}
  124. build_upload_docker:
  125. name: Build & Upload Docker Images
  126. runs-on: ubuntu-20.04
  127. needs: test
  128. steps:
  129. -
  130. name: Checkout
  131. uses: actions/checkout@v2
  132. -
  133. name: Setup Go
  134. uses: actions/setup-go@v2
  135. with:
  136. go-version: '1.17'
  137. -
  138. name: Install cosign
  139. uses: sigstore/cosign-installer@v1.1.0
  140. with:
  141. cosign-release: 'v1.1.0'
  142. -
  143. name: Write cosign key to disk
  144. id: write_key
  145. run: echo "${{ secrets.COSIGN_KEY }}" > "/tmp/cosign.key"
  146. -
  147. name: Build
  148. id: build
  149. run: |
  150. PATH=$PATH:/usr/local/go/bin:/home/admin/go/bin
  151. make docker-artifacts
  152. env:
  153. DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
  154. DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
  155. COSIGN_PWD: ${{ secrets.COSIGN_PWD }}