name: qqwry on: workflow_dispatch: env: innoextract_version: 1.9 arch: amd64 permissions: contents: write jobs: release: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 - name: Set up python id: setup-python uses: actions/setup-python@v6 with: python-version: '3.11' - name: Caching dependencies uses: actions/cache@v4 with: path: ~/.cache/pip key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} restore-keys: | ${{ runner.os }}-pip- - name: Install dependencies run: | pip install requests pip install bs4 - name: Get download link from WeChat tweet run: | link=$(python qqwry.py) if [ -z "$link" ]; then echo "No link found, exiting" exit 0 fi echo "LINK=${link}" >> $GITHUB_ENV - name: Use link to download newest Zip with retry run: | link=${{ env.LINK }} mkdir -p Downloads cd Downloads retries=0 max_retries=3 while [ $retries -lt $max_retries ]; do wget --no-check-certificate --user-agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36" $link if [ $? -eq 0 ]; then break fi retries=$((retries+1)) sleep 10 done - name: Cache innoextract uses: actions/cache@v4 id: cache-innoextract with: path: innoextract key: ${{ runner.os }}-innoextract-${{ env.innoextract_version }} - name: Download innoextract if: steps.cache-innoextract.outputs.cache-hit != 'true' run: | wget https://github.com/dscharrer/innoextract/releases/download/${{ env.innoextract_version }}/innoextract-${{ env.innoextract_version }}-linux.tar.xz tar -xvf innoextract-${{ env.innoextract_version }}-linux.tar.xz innoextract-${{ env.innoextract_version }}-linux/bin/${{ env.arch }}/innoextract --strip-components 3 - name: Get qqwry.dat id: dat_date shell: pwsh run: | $zip = (Get-ChildItem Downloads\*.zip)[0].FullName $filename = (Get-ChildItem Downloads\*.zip)[0].Name $name = $filename.Substring($filename.IndexOf('-') + 1 , $filename.length - $filename.IndexOf('-') - 5) echo "dat_date=$name" | Out-File -FilePath $env:GITHUB_ENV 7z e -y $zip setup.exe ./innoextract setup.exe -I qqwry.dat - name: Check if tag exists run: | git fetch --tags echo "Value of dat_date: ${{ env.dat_date }}" if git rev-parse ${{ env.dat_date }} >/dev/null 2>&1; then echo "Tag already exists, skipping create release" echo "TAG_EXISTS=true" >> $GITHUB_ENV fi - name: Calculate file hash value id: calculate_hash_value run: | echo "FILE_HASH=$(sha256sum app/qqwry.dat | awk '{ print $1 }')" >> $GITHUB_ENV - name: Create Release id: create_release uses: FW27623/release@v1 if: env.TAG_EXISTS != 'true' with: commit: ${{ env.GITHUB_SHA }} tag: ${{ env.dat_date }} token: ${{ secrets.qqwry }} artifacts: app/qqwry.dat body: | #### qqwry.dat | Name | Value | | :----------------: | :------------------------: | | Zip Download link: | ${{ env.LINK }} | | File hash: | qqwry.dat: ${{ env.FILE_HASH }} |

Version: ${{ env.dat_date }}

- name: Calculate repository hash value id: calculate_repo_hash_value run: | echo "REPO_HASH=$(git show main:qqwry.dat | sha256sum | awk '{ print $1 }')" >> $GITHUB_ENV - name: Check for changes in qqwry.dat id: check run: | if [ ! -f qqwry.dat ]; then echo "File does not exist" echo "RUN_NEXT_STEP=true" >> $GITHUB_ENV else #比较上面的两个hash值是否相等 if [ "${{ env.FILE_HASH }}" != "${{ env.REPO_HASH }}" ]; then echo "File has changed" echo "RUN_NEXT_STEP=true" >> $GITHUB_ENV else echo "File has not changed" fi fi - name: Commit qqwry.dat if: env.RUN_NEXT_STEP == 'true' env: GIT_USERNAME: ${{ secrets.GIT_USERNAME }} GIT_EMAIL: ${{ secrets.GIT_EMAIL }} run: | git config --global user.name $GIT_USERNAME git config --global user.email $GIT_EMAIL if ! git status -s | grep qqwry.dat --quiet; then mv app/qqwry.dat qqwry.dat git add qqwry.dat git commit -m "Update qqwry.dat in ${{ env.dat_date }}" git push fi