diff options
| author | loyalsoldier <[email protected]> | 2021-08-27 18:27:16 +0800 |
|---|---|---|
| committer | loyalsoldier <[email protected]> | 2021-08-29 20:09:57 +0800 |
| commit | 85a343aca99d864c517f13cd3169ebcc910ec0d8 (patch) | |
| tree | eccfd3680d9dc6e22f265a9525dccac85902c2ab /.github/workflows | |
| parent | 2b32e8845d9e55b6c23ebb41bd0f382100094386 (diff) | |
Refactor: use plugin architecture to support multiple I/O formats
Diffstat (limited to '.github/workflows')
| -rw-r--r-- | .github/workflows/build.yml | 90 |
1 files changed, 30 insertions, 60 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index eddea8d4..51df292f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,8 +7,11 @@ on: branches: - master paths-ignore: - - "**/README.md" - - "data/**" + - ".gitignore" + - "config-example.json" + - "LICENSE" + - "README.md" + - ".github/dependabot.yml" jobs: build: name: Build @@ -17,19 +20,14 @@ jobs: - name: Set up Go 1.x.y uses: actions/setup-go@v2 with: - go-version: ^1.16 + go-version: ^1.17 - name: Set variables run: | - echo "PATH=$(go env GOPATH)/bin:${PATH}" >> $GITHUB_ENV echo "TAG_NAME=$(date +%Y%m%d%H%M)" >> $GITHUB_ENV echo "RELEASE_NAME=$(date +%Y%m%d%H%M)" >> $GITHUB_ENV shell: bash - - name: Install cidr-merger - run: | - go get github.com/zhanhb/cidr-merger - - name: Checkout codebase uses: actions/[email protected] with: @@ -47,24 +45,6 @@ jobs: curl -sSL https://api.fastly.com/public-ip-list | jq --raw-output '.addresses[],.ipv6_addresses[]' >> data/fastly curl -sSL https://d7uri8nf7uskq.cloudfront.net/tools/list-cloudfront-ips | jq --raw-output '.CLOUDFRONT_GLOBAL_IP_LIST[],.CLOUDFRONT_REGIONAL_EDGE_IP_LIST[]' >> data/cloudfront - - name: Merge CIDR in files except ./data/private - run: | - for file in $(find ./data -type f ! -name "private"); do - cidr-merger --batch -s -o ${file} ${file} - done - - - name: Commit file changes - run: | - if [[ ! -z $(git status | awk '/data\//{print $0}') ]]; then - git config --local user.name "github-actions[bot]" - git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" - git add -A - git commit -m "Chore: auto update appended CIDR list(s)" data/* - git push - else - echo "No modifications." - fi - - name: Get GeoLite2 env: LICENSE_KEY: ${{ secrets.MAXMIND_GEOLITE2_LICENSE }} @@ -72,15 +52,25 @@ jobs: curl -L "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country-CSV&license_key=${LICENSE_KEY}&suffix=zip" -o GeoLite2-Country-CSV.zip unzip GeoLite2-Country-CSV.zip rm -f GeoLite2-Country-CSV.zip - mv GeoLite2* geoip + mv GeoLite2* geolite2 - name: Build geoip.dat file run: | - go run ./ --country=./geoip/GeoLite2-Country-Locations-en.csv --ipv4=./geoip/GeoLite2-Country-Blocks-IPv4.csv --ipv6=./geoip/GeoLite2-Country-Blocks-IPv6.csv --ipv4CN=https://raw.githubusercontent.com/17mon/china_ip_list/master/china_ip_list.txt + go run ./ - - name: Generate geoip.dat sha256 hash + - name: Generate sha256 checksum for dat files run: | - sha256sum geoip.dat > geoip.dat.sha256sum + cd ./output/dat || exit 1 + for name in $(ls *.dat); do + sha256sum ${name} > ./${name}.sha256sum + done + + - name: Generate sha256 checksum for mmdb files + run: | + cd ./output/maxmind || exit 1 + for name in $(ls *.mmdb); do + sha256sum ${name} > ./${name}.sha256sum + done - name: Download GeoLite2 env: @@ -94,7 +84,7 @@ jobs: - name: Move files to publish directory run: | mkdir -p publish - mv geoip.dat geoip.dat.sha256sum *.gz *.zip ./publish + mv ./output/dat/*.dat ./output/dat/*.sha256sum ./output/maxmind/*.mmdb ./output/maxmind/*.sha256sum ./output/text/*.txt *.gz *.zip ./publish/ - name: Git push assets to "release" branch run: | @@ -103,38 +93,18 @@ jobs: 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 geoip.dat geoip.dat.sha256sum *.gz *.zip + git add -A git commit -m "${{ env.RELEASE_NAME }}" git remote add geoip "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}" git push -f -u geoip release - - name: Create a release - id: create_release - uses: actions/[email protected] - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ env.TAG_NAME }} - release_name: ${{ env.RELEASE_NAME }} - draft: false - prerelease: false - - - name: Upload geoip.dat - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./publish/geoip.dat - asset_name: geoip.dat - asset_content_type: application/octet-stream + - name: Remove some files to avoid publishing to GitHub release + run: rm -f ./publish/*.{gz,zip,txt} - - name: Upload geoip.dat sha256sum - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Upload files to GitHub release + uses: svenstaro/upload-release-action@v2 with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./publish/geoip.dat.sha256sum - asset_name: geoip.dat.sha256sum - asset_content_type: text/plain + repo_token: ${{ secrets.GITHUB_TOKEN }} + file_glob: true + file: ./publish/* + tag: ${{ env.TAG_NAME }} |
