|
| 1 | +name:Update AdGuard Home |
| 2 | +on: |
| 3 | +workflow_dispatch: |
| 4 | +schedule: |
| 5 | + -cron:"0 17 * * *" |
| 6 | +push: |
| 7 | +branches: |
| 8 | + -main |
| 9 | +paths-ignore: |
| 10 | + -"README.md" |
| 11 | + -".github/workflows/delete-old-workflows.yml" |
| 12 | + -".github/workflows/update-dashboard.yml" |
| 13 | + -".github/workflows/update-mihomo.yml" |
| 14 | + -".github/workflows/update-singbox.yml" |
| 15 | + |
| 16 | +jobs: |
| 17 | +go: |
| 18 | +runs-on:ubuntu-latest |
| 19 | +outputs: |
| 20 | +version:${{ steps.go.outputs.version }} |
| 21 | +steps: |
| 22 | + -name:Get `Go` latest version |
| 23 | +id:go |
| 24 | +run:| |
| 25 | + echo version=$(curl -sSL https://raw.githubusercontent.com/actions/go-versions/update-versions-manifest-file/versions-manifest.json | jq -r '.[0].version') >> $GITHUB_OUTPUT |
| 26 | +
|
| 27 | +node: |
| 28 | +runs-on:ubuntu-latest |
| 29 | +outputs: |
| 30 | +version:${{ steps.node.outputs.version }} |
| 31 | +steps: |
| 32 | + -name:Get `Node` latest version (LTS) |
| 33 | +id:node |
| 34 | +run:| |
| 35 | + echo version=$(curl -sSL https://nodejs.org/dist/index.json | jq -r 'map(select(.lts)) | .[0].version[1:]') >> $GITHUB_OUTPUT |
| 36 | +
|
| 37 | +release: |
| 38 | +runs-on:ubuntu-latest |
| 39 | +outputs: |
| 40 | +release_version:${{ steps.release.outputs.release_version }} |
| 41 | +release_time:${{ steps.release.outputs.release_time }} |
| 42 | +steps: |
| 43 | + -name:Get `AdGuard Home Release` version and time |
| 44 | +id:release |
| 45 | +run:| |
| 46 | + release_version=$(curl -sSL https://api.github.com/repos/AdguardTeam/AdGuardHome/releases/latest | jq -r '.tag_name') |
| 47 | + echo "release_version=$release_version" >> $GITHUB_OUTPUT |
| 48 | + release_time=$(curl -sSL https://api.github.com/repos/AdguardTeam/AdGuardHome/releases/latest | jq -r '.created_at' | xargs -I {} date -d '{} +8 hours' '+%Y-%m-%d') |
| 49 | + echo "release_time=$release_time" >> $GITHUB_OUTPUT |
| 50 | +
|
| 51 | +release_cross: |
| 52 | +runs-on:ubuntu-latest |
| 53 | +strategy: |
| 54 | +matrix: |
| 55 | +include: |
| 56 | +# Linux |
| 57 | + -{ name: linux_amd64, goos: linux, goarch: amd64, goamd64: v1 } |
| 58 | + -{ name: linux_armv5, goos: linux, goarch: arm, goarm: 5 } |
| 59 | + -{ name: linux_armv6, goos: linux, goarch: arm, goarm: 6 } |
| 60 | + -{ name: linux_armv7, goos: linux, goarch: arm, goarm: 7 } |
| 61 | + -{ name: linux_arm64, goos: linux, goarch: arm64 } |
| 62 | + -{ name: linux_mips_softfloat, goos: linux, goarch: mips, gomips: softfloat } |
| 63 | + -{ name: linux_mipsle_softfloat, goos: linux, goarch: mipsle, gomips: softfloat } |
| 64 | +# Windows |
| 65 | + -{ name: windows_amd64, goos: windows, goarch: amd64, goamd64: v1 } |
| 66 | + -{ name: windows_arm64, goos: windows, goarch: arm64 } |
| 67 | + |
| 68 | +fail-fast:false |
| 69 | +needs: |
| 70 | + -go |
| 71 | + -node |
| 72 | + -release |
| 73 | +env: |
| 74 | +release_VERSION:${{ needs.release.outputs.release_version }} |
| 75 | +steps: |
| 76 | + -name:Checkout `AdguardTeam/AdGuardHome` |
| 77 | +uses:actions/checkout@v4 |
| 78 | +with: |
| 79 | +repository:AdguardTeam/AdGuardHome |
| 80 | + |
| 81 | + -name:Setup `Go` |
| 82 | +uses:actions/setup-go@v5 |
| 83 | +with: |
| 84 | +go-version:${{ needs.go.outputs.version }} |
| 85 | + |
| 86 | + -name:Adapt `Go` version |
| 87 | +run:| |
| 88 | + go get go@${{ needs.go.outputs.version }} |
| 89 | + go mod tidy |
| 90 | +
|
| 91 | + -name:Setup `Node` |
| 92 | +uses:actions/setup-node@v4 |
| 93 | +with: |
| 94 | +node-version:${{ needs.node.outputs.version }} |
| 95 | + |
| 96 | + -name:Setup `Snapcraft` |
| 97 | +run:| |
| 98 | + sudo snap install snapcraft --classic |
| 99 | +
|
| 100 | + -name:Build `AdGuard Home Release` |
| 101 | +id:build |
| 102 | +run:| |
| 103 | + make SIGN=0 VERBOSE=1 ARCH=${{ matrix.goarch }} OS=${{ matrix.goos }} CHANNEL=release VERSION=${{ env.release_VERSION }} GOTOOLCHAIN=local build-release |
| 104 | +
|
| 105 | + -name:Upload files to workspace |
| 106 | +uses:actions/upload-artifact@v4 |
| 107 | +with: |
| 108 | +name:AdGuardHome_release_${{ matrix.name }} |
| 109 | +path:'**/AdGuardHome/AdGuardHome*' |
| 110 | +compression-level:9 |
| 111 | + |
| 112 | +beta: |
| 113 | +runs-on:ubuntu-latest |
| 114 | +outputs: |
| 115 | +beta_version:${{ steps.beta.outputs.beta_version }} |
| 116 | +beta_time:${{ steps.beta.outputs.beta_time }} |
| 117 | +steps: |
| 118 | + -name:Get `AdGuard Home Beta` version and time |
| 119 | +id:beta |
| 120 | +run:| |
| 121 | + beta_version=$(curl -sSL https://api.github.com/repos/AdguardTeam/AdGuardHome/releases | jq -r '[.[] | select(.tag_name | contains("b"))][0].tag_name') |
| 122 | + echo "beta_version=$beta_version" >> $GITHUB_OUTPUT |
| 123 | + beta_time=$(curl -sSL https://api.github.com/repos/AdguardTeam/AdGuardHome/releases | jq -r '[.[] | select(.tag_name | contains("b"))][0].created_at' | xargs -I {} date -d '{} +8 hours' '+%Y-%m-%d') |
| 124 | + echo "beta_time=$beta_time" >> $GITHUB_OUTPUT |
| 125 | +
|
| 126 | +beta_cross: |
| 127 | +runs-on:ubuntu-latest |
| 128 | +strategy: |
| 129 | +matrix: |
| 130 | +include: |
| 131 | +# Linux |
| 132 | + -{ name: linux_amd64, goos: linux, goarch: amd64, goamd64: v1 } |
| 133 | + -{ name: linux_armv5, goos: linux, goarch: arm, goarm: 5 } |
| 134 | + -{ name: linux_armv6, goos: linux, goarch: arm, goarm: 6 } |
| 135 | + -{ name: linux_armv7, goos: linux, goarch: arm, goarm: 7 } |
| 136 | + -{ name: linux_arm64, goos: linux, goarch: arm64 } |
| 137 | + -{ name: linux_mips_softfloat, goos: linux, goarch: mips, gomips: softfloat } |
| 138 | + -{ name: linux_mipsle_softfloat, goos: linux, goarch: mipsle, gomips: softfloat } |
| 139 | +# Windows |
| 140 | + -{ name: windows_amd64, goos: windows, goarch: amd64, goamd64: v1 } |
| 141 | + -{ name: windows_arm64, goos: windows, goarch: arm64 } |
| 142 | + |
| 143 | +fail-fast:false |
| 144 | +needs: |
| 145 | + -go |
| 146 | + -node |
| 147 | + -beta |
| 148 | +env: |
| 149 | +beta_VERSION:${{ needs.beta.outputs.beta_version }} |
| 150 | +steps: |
| 151 | + -name:Checkout `AdguardTeam/AdGuardHome` |
| 152 | +uses:actions/checkout@v4 |
| 153 | +with: |
| 154 | +repository:AdguardTeam/AdGuardHome |
| 155 | + |
| 156 | + -name:Setup `Go` |
| 157 | +uses:actions/setup-go@v5 |
| 158 | +with: |
| 159 | +go-version:${{ needs.go.outputs.version }} |
| 160 | + |
| 161 | + -name:Adapt `Go` version |
| 162 | +run:| |
| 163 | + go get go@${{ needs.go.outputs.version }} |
| 164 | + go mod tidy |
| 165 | +
|
| 166 | + -name:Setup `Node` |
| 167 | +uses:actions/setup-node@v4 |
| 168 | +with: |
| 169 | +node-version:${{ needs.node.outputs.version }} |
| 170 | + |
| 171 | + -name:Setup `Snapcraft` |
| 172 | +run:| |
| 173 | + sudo snap install snapcraft --classic |
| 174 | +
|
| 175 | + -name:Build `AdGuard Home Beta` |
| 176 | +id:build |
| 177 | +run:| |
| 178 | + make SIGN=0 VERBOSE=1 ARCH=${{ matrix.goarch }} OS=${{ matrix.goos }} CHANNEL=beta VERSION=${{ env.beta_VERSION }} GOTOOLCHAIN=local build-release |
| 179 | +
|
| 180 | + -name:Upload files to workspace |
| 181 | +uses:actions/upload-artifact@v4 |
| 182 | +with: |
| 183 | +name:AdGuardHome_beta_${{ matrix.name }} |
| 184 | +path:'**/AdGuardHome/AdGuardHome*' |
| 185 | +compression-level:9 |
| 186 | + |
| 187 | +push_adguardhome: |
| 188 | +needs: |
| 189 | + -release_cross |
| 190 | + -release |
| 191 | + -beta_cross |
| 192 | + -beta |
| 193 | +runs-on:ubuntu-latest |
| 194 | +env: |
| 195 | +release_VERSION:${{ needs.release.outputs.release_version }} |
| 196 | +release_TIME:${{ needs.release.outputs.release_time }} |
| 197 | +beta_VERSION:${{ needs.beta.outputs.beta_version }} |
| 198 | +beta_TIME:${{ needs.beta.outputs.beta_time }} |
| 199 | +steps: |
| 200 | + -name:Clone Repository |
| 201 | +uses:actions/checkout@main |
| 202 | + |
| 203 | + -name:Download files from workspace |
| 204 | +uses:actions/download-artifact@v4 |
| 205 | +with: |
| 206 | +path:./tmp-AdGuardHome/ |
| 207 | + |
| 208 | + -name:Batch move and rename `AdGuard Home` files |
| 209 | +run:| |
| 210 | + mkdir -p ./tmp-AdGuardHome/compress/ |
| 211 | + archs=(amd64 armv5 armv6 armv7 arm64 mips_softfloat mipsle_softfloat) |
| 212 | + new_name=(amd64 armv5 armv6 armv7 armv8 mips_softfloat mipsle_softfloat) |
| 213 | + for ((i = 0; i < 7; i++)); do |
| 214 | + mv -f "./tmp-AdGuardHome/AdGuardHome_release_linux_${archs[i]}/dist/AdGuardHome_linux_${archs[i]//v/_}/AdGuardHome/AdGuardHome" "./tmp-AdGuardHome/compress/AdGuardHome_release_linux_${new_name[i]}" |
| 215 | + mv -f "./tmp-AdGuardHome/AdGuardHome_beta_linux_${archs[i]}/dist/AdGuardHome_linux_${archs[i]//v/_}/AdGuardHome/AdGuardHome" "./tmp-AdGuardHome/compress/AdGuardHome_beta_linux_${new_name[i]}" |
| 216 | + done |
| 217 | + chmod +x ./tmp-AdGuardHome/compress/* |
| 218 | +
|
| 219 | + -name:Setup `upx` and compress `AdGuard Home` files |
| 220 | +uses:crazy-max/ghaction-upx@v3 |
| 221 | +with: |
| 222 | +version:latest |
| 223 | +files:./tmp-AdGuardHome/compress/* |
| 224 | + |
| 225 | + -name:Move `AdGuard Home` files |
| 226 | +run:| |
| 227 | + mkdir -p ./AdGuardHome/ |
| 228 | + mv -f ./tmp-AdGuardHome/compress/* ./AdGuardHome/ |
| 229 | + # `Release` for Windows |
| 230 | + mv -f ./tmp-AdGuardHome/AdGuardHome_release_windows_amd64/dist/AdGuardHome_windows_amd64/AdGuardHome/AdGuardHome.exe ./AdGuardHome/AdGuardHome_release_windows_amd64.exe |
| 231 | + mv -f ./tmp-AdGuardHome/AdGuardHome_release_windows_arm64/dist/AdGuardHome_windows_arm64/AdGuardHome/AdGuardHome.exe ./AdGuardHome/AdGuardHome_release_windows_arm64.exe |
| 232 | +
|
| 233 | + # `Beta` for Windows |
| 234 | + mv -f ./tmp-AdGuardHome/AdGuardHome_beta_windows_amd64/dist/AdGuardHome_windows_amd64/AdGuardHome/AdGuardHome.exe ./AdGuardHome/AdGuardHome_beta_windows_amd64.exe |
| 235 | + mv -f ./tmp-AdGuardHome/AdGuardHome_beta_windows_arm64/dist/AdGuardHome_windows_arm64/AdGuardHome/AdGuardHome.exe ./AdGuardHome/AdGuardHome_beta_windows_arm64.exe |
| 236 | + rm -rf ./tmp* |
| 237 | +
|
| 238 | + -name:Release and upload `AdGuardHome` assets |
| 239 | +uses:svenstaro/upload-release-action@v2 |
| 240 | +with: |
| 241 | +repo_token:${{ secrets.GITHUB_TOKEN }} |
| 242 | +release_name:AdGuardHome |
| 243 | +tag:AdGuardHome |
| 244 | +overwrite:true |
| 245 | +body:| |
| 246 | + 更新 [AdGuard Home Release 版](https://github.com/AdguardTeam/AdGuardHome/tree/beta-v0.107)至 ${{ env.release_VERSION }},发布于 ${{ env.release_TIME }} |
| 247 | + 更新 [AdGuard Home Beta 版](https://github.com/AdguardTeam/AdGuardHome/tree/beta-v0.108)至 ${{ env.beta_VERSION }},发布于 ${{ env.beta_TIME }} |
| 248 | +file_glob:true |
| 249 | +file:./AdGuardHome/* |