deb.yml 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. name: Build debian packages
  2. on:
  3. workflow_dispatch:
  4. inputs:
  5. tag:
  6. description: "The tag version you want to build. Leave it empty to use the latest one."
  7. pull_request:
  8. types: [opened, synchronize, reopened]
  9. paths:
  10. - ".github/workflows/deb.yml"
  11. - "release/debian/*"
  12. jobs:
  13. package:
  14. if: github.repository == 'v2fly/v2ray-core'
  15. runs-on: ubuntu-latest
  16. container: golang:1.17-bullseye
  17. steps:
  18. - name: Update & install dependencies
  19. run: |
  20. apt-get update
  21. apt-get install -y git wget
  22. - name: Get tag
  23. if: ${{ github.event_name == 'workflow_dispatch' }}
  24. id: tag
  25. run: |
  26. latest_tag=$(curl -sSL --retry 5 "https://api.github.com/repos/v2fly/v2ray-core/releases/latest" | jq .tag_name | awk -F '"' '{print $2}')
  27. if [[ -z "${{ github.event.inputs.tag }}" ]]; then
  28. echo "Use the latest release tag of v2ray-core: ${latest_tag}"
  29. echo ::set-output name=tag::${latest_tag}
  30. else
  31. echo "Use tag: ${{ github.event.inputs.tag }}"
  32. echo ::set-output name=tag::${{ github.event.inputs.tag }}
  33. fi
  34. - name: Checkout codebase on a specific tag for `workflow_dispatch` event
  35. if: ${{ github.event_name == 'workflow_dispatch' }}
  36. uses: actions/checkout@v2
  37. with:
  38. ref: ${{ steps.tag.outputs.tag }}
  39. fetch-depth: 0
  40. - name: Checkout codebase on the triggered commit for other events
  41. if: ${{ github.event_name != 'workflow_dispatch' }}
  42. uses: actions/checkout@v2
  43. - name: Override file `release/debian/changelog` to get the latest CHANGELOG
  44. if: ${{ github.event_name == 'workflow_dispatch' }}
  45. run: |
  46. curl --fail "https://raw.githubusercontent.com/v2fly/v2ray-core/${github.ref_name}/release/debian/changelog" > release/debian/changelog
  47. - name: Download geo files
  48. run: |
  49. wget -O release/config/geoip.dat "https://raw.githubusercontent.com/v2fly/geoip/release/geoip.dat"
  50. wget -O release/config/geoip-only-cn-private.dat "https://raw.githubusercontent.com/v2fly/geoip/release/geoip-only-cn-private.dat"
  51. wget -O release/config/geosite.dat "https://raw.githubusercontent.com/v2fly/domain-list-community/release/dlc.dat"
  52. - name: Install build dependencies
  53. run: |
  54. apt-get install -y build-essential dh-golang reprepro
  55. - name: Build
  56. run: |
  57. echo "PATH=${PATH}"
  58. cp -r release/debian .
  59. dpkg-buildpackage -us -uc -i -b -d
  60. - name: Copy binary
  61. run: |
  62. cp ../*.deb ./
  63. - name: Upload artifact
  64. uses: actions/upload-artifact@v2
  65. with:
  66. name: v2ray-debian-packages
  67. path: ./*.deb
  68. - name: Setup Repository
  69. if: ${{ github.event_name == 'workflow_dispatch' }}
  70. run: |
  71. git clone https://github.com/v2fly/debian.git archive
  72. echo ${{ secrets.DEBIAN_GPG_PRIVATE }} | base64 -d > private.key
  73. gpg --import --batch private.key
  74. gpg -K
  75. cd archive
  76. git config --local user.name "${{ github.actor }}"
  77. git config --local user.email "${{ github.actor }}@users.noreply.github.com"
  78. git remote set-url origin https://${{ github.actor }}:${{ secrets.DEBIAN_REPO_TOKEN }}@github.com/v2fly/debian.git
  79. reprepro includedeb stable ../*.deb
  80. git add -A
  81. git commit -am 'update'
  82. git push origin main