build.yml #2414
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: build.yml | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: "30 3,9,15,21 * * *" | |
| push: | |
| branches: | |
| - master | |
| paths-ignore: | |
| - "**/README.md" | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Set variables | |
| run: | | |
| echo "RELEASE_NAME=Released on $(date +%Y%m%d%H%M)" >> $GITHUB_ENV | |
| echo "TAG_NAME=$(date +%Y%m%d%H%M)" >> $GITHUB_ENV | |
| echo "GEOIP_URL=https://raw.githubusercontent.com/runetfreedom/russia-blocked-geoip/release/geoip.dat" >> $GITHUB_ENV | |
| echo "GEOSITE_URL=https://raw.githubusercontent.com/runetfreedom/russia-blocked-geosite/release/geosite.dat" >> $GITHUB_ENV | |
| shell: bash | |
| - name: Checkout runetfreedom/geodat2srs | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: runetfreedom/geodat2srs | |
| path: geodat2srs | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: ./geodat2srs/go.mod | |
| - name: Collect files | |
| run: | | |
| mkdir -p ./publish | |
| curl -sSL $GEOIP_URL > ./publish/geoip.dat | |
| curl -sSL $GEOIP_URL.sha256sum > ./publish/geoip.dat.sha256sum | |
| curl -sSL $GEOSITE_URL > ./publish/geosite.dat | |
| curl -sSL $GEOSITE_URL.sha256sum > ./publish/geosite.dat.sha256sum | |
| - name: Generate sing-box srs | |
| run: | | |
| go build -C geodat2srs ./ | |
| ./geodat2srs/geodat2srs geoip -i ./publish/geoip.dat -o ./tmp/sing-box/rule-set-geoip/ | |
| ./geodat2srs/geodat2srs geosite -i ./publish/geosite.dat -o ./tmp/sing-box/rule-set-geosite/ | |
| cd ./tmp/sing-box || exit 1 | |
| zip -r ../../publish/sing-box.zip * | |
| - name: Release and upload assets | |
| uses: svenstaro/upload-release-action@v2 | |
| with: | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| release_name: ${{ env.RELEASE_NAME }} | |
| tag: ${{ env.TAG_NAME }} | |
| file_glob: true | |
| file: ./publish/* | |
| - name: Git push assets to "release" branch | |
| run: | | |
| rm -rf ./publish/sing-box.zip | |
| mv ./tmp/sing-box ./publish/sing-box | |
| cd publish || exit 1 | |
| git init | |
| git config --local user.name "github-actions[bot]" | |
| git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git checkout -b release | |
| git add . | |
| git commit -m "${{ env.RELEASE_NAME }}" | |
| git remote add origin "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}" | |
| git push -f -u origin release |