|
| 1 | +name: Build Tailscale QNAP QPKG |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + # 每周一 3:00 UTC 检查一次 |
| 6 | + - cron: '0 3 * * 1' |
| 7 | + workflow_dispatch: # 允许手动点击启动 |
| 8 | + |
| 9 | +jobs: |
| 10 | + check-and-build: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + |
| 13 | + steps: |
| 14 | + - name: Checkout workflow repo |
| 15 | + uses: actions/checkout@v4 |
| 16 | + |
| 17 | + - name: Fetch latest Tailscale release |
| 18 | + id: tailscale_release |
| 19 | + run: | |
| 20 | + latest_tag=$(curl -s https://api.github.com/repos/tailscale/tailscale/releases/latest | jq -r .tag_name) |
| 21 | + echo "Latest Tailscale tag: $latest_tag" |
| 22 | + echo "latest_tag=$latest_tag" >> $GITHUB_ENV |
| 23 | +
|
| 24 | + - name: Check last built version |
| 25 | + id: check_last_build |
| 26 | + run: | |
| 27 | + if [ -f .last_built_version ]; then |
| 28 | + last_built=$(cat .last_built_version) |
| 29 | + echo "Last built version: $last_built" |
| 30 | + else |
| 31 | + last_built="" |
| 32 | + fi |
| 33 | + echo "last_built=$last_built" >> $GITHUB_ENV |
| 34 | +
|
| 35 | + - name: Decide whether to build |
| 36 | + id: should_build |
| 37 | + run: | |
| 38 | + if [ "$latest_tag" != "$last_built" ]; then |
| 39 | + echo "need_build=true" >> $GITHUB_ENV |
| 40 | + else |
| 41 | + echo "need_build=false" >> $GITHUB_ENV |
| 42 | + fi |
| 43 | +
|
| 44 | + - name: Clone tailscale source |
| 45 | + if: env.need_build == 'true' || github.event_name == 'workflow_dispatch' |
| 46 | + run: | |
| 47 | + git clone --branch ${{ env.latest_tag }} https://github.com/tailscale/tailscale.git |
| 48 | +
|
| 49 | + - name: Build QPKG Package |
| 50 | + if: env.need_build == 'true' || github.event_name == 'workflow_dispatch' |
| 51 | + run: | |
| 52 | + chmod +x ./build-qpkg.sh |
| 53 | + ./build-qpkg.sh ${{ env.latest_tag }} |
| 54 | +
|
| 55 | + - name: Save built version |
| 56 | + if: env.need_build == 'true' |
| 57 | + run: | |
| 58 | + echo "${{ env.latest_tag }}" > .last_built_version |
| 59 | +
|
| 60 | + - name: Upload QPKG artifact |
| 61 | + if: env.need_build == 'true' || github.event_name == 'workflow_dispatch' |
| 62 | + uses: actions/upload-artifact@v4 |
| 63 | + with: |
| 64 | + name: tailscale-qpkg-${{ env.latest_tag }} |
| 65 | + path: ./output/tailscale-*.qpkg |
| 66 | + |
| 67 | + # 可选:自动发布 release |
| 68 | + # - name: Create GitHub Release |
| 69 | + # if: env.need_build == 'true' || github.event_name == 'workflow_dispatch' |
| 70 | + # uses: softprops/action-gh-release@v2 |
| 71 | + # with: |
| 72 | + # tag_name: ${{ env.latest_tag }} |
| 73 | + # name: "Tailscale QPKG ${{ env.latest_tag }}" |
| 74 | + # files: ./output/tailscale-*.qpkg |
0 commit comments