release.yml 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. name: Release
  2. # Controls when the workflow will run
  3. on:
  4. # Triggers the workflow on push or pull request events but only for the main branch
  5. push:
  6. branches: [ main ]
  7. #tags:
  8. # - '*'
  9. pull_request:
  10. branches: [ main ]
  11. release:
  12. types: [published]
  13. # Allows you to run this workflow manually from the Actions tab
  14. workflow_dispatch:
  15. jobs:
  16. build:
  17. strategy:
  18. matrix:
  19. # Include amd64 on Linux and drawin.
  20. goos: [linux, darwin]
  21. goarch: [amd64, 386]
  22. exclude:
  23. # Exclude i386 on darwin.
  24. - goarch: 386
  25. goos: darwin
  26. include:
  27. - goos: darwin
  28. goarch: arm64
  29. - goos: linux
  30. goarch: arm64
  31. fail-fast: false
  32. runs-on: ubuntu-latest
  33. env:
  34. GOOS: ${{ matrix.goos }}
  35. GOARCH: ${{ matrix.goarch }}
  36. GOARM: ${{ matrix.goarm }}
  37. CGO_ENABLED: 0
  38. steps:
  39. - name: Checkout
  40. uses: actions/checkout@v2
  41. - name: Setup Go
  42. uses: actions/setup-go@v2
  43. with:
  44. go-version: 1.17
  45. - name: Get project dependencies
  46. run: go mod download
  47. - name: Build
  48. run: |
  49. mkdir -p build_assets
  50. go build -v -o build_assets/oci-help -trimpath -ldflags "-s -w -buildid=" ./...
  51. - name: Show workflow information
  52. id: get_filename
  53. run: |
  54. export _NAME=$(jq ".[\"$GOOS-$GOARCH$GOARM\"].friendlyName" -r < .github/build/friendly-filenames.json)
  55. echo "GOOS: $GOOS, GOARCH: $GOARCH, GOARM: $GOARM, RELEASE_NAME: $_NAME"
  56. echo "::set-output name=ASSET_NAME::$_NAME"
  57. echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV
  58. - name: Create ZIP archive
  59. run: |
  60. pushd build_assets || exit 1
  61. zip -9vr ../oci-help-$ASSET_NAME.zip .
  62. popd || exit 1
  63. FILE=./oci-help-$ASSET_NAME.zip
  64. DGST=$FILE.dgst
  65. for METHOD in {"md5","sha1","sha256","sha512"}
  66. do
  67. openssl dgst -$METHOD $FILE | sed 's/([^)]*)//g' >>$DGST
  68. done
  69. - name: Upload ZIP file to Artifacts
  70. uses: actions/upload-artifact@v2
  71. with:
  72. name: oci-help-${{ steps.get_filename.outputs.ASSET_NAME }}.zip
  73. path: oci-help-${{ steps.get_filename.outputs.ASSET_NAME }}.zip
  74. - name: Upload Release
  75. uses: softprops/action-gh-release@v1
  76. if: startsWith(github.ref, 'refs/tags/')
  77. with:
  78. files: ./oci-help-${{ steps.get_filename.outputs.ASSET_NAME }}.zip*
  79. #draft: true
  80. #prerelease: true