Skip to content

Commit

Permalink
Check update according to upstream latest tag
Browse files Browse the repository at this point in the history
  • Loading branch information
Loyalsoldier committed Nov 1, 2020
1 parent 13e3b5a commit 09d0f02
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,49 @@ jobs:
with:
go-version: ^1.15

- name: Set variables
- name: Compare latest tags and set variables
run: |
echo "RELEASE_NAME=$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV
echo "TAG_NAME=$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV
upstreamLatestTag=$(curl -sSL --connect-timeout 5 -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/v2fly/domain-list-community/releases/latest | grep "tag_name" | cut -d\" -f4)
thisLatestTag=$(curl -sSL --connect-timeout 5 -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/${{ github.repository }}/releases/latest | grep "tag_name" | cut -d\" -f4)
if [[ $upstreamLatestTag != $thisLatestTag ]]; then
echo "NeedToSync=true" >> $GITHUB_ENV
fi
echo "RELEASE_NAME=$upstreamLatestTag" >> $GITHUB_ENV
echo "TAG_NAME=$upstreamLatestTag" >> $GITHUB_ENV
shell: bash

- name: Checkout codebase
uses: actions/checkout@v2
if: ${{ env.NeedToSync }}

- name: Checkout v2fly/domain-list-community
if: ${{ env.NeedToSync }}
uses: actions/checkout@v2
with:
repository: v2fly/domain-list-community
path: domain-list-community

- name: Append attribute rules
if: ${{ env.NeedToSync }}
run: |
echo "include:geolocation-!cn@cn" >> ./domain-list-community/data/cn
echo "include:geolocation-cn@!cn" >> ./domain-list-community/data/geolocation-\!cn
- name: Get dependencies and run
if: ${{ env.NeedToSync }}
run: |
go mod download
go run ./ --datapath=./domain-list-community/data
- name: Rename to geosite.dat && generate sha256 hash
if: ${{ env.NeedToSync }}
run: |
cd publish || exit 1
mv dlc.dat geosite.dat
sha256sum geosite.dat > geosite.dat.sha256sum
- name: Git push assets to "release" branch
if: ${{ env.NeedToSync }}
run: |
cd publish || exit 1
git init
Expand All @@ -61,6 +72,7 @@ jobs:
git push -f publish release
- name: Create a release
if: ${{ env.NeedToSync }}
id: create_release
uses: actions/create-release@v1
env:
Expand All @@ -72,6 +84,7 @@ jobs:
prerelease: false

- name: Upload geosite.dat
if: ${{ env.NeedToSync }}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -82,6 +95,7 @@ jobs:
asset_content_type: application/octet-stream

- name: Upload geosite.dat sha256sum
if: ${{ env.NeedToSync }}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down

0 comments on commit 09d0f02

Please sign in to comment.