release.yml 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. name: Build and Release
  2. on:
  3. workflow_dispatch:
  4. release:
  5. types: [published]
  6. jobs:
  7. build:
  8. strategy:
  9. matrix:
  10. # Include amd64 on all platforms.
  11. goos: [windows, freebsd, openbsd, linux, dragonfly, darwin]
  12. goarch: [amd64, 386]
  13. exclude:
  14. # Exclude i386 on darwin and dragonfly.
  15. - goarch: 386
  16. goos: dragonfly
  17. - goarch: 386
  18. goos: darwin
  19. include:
  20. # BEIGIN MacOS ARM64
  21. - goos: darwin
  22. goarch: arm64
  23. # END MacOS ARM64
  24. # BEGIN Linux ARM 5 6 7
  25. - goos: linux
  26. goarch: arm
  27. goarm: 7
  28. - goos: linux
  29. goarch: arm
  30. goarm: 6
  31. - goos: linux
  32. goarch: arm
  33. goarm: 5
  34. # END Linux ARM 5 6 7
  35. # BEGIN Android ARM 8
  36. - goos: android
  37. goarch: arm64
  38. # END Android ARM 8
  39. # Windows ARM 7
  40. - goos: windows
  41. goarch: arm
  42. goarm: 7
  43. # BEGIN Other architectures
  44. # BEGIN riscv64 & ARM64
  45. - goos: linux
  46. goarch: arm64
  47. - goos: linux
  48. goarch: riscv64
  49. # END riscv64 & ARM64
  50. # BEGIN MIPS
  51. - goos: linux
  52. goarch: mips64
  53. - goos: linux
  54. goarch: mips64le
  55. - goos: linux
  56. goarch: mipsle
  57. - goos: linux
  58. goarch: mips
  59. # END MIPS
  60. # BEGIN PPC
  61. - goos: linux
  62. goarch: ppc64
  63. - goos: linux
  64. goarch: ppc64le
  65. # END PPC
  66. # BEGIN FreeBSD ARM
  67. - goos: freebsd
  68. goarch: arm64
  69. - goos: freebsd
  70. goarch: arm
  71. goarm: 7
  72. # END FreeBSD ARM
  73. # BEGIN S390X
  74. - goos: linux
  75. goarch: s390x
  76. # END S390X
  77. # END Other architectures
  78. # BEGIN OPENBSD ARM
  79. - goos: openbsd
  80. goarch: arm64
  81. - goos: openbsd
  82. goarch: arm
  83. goarm: 7
  84. # END OPENBSD ARM
  85. fail-fast: false
  86. runs-on: ubuntu-latest
  87. env:
  88. GOOS: ${{ matrix.goos }}
  89. GOARCH: ${{ matrix.goarch }}
  90. GOARM: ${{ matrix.goarm }}
  91. CGO_ENABLED: 0
  92. steps:
  93. - name: Checkout codebase
  94. uses: actions/checkout@v2
  95. - name: Show workflow information
  96. id: get_filename
  97. run: |
  98. export _NAME=$(jq ".[\"$GOOS-$GOARCH$GOARM$GOMIPS\"].friendlyName" -r < .github/build/friendly-filenames.json)
  99. echo "GOOS: $GOOS, GOARCH: $GOARCH, GOARM: $GOARM, GOMIPS: $GOMIPS, RELEASE_NAME: $_NAME"
  100. echo "::set-output name=ASSET_NAME::$_NAME"
  101. echo "::set-output name=GIT_TAG::${GITHUB_REF##*/}"
  102. echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV
  103. - name: Set up Go
  104. uses: actions/setup-go@v5
  105. with:
  106. go-version: ^1.22
  107. - name: Get project dependencies
  108. run: go mod download
  109. - name: Build Transfersh
  110. run: |
  111. mkdir -p build_assets
  112. go build -tags netgo -ldflags "-X github.com/dutchcoders/transfer.sh/cmd.Version=${GITHUB_REF##*/} -a -s -w -extldflags '-static'" -o build_assets/transfersh-${GITHUB_REF##*/}-${ASSET_NAME}
  113. - name: Build Mips softfloat Transfersh
  114. if: matrix.goarch == 'mips' || matrix.goarch == 'mipsle'
  115. run: |
  116. GOMIPS=softfloat go build -tags netgo -ldflags "-X github.com/dutchcoders/transfer.sh/cmd.Version=${GITHUB_REF##*/} -a -s -w -extldflags '-static'" -o build_assets/transfersh-softfloat-${GITHUB_REF##*/}-${ASSET_NAME}
  117. - name: Rename Windows Transfersh
  118. if: matrix.goos == 'windows'
  119. run: |
  120. cd ./build_assets || exit 1
  121. mv transfersh-${GITHUB_REF##*/}-${ASSET_NAME} transfersh-${GITHUB_REF##*/}-${ASSET_NAME}.exe
  122. - name: Prepare to release
  123. run: |
  124. cp ${GITHUB_WORKSPACE}/README.md ./build_assets/README.md
  125. cp ${GITHUB_WORKSPACE}/LICENSE ./build_assets/LICENSE
  126. - name: Create Gzip archive
  127. shell: bash
  128. run: |
  129. pushd build_assets || exit 1
  130. touch -mt $(date +%Y01010000) *
  131. tar zcvf transfersh-${GITHUB_REF##*/}-${ASSET_NAME}.tar.gz *
  132. mv transfersh-${GITHUB_REF##*/}-${ASSET_NAME}.tar.gz ../
  133. FILE=`find . -name "transfersh-${GITHUB_REF##*/}-${ASSET_NAME}*"`
  134. DGST=$FILE.sha256sum
  135. echo `sha256sum $FILE` > $DGST
  136. popd || exit 1
  137. FILE=./transfersh-${GITHUB_REF##*/}-${ASSET_NAME}.tar.gz
  138. DGST=$FILE.sha256sum
  139. echo `sha256sum $FILE` > $DGST
  140. - name: Change the name
  141. run: |
  142. mv build_assets transfersh-${GITHUB_REF##*/}-${ASSET_NAME}
  143. - name: Upload files to Artifacts
  144. uses: actions/upload-artifact@v2
  145. with:
  146. name: transfersh-${{ steps.get_filename.outputs.GIT_TAG }}-${{ steps.get_filename.outputs.ASSET_NAME }}
  147. path: |
  148. ./transfersh-${{ steps.get_filename.outputs.GIT_TAG }}-${{ steps.get_filename.outputs.ASSET_NAME }}/*
  149. - name: Upload binaries to release
  150. uses: softprops/action-gh-release@v1
  151. if: github.event_name == 'release'
  152. with:
  153. files: |
  154. ./transfersh-${{ steps.get_filename.outputs.GIT_TAG }}-${{ steps.get_filename.outputs.ASSET_NAME }}.tar.gz*
  155. ./transfersh-${{ steps.get_filename.outputs.GIT_TAG }}-${{ steps.get_filename.outputs.ASSET_NAME }}/transfersh-${{ steps.get_filename.outputs.GIT_TAG }}-${{ steps.get_filename.outputs.ASSET_NAME }}*
  156. env:
  157. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}