release.yml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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.18', '1.19' ]
  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. version: ${{ secrets.GOLANGCI_LINT_VERSION }}
  34. args: --timeout=30m
  35. -
  36. name: Test, Build
  37. id: lint_test_build
  38. run: V=1 make ci
  39. create_release:
  40. name: Create Release
  41. needs: test
  42. runs-on: ubuntu-20.04
  43. outputs:
  44. debversion: ${{ steps.extract-tag.outputs.DEB_VERSION }}
  45. is_prerelease: ${{ steps.is_prerelease.outputs.IS_PRERELEASE }}
  46. steps:
  47. -
  48. name: Extract Tag Names
  49. id: extract-tag
  50. run: |
  51. DEB_VERSION=$(echo ${GITHUB_REF#refs/tags/v} | sed 's/-/./')
  52. echo "::set-output name=DEB_VERSION::${DEB_VERSION}"
  53. -
  54. name: Is Pre-release
  55. id: is_prerelease
  56. run: |
  57. set +e
  58. echo ${{ github.ref }} | grep "\-rc.*"
  59. OUT=$?
  60. if [ $OUT -eq 0 ]; then IS_PRERELEASE=true; else IS_PRERELEASE=false; fi
  61. echo "::set-output name=IS_PRERELEASE::${IS_PRERELEASE}"
  62. -
  63. name: Create Release
  64. id: create_release
  65. uses: actions/create-release@v1
  66. env:
  67. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  68. with:
  69. tag_name: ${{ github.ref }}
  70. release_name: Release ${{ github.ref }}
  71. draft: false
  72. prerelease: ${{ steps.is_prerelease.outputs.IS_PRERELEASE }}
  73. goreleaser:
  74. name: Upload Assets To Github w/ goreleaser
  75. runs-on: ubuntu-20.04
  76. needs: create_release
  77. steps:
  78. -
  79. name: Checkout
  80. uses: actions/checkout@v2
  81. with:
  82. fetch-depth: 0
  83. -
  84. name: Set up Go
  85. uses: actions/setup-go@v2
  86. with:
  87. go-version: 1.19
  88. -
  89. name: APT Install
  90. id: aptInstall
  91. run: sudo apt-get -y install build-essential debhelper fakeroot
  92. -
  93. name: Build Debian package
  94. id: make_debian
  95. run: |
  96. PATH=$PATH:/usr/local/go/bin:/home/admin/go/bin
  97. make debian
  98. # need to restore the git state otherwise goreleaser fails due to dirty state
  99. git restore debian/changelog
  100. git clean -fd
  101. -
  102. name: Install cosign
  103. uses: sigstore/cosign-installer@v1.1.0
  104. with:
  105. cosign-release: 'v1.1.0'
  106. -
  107. name: Write cosign key to disk
  108. id: write_key
  109. run: echo "${{ secrets.COSIGN_KEY }}" > "/tmp/cosign.key"
  110. -
  111. name: Get Release Date
  112. id: release_date
  113. run: |
  114. RELEASE_DATE=$(date +"%y-%m-%d")
  115. echo "::set-output name=RELEASE_DATE::${RELEASE_DATE}"
  116. -
  117. name: Run GoReleaser
  118. uses: goreleaser/goreleaser-action@5a54d7e660bda43b405e8463261b3d25631ffe86 # v2.7.0
  119. with:
  120. version: 'v1.7.0'
  121. args: release --rm-dist
  122. env:
  123. GITHUB_TOKEN: ${{ secrets.PAT }}
  124. COSIGN_PWD: ${{ secrets.COSIGN_PWD }}
  125. DEB_VERSION: ${{ needs.create_release.outputs.debversion }}
  126. RELEASE_DATE: ${{ steps.release_date.outputs.RELEASE_DATE }}
  127. build_upload_docker:
  128. name: Build & Upload Docker Images
  129. runs-on: ubuntu-20.04
  130. needs: test
  131. steps:
  132. -
  133. name: Checkout
  134. uses: actions/checkout@v2
  135. -
  136. name: Setup Go
  137. uses: actions/setup-go@v2
  138. with:
  139. go-version: '1.19'
  140. -
  141. name: Install cosign
  142. uses: sigstore/cosign-installer@v1.1.0
  143. with:
  144. cosign-release: 'v1.1.0'
  145. -
  146. name: Write cosign key to disk
  147. id: write_key
  148. run: echo "${{ secrets.COSIGN_KEY }}" > "/tmp/cosign.key"
  149. -
  150. name: Build
  151. id: build
  152. run: |
  153. PATH=$PATH:/usr/local/go/bin:/home/admin/go/bin
  154. make docker-artifacts
  155. env:
  156. DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
  157. DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
  158. COSIGN_PWD: ${{ secrets.COSIGN_PWD }}