|
| 1 | +name: Build |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - master |
| 6 | + schedule: |
| 7 | + - cron: '0 1 * * *' # UTC |
| 8 | + |
| 9 | +jobs: |
| 10 | + build: |
| 11 | + name: Build pt3_drv deb package |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - uses: actions/checkout@v4 |
| 15 | + |
| 16 | + - name: Clone m-tsudo/pt3 |
| 17 | + run: git clone --depth=5 https://github.com/m-tsudo/pt3.git |
| 18 | + |
| 19 | + - name: Get pt3 repo status |
| 20 | + working-directory: pt3 |
| 21 | + run: | |
| 22 | + echo COMMIT_HASH=$(git rev-parse --short HEAD) >> $GITHUB_ENV |
| 23 | + echo TAG_NAME=v$(grep PACKAGE_VERSION dkms.conf | cut -d'"' -f2) >> $GITHUB_ENV |
| 24 | +
|
| 25 | + - name: Get last release info |
| 26 | + id: last_release |
| 27 | + uses: cardinalby/git-get-release-action@v1 |
| 28 | + env: |
| 29 | + GITHUB_TOKEN: ${{ github.token }} |
| 30 | + with: |
| 31 | + latest: true |
| 32 | + |
| 33 | + - name: Check updates |
| 34 | + run: | |
| 35 | + LAST_HASH=$(echo "${{ steps.last_release.outputs.name }}" | cut -d'-' -f2) |
| 36 | + if [ "${COMMIT_HASH}" != "${LAST_HASH}" ]; then |
| 37 | + echo RUN_BUILD=yes >> $GITHUB_ENV |
| 38 | + fi |
| 39 | + echo "COMMIT_HASH: ${LAST_HASH} => ${COMMIT_HASH}" |
| 40 | +
|
| 41 | + - name: Setup apt packages |
| 42 | + if: env.RUN_BUILD == 'yes' |
| 43 | + run: sudo apt-get install -y debhelper devscripts dh-exec dkms dpkg |
| 44 | + |
| 45 | + - name: Copy files |
| 46 | + if: env.RUN_BUILD == 'yes' |
| 47 | + run: | |
| 48 | + cp post_install.sh post_remove.sh pt3/ |
| 49 | + cp blacklist-dvb-pt3.conf pt3/etc/ |
| 50 | +
|
| 51 | + - name: Modify dkms.conf |
| 52 | + if: env.RUN_BUILD == 'yes' |
| 53 | + working-directory: pt3 |
| 54 | + run: | |
| 55 | + sed -i 's/ dkms"/ pt3_drv.ko"/' dkms.conf |
| 56 | + echo 'POST_INSTALL="post_install.sh"' >> dkms.conf |
| 57 | + echo 'POST_REMOVE="post_remove.sh"' >> dkms.conf |
| 58 | +
|
| 59 | + - name: Fix mkdeb |
| 60 | + if: env.RUN_BUILD == 'yes' |
| 61 | + working-directory: pt3 |
| 62 | + run: | |
| 63 | + cp -r /etc/dkms/template-dkms-mkdeb pt3_drv-dkms-mkdeb |
| 64 | + sed -i 's/chmod 644 -R/#chmod 644 -R/' pt3_drv-dkms-mkdeb/Makefile |
| 65 | +
|
| 66 | + - name: Build deb package |
| 67 | + if: env.RUN_BUILD == 'yes' |
| 68 | + working-directory: pt3 |
| 69 | + run: dkms mkdeb --source-only |
| 70 | + |
| 71 | + - name: Generate Release Notes |
| 72 | + if: env.RUN_BUILD == 'yes' |
| 73 | + working-directory: pt3 |
| 74 | + run: | |
| 75 | + echo '### The latest five updates are:' >> ../ReleaseNotes.md |
| 76 | + git log -"5" --format="- [\`%h\`](https://github.com/m-tsudo/pt3/commit/%H) %s" >> ../ReleaseNotes.md |
| 77 | +
|
| 78 | + - name: Publish GitHub Release |
| 79 | + if: env.RUN_BUILD == 'yes' |
| 80 | + uses: ncipollo/release-action@v1.14.0 |
| 81 | + with: |
| 82 | + name: ${{ env.TAG_NAME }}-${{ env.COMMIT_HASH }} |
| 83 | + bodyFile: ReleaseNotes.md |
| 84 | + artifacts: ./*.deb |
| 85 | + tag: ${{ env.TAG_NAME }}-${{ env.COMMIT_HASH }} |
| 86 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 87 | + |
| 88 | + - name: Discord notification |
| 89 | + uses: sarisia/actions-status-discord@v1 |
| 90 | + if: env.RUN_BUILD == 'yes' |
| 91 | + with: |
| 92 | + webhook: ${{ secrets.DISCORD_WEBHOOK }} |
| 93 | + content: | |
| 94 | + A new pt3 deb package has been built. See below. |
| 95 | + - https://github.com/b00t0x/pt3-deb-builder/releases |
| 96 | + - https://github.com/m-tsudo/pt3 |
0 commit comments